Jump to content
  • Advertisement

Archived

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

spooky2004

OpenGL re opengl rotations

This topic is 5205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi i am having real trouble trying to solve this problem I have a model loaded into a opengl window I want the user to be able to rotate the model around the current upvector by draging the mouse left/right on the window, and around the current right vector, draging the mouse updown. Imagine this, default upVector=(0,1,0). If you rotate this 90deg ccw on the yz plane your new up vector will be (0,0,-1). Once the model is in this position any left/right drag of the mouse to uspdate the rotation around the (0,1,0) axis will make it rotate around the old axis, which is now pointing in a wrong direction. At his point when i move the mouse left and right the model should rotate around (0,0,-1) which is the -z axis, not around the old y axis. How can i do this, using the glrotate command, specificly how do i find the current up vector, after the model has been rotated from the default, i cant use the default upvector, becasue that now points in a ddifferent location any help appreciated thanks

Share this post


Link to post
Share on other sites
Advertisement
If you want to know the current up vector,just do this:

vector up;
float m[16];

glGetFloatv(GL_MODELVIEW_MATRIX,m);

up.x=m[4];
up.y=m[5];
up.z=m[6];

I hope this help.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!