Jump to content
  • Advertisement
Sign in to follow this  
jamcar

OpenGL How to rotate using Pivot point?

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

Hello! I am wondering how to rotate a 3D object in a 3D world. I am using OpenGL and reading the object's Pivot point(x,y,z) from .3ds file. I should probably first translate the coordinates with some matrix math from world coordinates(that 3ds studio max uses) into object coordinates(that i'm using with openGL), or do you have some better ideas? How do I use the Pivot point and the rotation data(I succesfully read 100 keyframes for this rotation track) to rotate the object succesfully in my 3d world? thank you in advance.. Best wishes, teemu turkki

Share this post


Link to post
Share on other sites
Advertisement
Hey,

I believe what you want to do is first translate the object to the origin by the pivot point P(-x,-y,-z) then rotate the object, then translate it back to its pivot point.


// Note matrix math works from right to left.
FinalTransform = TransPiv * Rotation * TransOrigin

Share this post


Link to post
Share on other sites
Quote:
Original post by ph33r
Hey,

I believe what you want to do is first translate the object to the origin by the pivot point P(-x,-y,-z) then rotate the object, then translate it back to its pivot point.


// Note matrix math works from right to left.
FinalTransform = TransPiv * Rotation * TransOrigin


Exactly correct. To rotate about a point P, you need to perform:

V' = T(P) * R * T(-P) * V

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.

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!