PDA

View Full Version : Rotate?



newmannium
03-01-2001, 08:29 PM
How can I rotate an object around an
axis while preventing the axis rotating?

I draw the axis and the object, and
when I try to JUST rotate the object,
I find that the axis rotates also.

Thanks a lot!

RandyU
03-01-2001, 08:50 PM
glPushMatrix/glPopMatrix may help.

dpgraves
03-02-2001, 09:39 AM
You're talking about when you're using the glRotate function right? I ran into this problem also. I managed to work around this using my own matrix and rotation code. I just pass it the local vertices of the object I want rotated. Though I would like to know how to rotate a singe object using OpenGL also.

Deiussum
03-02-2001, 01:57 PM
As RandyU said, you can use glPushMatrix, glPopMatrix. you use it something like so.

for each object
{
glPushMatrix();
ObjectTransformations();
DrawObject();
glPopMatrix();
}

billy
03-03-2001, 07:53 AM
To rotate an object around x,y,z:

Around x
y' = y * Cos(angx) - z * Sin(angx);
z' = y * Sin(angx) + z * Cos(angx);

Around y
x' = x * Cos(angy) + z * Sin(angy);
z' = -x * Sin(angy) + z * Cos(angy);

Around z
x' = x * Cos(angz) - y * Sin(angz);
y' = x * Sin(angz) + y * Cos(angz);

Tim Stirling
03-03-2001, 08:44 AM
If you are drawing the axis and jsut want to watch an object roate around it (I think this is what you want) put your code to draw the axis before you use the glRotatef() function.