Jump to content
  • Advertisement
Sign in to follow this  
GenPFault

Panning and rotation...

This topic is 4057 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

I'm trying to make a simple model viewer that does mouse panning and rotation. I got panning and rotation to work in isolation, but I can't seem to combine them in the way I'd like. Here's what I'd like to happen: Panning around changes the 'center' of the model. Any further rotations will be about this new center point. What I got right now is like this: glTranslatef(0.0f, 0.0f, -10.0f); // move away from the model a bit glTranslatef(xoffset, -yoffset, 0.0f); // pan DoRotation(); Render(); This results in correct panning, but the rotation is still centered about the model's origin. Swapping the pan translation and DoRotation() works for the first pan, but subsequent rotations mess up the panning.

Share this post


Link to post
Share on other sites
Advertisement
To rotate about the center of your model, you must first apply the rotation matrix, then translation. Any subsequent call to glRotation will again rotate about the origin, so what you have to do is keep the global (cumulated) translation and rotation in some variables of your app, and each time call

glLoadIdentity
rotate
translate

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!