PDA

View Full Version : finding normals of a sphere



cg-hci_novice
11-09-2003, 10:02 PM
Hi,

How can I determine the normals of a sphere so I can make it a pt light src?

References to red book, superbible, etc. are very welcome.

Thanks a lot.

cg-hci_novice
11-09-2003, 10:17 PM
I should add that the sphere was created as a quadric object using gluSphere where the first arg to gluSphere was a ptr to the quadric.

mikael_aronsson
11-09-2003, 10:18 PM
What kind of normals do you need ?

Surface normals is calculated on a triangle so it does not matter what kind of "object" it is, google has zillions of tutorials on how to do that.

Vertex normals is pretty easy for a sphere, it just the line from the center of the sphere to the vertex, and maybe normalize it.
if the spheres origin is at 0,0,0 it's very simple, or to put it simple, if you have the radius of the sphere set to one, then the coordinate of each vertex is the normal for the vertex.

You could also download Mesa or SGI's sample OpenGL implementation, they both include source code for the GLU library so you cen have a peek at how they did gluSphere.

Mikael

cg-hci_novice
11-09-2003, 10:27 PM
Thanks.

Basically, need to make a sphere (sun) a point light source. I think maybe what you said with the radius might apply to what I am doing but not sure (?)

Would I need to set the 1st element of the light_pos array to the center (in my case 0, 0) to be + and - the radius?

Thanks.