I am trying to light up a large area of triangle strips. For that I need to specify a normal vector for each vertex.
I am using glDrawElements() with GL_TRIANGLE_STRIP. I have a vector with the triangle coordinates.
As I understand, I can specify only one normal vector for each triangle (for non-smooth results). In that case, how should I create the normal vector? Where should I put the data for it? Should I add it to the coordinate vector? This might be a problem because each vertex is a part of more then one triangle.
There are 2 more vertices then triangle in each stripe. How many normals should I use, and in what order?
Is it possible to use interleaved arrays in that case? If so how?
There is an option of N3F_V3F in the parameters for glIterleavedArray(), but how sould I specify the normals in case I am using triagnle tripes?
You provide one normal for each vertex. Smooth shading will interpolate the surface normals across each triangle. I can''t tell you more about how to figure out the surface normals without knowing what kind of surface you''re trying to specify. A hint, though: figure out all the polys that share (or are adjacent to) the vertex and give that vertex the average of the normals of the neighboring polys.
I understand how to calculate the normals. My question is more specific: How do I enter the normals to a triangle strip? Which command do I use, in what order should the normals be ordered in order for them to match the correct triangle?
Well I don''t know much about interleaved arrays yet. With standard vertex arrays, you specify a glVertexPointer pointing to an array of x,y,z positions for all vertices. And a glNormalPointer pointing to an array of x,y,z normals for all vertices. For texture coordinates, colors, etc, etc you''d pass another pointer. Just make sure to enable each of the arrays you pass to OpenGL using glEnableClientState.
For information how to do this with interleaved arrays, I suggest you try looking in the Red Book: http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/