Jump to content
• ### What is your GameDev Story?

• Advertisement

# OpenGL How to rotate using Pivot point?

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

##### 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

##### Share on other sites
Quote:
 Original post by ph33rHey,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

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 15
• 14
• 46
• 22
• 27
• Advertisement
• ### Forum Statistics

• Total Topics
634047
• Total Posts
3015232
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!