ELIMT
12-04-2001, 12:21 AM
How can I rotate a 3-D object drawn at ORIGIN
to rotate along an axis parallel to either the x or y or z axis with respect to previous rotation.
I used
glRotatef(angle_x, 1.0, 0.0, 0.0);
glRotatef(angle_y, 0.0, 1.0, 0.0);
glRotatef(angle_z, 0.0, 0.0, 1.0);
drawObject();
Where each angle is updated by clicking the mouse(using the mouse call-back function)
But what I get is something very strange.
For example when I click to rotate 20 degrees on the x-axis it is fine, but when I click to rotate 30 degrees on the z-axis, then 30 degrees on the y-axis etc. Everything seems to go wrong.
All I want is to rotate the current object
position by a degree about an axis which passes through the current object position and which is parallel to the axis(depending on which angle is being updated).
Please help me,much appreciated Thank You.
to rotate along an axis parallel to either the x or y or z axis with respect to previous rotation.
I used
glRotatef(angle_x, 1.0, 0.0, 0.0);
glRotatef(angle_y, 0.0, 1.0, 0.0);
glRotatef(angle_z, 0.0, 0.0, 1.0);
drawObject();
Where each angle is updated by clicking the mouse(using the mouse call-back function)
But what I get is something very strange.
For example when I click to rotate 20 degrees on the x-axis it is fine, but when I click to rotate 30 degrees on the z-axis, then 30 degrees on the y-axis etc. Everything seems to go wrong.
All I want is to rotate the current object
position by a degree about an axis which passes through the current object position and which is parallel to the axis(depending on which angle is being updated).
Please help me,much appreciated Thank You.