Calculating the normal

I am in big doubt of calculating the normal…

Lets say i want to calculate the normal for the following quad with those exact values. I mean, do i have to take 2 of the points, subtract them from each other, to get a vector, then do the same with other points, and then take the cross-product of these two vectors, and then normalize - of course all done on paper, cause it doesnt make any sense computing all of that (i dont even know how to implement that). I know that OpenGL does this for you, but how can i make OpenGL do it for me with this example?


glVertex3f(-200.0f, 110.3f, -100.0f); 
glVertex3f(-100.0f, 110.3f, 100.0f);		
glVertex3f(100.0f,  110.3f, 100.0f);
glVertex3f(200.0f,  110.3f, -100.0f);

glNormal3f( ?, ?, ?);

In OpenGL there is no such thing as a face normal, therefore i have to calculate the normal for each vertex, not that it matters cause i am still kind of lost…
any thoughts?

OpenGL will not calculate the normals for you. You have to do it yourself and specify them. That means you have to implement your own vector library that has normalize operation and cross product operations (+ and - helps too).

If it’s a static model (doesn’t change) it makes sense to store the computed normals along with the vertices somewhere. But you’ll still need the code to compute them.

You specify a normal for each vertex because in rounded objects like spheres a normal that is the average of normals around it will give you better lighting than just face normal for each triangle in the sphere. Again you’d have to compute and decide what normals to average. For a sphere of course you don’t have to average but can use a very simple algorithm of vertex - center of sphere to compute the normal. For other surfaces it’s a different algorithm.

Actually, there are face normals in OpenGL. They are implemented by calling glNormal once per poly (shown below). To specify vertex normals glNormal would be called before each glVertex call.

glBegin (GL_QUADS);

glNormal3f ( ???, ???, ???);
glVertex3f (-200, 110, -100);
glVertex3f (-100, 110, 100);
glVertex3f ( 100, 110, 100);
glVertex3f ( 200, 110, -100);

glEnd ();