Jump to content
  • Advertisement
Sign in to follow this  
ic0de

OpenGL Proper rotation in opengl

This topic is 2557 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've been writing a little OpenGL app for a while and up until I started implementing physics glRotatef(); has been OK, now I need to modify the position of an objects vertices based on the amount it needs to rotate, I figured out how to translate objects pretty quickly, I just draw all the vertices at their new position. Now I need to know how to rotate the objects. Say I have a cube and I want to rotate it, how do I calculate the new position of each vertex based on a given angle of rotation?

Share this post


Link to post
Share on other sites
Advertisement

I've been writing a little OpenGL app for a while and up until I started implementing physics glRotatef(); has been OK, now I need to modify the position of an objects vertices based on the amount it needs to rotate, I figured out how to translate objects pretty quickly, I just draw all the vertices at their new position. Now I need to know how to rotate the objects. Say I have a cube and I want to rotate it, how do I calculate the new position of each vertex based on a given angle of rotation?


Use a matrix and just multiply the vertices with the matrix. (Then you can use glMultMatrix instead of glRotate to use the same one for rendering)

(You could also stick with glRotate and grab the matrix from OpenGL using glGetfoatv but that will be slower)

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.

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!