View Full Version : rotating at the right axis

11-22-2001, 10:50 PM
now i want to rotate the 3d model with respect of its axis , if i want to rotate the model with respect of its x axis, it only rotate around x axis .. and so on..for y and z ..
now i have to use glRotatef right ???

here partial of my code :

glRotatef (value , 1,0,0);
glRotatef(Value , 0,1,0);
glRotatef(value ,0,0,1);


but after i rotate the model first at x ,second at y , third at z axis and at the fourth time at x axis again ,now rotation is no longer following its own axis
(let say i want to rotate again at x axis , the model rotate with the world x axis rather its own x axis , same for the y axis ,
the y axis is now an unkown axis , only the rotation around z axis is stll working ..

how do i solve the problem ?????

11-23-2001, 12:12 AM
OK remember that when you rotate around the x axis, the next rotate statement which will rotate on the y axis, is rotating around the origin with the effect of the rotate around x taken into consideration. So if it has rotated at 8 degrees around X, for eg., and now rotates you want it to rotate around y then it rotates around y where it's already rotated around X at 8 degrees. Understand?
From what I understand you want a static object rotating in different directions, but not moving. You can do this by using one rotate statement.
Also if you have more than one object then make sure you push and pop youre matrices on and off the stack at the correct place, and also make sure that you're rotate's aren't affecting object you don't want it to.
If I misunderstood, or did not answer youre question then please post some code so I can see. http://www.opengl.org/discussion_boards/ubb/smile.gif