View Full Version : Rotate?
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!
03-01-2001, 08:50 PM
glPushMatrix/glPopMatrix may help.
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.
03-02-2001, 01:57 PM
As RandyU said, you can use glPushMatrix, glPopMatrix. you use it something like so.
for each object
03-03-2001, 07:53 AM
To rotate an object around x,y,z:
y' = y * Cos(angx) - z * Sin(angx);
z' = y * Sin(angx) + z * Cos(angx);
x' = x * Cos(angy) + z * Sin(angy);
z' = -x * Sin(angy) + z * Cos(angy);
x' = x * Cos(angz) - y * Sin(angz);
y' = x * Sin(angz) + y * Cos(angz);
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.