# Lighting a surface of revolution

I wasnt sure of posting this here, since it is a very basic question, but it is math related so I guess it would be better to post it here.
I have to finish an OpenGL project for college, and my deadline is tomorrow at midnight, I have tried everything and can’t find the solution.
I have to display a surface of revolution and add some lights (the surface of revolution happens to be a windmill), my classmates chose other objects such as hands or simple robots that were easier to light, so they couldn’t help me.
My problem is about calculating the normal vectors of the surface.
The surface is drawn as follows

for(v=0;v<=1;v+=K)
{
for(u=0;u<=sqrh;u+=K)
{
glVertex3f(top(u)Rsin(v2PI),Ru3,top(u)Rcos(v2PI));
glVertex3f(top(u)Rsin((v+K)2PI),Ru3,top(u)Rcos((v+K)2PI));
}
glEnd();
}

GLfloat top(GLfloat u)
{

return (float)height - (u*u);
}

The teacher told me to calculate the normals by using the vector product of the partial derivatives of the ecuation.
I wrote this

GLfloat t1[3],t2[3];

t1[0] = topd(u)Rsin(v2PI);
t1[1] = 3R;
t1[2] = topd(u)Rcos(v
2*PI);

t2[0] = 2PI * R * top(u) * cos(v2PI);
t2[1] = 0;
t2[2] = -R
top(u)2PIsin(v2*PI);

VectorProduct(normal,t2,t1);
Normalize(normal);

Where topd() is

GLfloat inline topd(GLfloat u)
{
return (float)-(2*u);
}

When i render it, almost the 90% of the object is completely white, and just a very small zone is shaded.
The teacher says that there is something wrong with the normal vectors, but I am completely clueless now.
Any help woulde be really appreciated

If you want, you can tell OpenGL to calculate the normals for you. In your initialize function, add

glEnable(GL_NORMALIZE);

This is sort of slow and not recommended, but if you have a tight deadline, maybe you should try it.

Originally posted by while(fork()):
[b]If you want, you can tell OpenGL to calculate the normals for you. In your initialize function, add

glEnable(GL_NORMALIZE);

This is sort of slow and not recommended, but if you have a tight deadline, maybe you should try it.[/b]

GL_NORMALIZE will scale you normals to unit length after transformation but it will not generate normals, as far as I know.

while(fork()) thanks a lot!
As satan said, that does not do the whole normal calculation, (without my normal vector calculation routine it fails), but if I use both my routine and glEnable(GL_NORMALIZE) as you said, everything works incredibly great. Now I will be able to submit my project as scheduled, thanks!!!