Sphere Rotation Problems

Hi everyone.

I’m trying to get a sphere to orbit a bigger one, and it’s not working. I’m using OpenGL in Delphi 7, and this is the code I’m using. If anyone knows what the problem is, could they let me know? Thanks.

glLoadIdentity();
glTranslatef(0.0,0.0,-6.0);
gluSphere(quadratic,1.0,32,32);
glRotatef(0.5,0.0,1.0,0.0);
glTranslatef(2.0,0.0,0.0);
gluSphere(quadratic,0.2,32,32);

glEnd();

Also, many thanks to SThomas for trying to help me out before.

Originally posted by W. Poons:
[b]Hi everyone.

I’m trying to get a sphere to orbit a bigger one, and it’s not working. I’m using OpenGL in Delphi 7, and this is the code I’m using. If anyone knows what the problem is, could they let me know? Thanks.

glLoadIdentity();
glTranslatef(0.0,0.0,-6.0);
gluSphere(quadratic,1.0,32,32);
glRotatef(0.5,0.0,1.0,0.0);
glTranslatef(2.0,0.0,0.0);
gluSphere(quadratic,0.2,32,32);

glEnd();[/b]

Your glRotate function should pass a variable not 0.5 such that the variable is incremented by 0.5 or whatever value you want. Otherwise, it will be rotated at 0.5 degrees about the y axis but not consecutively and appear stationary.

glLoadIdentity();
glTranslatef(0.0,0.0,-6.0);
gluSphere(quadratic,1.0,32,32);
glRotatef(angle,0.0,1.0,0.0);
glTranslatef(2.0,0.0,0.0);
gluSphere(quadratic,0.2,32,32);

angle += 0.5;

W.poons is right but he didn’t write the actual code. it looks like:
while(1)
{

rotate(angle,…);
angle+=whatever you want increase each loop;
}

Originally posted by W. Poons:
[b]Hi everyone.

I’m trying to get a sphere to orbit a bigger one, and it’s not working. I’m using OpenGL in Delphi 7, and this is the code I’m using. If anyone knows what the problem is, could they let me know? Thanks.

glLoadIdentity();
glTranslatef(0.0,0.0,-6.0);
gluSphere(quadratic,1.0,32,32);
glRotatef(0.5,0.0,1.0,0.0);
glTranslatef(2.0,0.0,0.0);
gluSphere(quadratic,0.2,32,32);

glEnd();[/b]

Or if you want a continual motion, don’t load you identity matrix