# Hemispheres

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.

Thanks

Get the source code for Glut, and adapt the glutSolidSphere code, it should be pretty easy.
http://www.opengl.org/resources/libraries/glut.html

You could try gluSphere() with an additional clipping plane.

1 Sorry, but I’m a bit of a noob, where exactly on that site can i get the code for glutSolidSphere?

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

yeah, ive got the .tar.gz file, but theres a lot of files inside it any clue which one will have the code for gluSphere that i need in it?

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;
glEnable(GL_CLIP_PLANE0);
for(i=0; i<16; i++)
{
glClipPlane(GL_CLIP_PLANE0, clipEq[i]);
glPushMatrix();
// Transform
gluSphere(q, size, numSegs, numSegs);
glPopMatrix();
}
``````

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,
Ben

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?

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.

thanks a lot mate, just got them to work, sorry for the hassle

Originally posted by <LordSigmund>:
… trying to do is create a transparent hollow cylinders ending in 2 hemispheres.
Try this …

``````   static GLUquadricObj * q = 0;
if(!q)
{
}

double clipEq =
{ { radius, 0.0, 0.0, 1.0 }, { -radius, 0.0, 0.0, 1.0 } };

// Red hemisphere
glPushMatrix();
glColor3f(1.0, 0.0, 0.0);
glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0, clipEq);
glPopMatrix();

// Green hemisphere
glPushMatrix();
glColor3f(0.0, 1.0, 0.0);
glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0, clipEq);