View Full Version : Hemispheres

05-11-2004, 08:31 AM
How can i create a hollow hemisphere in OpenGL? (ie. half of a glutSolidSphere object)

It's driving me up the wall trying to work it out.


05-11-2004, 08:37 AM
Get the source code for Glut, and adapt the glutSolidSphere code, it should be pretty easy.

05-11-2004, 08:42 AM
You could try gluSphere() with an additional clipping plane.

05-11-2004, 08:52 AM
1 Sorry, but I'm a bit of a noob, where exactly on that site can i get the code for glutSolidSphere?

2. I thought about clipping planes, but after looking into it, i was under the impression that you can only have 6 clipping planes. I need to create 16 hemishere though.

05-11-2004, 09:08 AM
You can get glut source (follow links) at http://www.opengl.org/resources/libraries/glut.html.

05-11-2004, 09:19 AM
yeah, ive got the .tar.gz file, but theres a lot of files inside it :D

any clue which one will have the code for gluSphere that i need in it?

05-11-2004, 09:39 AM
You can use gluSphere with just 1 clipping plane ... even for 16 hemispheres. Just specify the appropriate clipping plane equation before you draw each sphere.

double clipEq[16][4];
for(i=0; i<16; i++)
glClipPlane(GL_CLIP_PLANE0, clipEq[i]);
// Transform
gluSphere(q, size, numSegs, numSegs);

05-11-2004, 09:45 AM
Originally posted by <LordSigmund>:
which one will have the code for gluSphere that i need in it?I don't think GLUT has the gluSphere source ... only the glut**Sphere source. See glut_shapes.c.

You can do a google search (e.g. with spherical coordinates) to get an algorithm to generate the mesh yourself. This might be more what you need.

Hope this helps,

05-11-2004, 10:17 AM
Thanks for the help, i think thats the right track, but im having trouble understanding glClipPlane

how does the plane equation define the plane?

what im trying to do is create a transparent hollow cylinders ending in 2 hemispheres. im going to be looking out of them (theyre carriages in a ferris whell to be exact), so i cant just use spheres and hide the other half.

so, when i setup my carriage object, i need to define two vertical and parallel clipping planes at either end of my cylinder

how do i define the clipping planes to do this, i dont understand the manual explanation for the equation?

05-11-2004, 10:29 AM
The equation for glClipPlane is the equation [A,B,C,D] that satisfies the relationship Ax+By+Cz+D=0. [x,y,z] is a point in 3-space. [A,B,C] defines the plane normal vector. D defines the distance from the origin to the plane along the plane normal.

In other words, for a given [x,y,z] you are on the plane if the equation yields zero. Anything behind the plane's half-space (away from normal) is clipped. Anything in front is kept.

Playing around with the book example, clip.c, should help you understand. Try varying the clip equation.

05-11-2004, 11:01 AM
thanks a lot mate, just got them to work, sorry for the hassle

05-11-2004, 11:02 AM
Originally posted by <LordSigmund>:
... trying to do is create a transparent hollow cylinders ending in 2 hemispheres.Try this ...

static GLUquadricObj * q = 0;
q = gluNewQuadric();
gluQuadricDrawStyle(q, GLU_FILL);

double radius = 10.0;
double clipEq[2][4] =
{ { radius, 0.0, 0.0, 1.0 }, { -radius, 0.0, 0.0, 1.0 } };

// Red hemisphere
glColor3f(1.0, 0.0, 0.0);
glTranslatef(radius, 0.0, 0.0);
glClipPlane(GL_CLIP_PLANE0, clipEq[0]);
gluSphere(q, radius, 16, 16);

// Green hemisphere
glColor3f(0.0, 1.0, 0.0);
glTranslatef(-radius, 0.0, 0.0);
glClipPlane(GL_CLIP_PLANE0, clipEq[1]);
gluSphere(q, radius, 16, 16);

// Blue cylinder
glColor3f(0.0, 0.0, 1.0);
glRotatef(90.0, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -radius);
gluCylinder(q, radius, radius, 2.0*radius, 16, 16);