Advertisement

Normals for quad strips...

Started by February 07, 2003 11:54 AM
6 comments, last by James Trotter 22 years ago
Ok, I''m drawing Quad Strips in my program, and I''m specifying the normals for them, but what I''m wondering about is if I can do it like this: glNormal3f(Normal[0].x, Normal[0].y, Normal[0].z); glVertex3f(Vertex[0].x, Vertex[0].y, Vertex[0].z); glVertex3f(Vertex[1].x, Vertex[1].y, Vertex[1].z); glVertex3f(Vertex[2].x, Vertex[2].y, Vertex[2].z); glNormal3f(Normal[1].x, Normal[1].y, Normal[1].z); glVertex3f(Vertex[3].x, Vertex[3].y, Vertex[3].z); Or if I just use the same normal for the whole Quad Strip... Any help is greatly appreciated!
Rememer that OpenGL is a (finite) state machine. So normal will be used for all vertices processed until you send a new one.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Advertisement
Yes, thank you DarkWing, but I''m already aware of that. But what I wanted to know is if the second normal counts for the second quad... Because of that after the three first vertices, every new vertex specifies a new quad...
I think each normal counts for only the vertex not a whole quad. You can then have a quad with 4 different normals if you want smoother lighting.
Thank you Xiros! But is there really a way to calculate normals per vertex?? If there is I would really like to know. So please, if you have any tutorials, references, etc...
a vertex has no normal, you can only get the normal from a plane (3 points). to do that just take the cross product of two vectors (two sides of a triangle).
Advertisement
If you want your object to appear smooth (e.g. a sphere), then you need to calculate an average normal from the vectors of the neighboring polygon edges.

If you want it to appear angular (e.g. a cube) then for each vertex have it calculated as the cross product of two of the polygons edges.

I have not done much 3D, and one thing I am curious about is how the artist controls the normals in a model - I have made a 3d model before but at no point did I seem to have direct control of the vertice normals, so how could the program possibly know what was supposed to be a smooth edge and what was supposed to be a angular edge?

One way I thought is that if it is a large angle (say 150 degs)between edges then the normal would be averaged, otherwise it is normal to the polygon face, is this correct?
quote:
Original post by xiros
I think each normal counts for only the vertex not a whole quad. You can then have a quad with 4 different normals if you want smoother lighting.


I am possibly mistaken here, but..If you are using index buffers, then you can only have one averaged normal, and all the faces surrounding it will be smooth, and even if you weren''t, you would set all the vertice normals to the same direction to make it appear smooth (how exactly this would be done without an index buffer I dont know).

This topic is closed to new replies.

Advertisement