# normals and GL_TRIANGLE_STRIP

How do I generate normals from the vertexes below?:

glBegin(GL_TRIANGLE_STRIP);
fVertexes = (i+1-fSize/2)/2;
fVertexes = m_fWater[i+1][j+1]-2;
fVertexes = (j+1-fSize)/2;
fVertexes = (i-fSize/2)/2;
fVertexes = m_fWater[i][j+1]-2;
fVertexes = (j+1-fSize)/2;
fVertexes = (i+1-fSize/2)/2;
fVertexes = m_fWater[i+1][j]-2;
fVertexes = (j-fSize)/2;
fVertexes = (i-fSize/2)/2;
fVertexes = m_fWater[i][j]-2;
fVertexes = (j-fSize)/2;

glTexCoord2f(m_fTransWaterX+tx+td, m_fTransWaterZ+ty+td);
glVertex3f(fVertexes,fVertexes,fVertexes);
glTexCoord2f(m_fTransWaterX+tx, m_fTransWaterZ+ty+td);
glVertex3f(fVertexes,fVertexes,fVertexes);
glTexCoord2f(m_fTransWaterX+tx+td, m_fTransWaterZ+ty);
glVertex3f(fVertexes,fVertexes,fVertexes);
glTexCoord2f(m_fTransWaterX+tx, m_fTransWaterZ+ty);
glVertex3f(fVertexes,fVertexes,fVertexes);
glEnd();

[This message has been edited by dcd (edited 02-06-2003).]

This is a heightmap, right?

To get a normal of vertex[x, z], make a vector from vertex[x-1, z] to vertex[x+1, z], and another vector from vertex[x, z-1] to vertex[x, z+1]. The normal is the normalized cross product of these two vectors.

-Ilkka

Actually it is just a water texture with a water algorithm applied to the y axis. I have a calculateNormals() function that takes 3 vertices, but I don’t think it will work in this case. What I am doing is creating a triangle strip out of two triangles out of 4 vertices like:

2 1
|\ |
|
|
4 3

Does what you proposed still work for this scenario? Or do I have to calculate the normal for each triangle and then average them?