View Full Version : Please help with openGl

10-27-2003, 07:26 AM
I wanted to render a section of a sphere and then find the normals at every point on the shape. I want the radius of the sphere to be 10cm. Can anybody tell me how to do that in opengl?

10-27-2003, 07:50 AM
Rendering a sphere can be done with gluSphere. OpenGL itself won't calculate normals for you, but the normal calculation for a sphere is pretty simple. For any point v on the sphere, the normal would be normalize(v - c), where c is the center of the sphere, and normalize sets the length of the resulting vector to 1.

10-27-2003, 08:11 AM
Hi thanks for your reply but the gluSphere renders a whole sphere and i just want half of it

10-27-2003, 09:03 AM
Then you can either do your own sphere calculations, or use clip planes to clip the gluSphere.

10-27-2003, 09:04 AM
you will have to either do the math for half a sphere or create the object in maya or another package and load it into the program.

10-27-2003, 09:48 AM
Thank you for the replies. DO you know if theres some example code out there someplace?


10-28-2003, 04:09 AM
These are equations for every vertex in a sphere:
x = radius * cos(alpha)*sin(theta)
y = radius * sin(alpha)*sin(theta)
z = radius * cos(theta)

If you a half of sphere just render it with theta from 0 to 90 degrees and alpha from 0..360. Whole sphere would be theta from -90..90 degrees.

[This message has been edited by glYaro (edited 10-28-2003).]

10-29-2003, 06:57 PM
THanks. I know the equation of the sphere. Unfortunately its the rendering that im having trouble with..