Archived

This topic is now archived and is closed to further replies.

NemoButt

Rotation problem

Recommended Posts

Hi I''m using the mouse to rotate my model around the x and y axis with the following codes: glRotatef(manualRotateY, 0.0f, 1.0f, 0.0f); glRotatef(-manualRotateX, 1.0f, 0.0f, 0.0f); However, after the model is rotated 180 degrees around the y-axis such that the screen is showing the back of the model, rotation around the x-axis is in the opposite direction from when the model is initially at 0 degree. What should I do to make sure they are of the same direction?

Share this post


Link to post
Share on other sites
You can do something like
manualRotateY%=360;
if(manualRotateY>=90 && manualRotateY<=270)
{
glRotatef(manualRotateX, 1.0f, 0.0f, 0.0f);
}
else
{
glRotatef(-manualRotateX, 1.0f, 0.0f, 0.0f);
}

Something along those lines should work. You may have to play around with the parameters.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have tried this code but if I rotate the model around the x-axis by 30 degrees, then rotate around the y-axis, once the model rotate more than 90 degrees around the y-axis, the screen will display the model such that it has been rotated around the x-axis by negative 30 degrees, even though I did not use the mouse to rotate around the x-axis.

May I know how to solve this?

Share this post


Link to post
Share on other sites