jessica

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?

View Full Version : Please help with openGl

jessica

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?

Deiussum

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.

jessica

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

Deiussum

10-27-2003, 09:03 AM

Then you can either do your own sphere calculations, or use clip planes to clip the gluSphere.

mdog1234

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.

jessica

10-27-2003, 09:48 AM

Thank you for the replies. DO you know if theres some example code out there someplace?

thanks

Jessy

thanks

Jessy

yaro_dup1

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).]

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..

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.