PDA

View Full Version : quick question about Rotating objects on their OWN axis



jubei_GL
05-01-2002, 05:35 PM
Ok.. I want to create an object that will rotate with respect to its OWN axis, and not the Global axis..

glRoteted(1,0,0)
glPushMatrix()
drawObject
glPopMatrix()

when I rotate around X, the object does not rotate on its Axis but, rotates on Global Axis.. I think that if I would put glRotated() inside the Push/Pop Matrix, the object would rotate with respect to its own axis, am I right ????



[This message has been edited by jubei_GL (edited 05-01-2002).]

rhs
05-01-2002, 08:25 PM
glPushMatrix()
glRoteted(1,0,0)
drawObject
glPopMatrix()

now it will

Jambolo
05-02-2002, 03:37 PM
The object already will rotate on its own axis. The push and pop prevent other objects from being rotated too.

velco
05-03-2002, 06:19 AM
You should first rotate and then translate
the object, i.e. in the source the calls should
be glTranslate first, glRotate second.

nexusone
05-03-2002, 06:45 AM
If you want only the object to rotate and not the world, then you have to push, rotate and pop the object. That also includes other objects that you also want to rotate around their axis also, each object will have to be push, rotate and pop!!!

example:

//list of objects to draw

for(x=0; x < 10; x++) //Draw ten objects rotating around their axis.
{
glPushMatrix()
glTranslate(......)// move our object some place on the screen.
glRotate(......)// Rotate around axis
draw_object(x); // Draw object number x
glPopMatrix()
}



Originally posted by Jambolo:
The object already will rotate on its own axis. The push and pop prevent other objects from being rotated too.



[This message has been edited by nexusone (edited 05-03-2002).]

Jambolo
05-03-2002, 02:07 PM
Originally posted by velco:
...glTranslate first, glRotate second.

Yes, like this.

Translating first/rotating second will translate in the current system, then rotate in the new (translated) system. Rotating first/translating second will rotate in the current system, then translate in the new (rotated) system. Scale works the same way. If you understand this, then you understand how the order of transformations works in OpenGL.