 # Normal calculations look right,but my scene doesnt

Hi there. I’m trying to make a flat shaded heightmap rendering engine, but I can’t seem to get it looking the way it should. I’ve asked around and rechecked but it just refuses to work.
I’ve posted the code I use to calculate my normals and then render the triangles. Maybe someone with an eye for OpenGL rendering can see what’s going on here.

------- Source code ---------
http://utilitybase.com/paste/26026 <-- Vector and cross product classes and functions
http://ec.codepad.org/NsxUim61 <-- Code to calculate normals

----------- Image results ----------
http://up.mibbit.com/up/06o2n8oG.png
http://up.mibbit.com/up/8LkRvtkd.png
http://up.mibbit.com/up/uxcfl8sS.png

Maybe a little explanation of the images. The first image is back lit, the white lines and face represents the position of the light source.

The second image is the scene with specular lighting added, and the yellow hairs are vertex; vertex + the normal for the top left hand triangle.

and the third shows that lighting does somewhat work.

Do you assume that the vertices are give in counter - clockwise
order?

From my understanding everything is stored in CW coordinates. Am I calculating my normals wrong here? From what I just tried when the light is behind something, it lights up, and when it’s infront, it gets dark. It’s like it’s reveresed

a = v1 - v2;
b = v2 - v3;

n = CrossProduct(a, b);
n.Normalize();
m_normals[(x + (z * m_size)) * 2 + 0] = n;
// Calc the normals of the second
b = v4-v2;
a = v2-v3;

n = CrossProduct(a, b);
n.Normalize();
m_normals[(x + (z * m_size)) * 2 + 1] = n;

I think that the accepted way to store vertices is CCW
In the application I write now, not all surfaces have the same ordering of vertices

`````` glEnable(GL_NORMALIZE);