Jump to content
  • Advertisement
Sign in to follow this  
jared168

Rotation along a defined axis

This topic is 4879 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 would like to rotate a 2d object through the center, but I don't want to put 0,0 in the center and change my points to fit around that. So, Is there a way to change the location of the axis that this object rotates along? Thanks, Jared

Share this post


Link to post
Share on other sites
Advertisement
Use glTranslate, translate the object in the center, rotate, and then retranslate it... like this
glTranslate(center)
glRotate()
glTranslate(-center)

Share this post


Link to post
Share on other sites
Maybe I didn't make myself too clear...

My current object is rotating around point (0,0) on the object. I need to rotate it around the point (1260,1194).

Picture a rectangle rotating on the lower-left corner. I want it to rotate on the center of the rectangle.


Any easy ways?


Share this post


Link to post
Share on other sites
Quote:
Original post by jared168
Any easy ways?
BladeWise and Eitsch just told you how.

The problem is that the origin (which is what glRotate always rotates around) is at the corner of the sprite. You need to translate it to the center, then rotate, and translate it back.

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!