Jump to content
  • Advertisement
Sign in to follow this  
mouser58907

I don't understand rotation.

This topic is 2973 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 have a quad with a texture on it, representing a ship. I can rotate the camera to make the ship rotate, but it always rotates around 0,0. Am I supposed to rotate each vertex around the ship's position? What is the correct way to do this?

Share this post


Link to post
Share on other sites
Advertisement
What exactly are you trying to do?

Remember that order matters when calling glRotate and glTranslate, since matrix multiplication is not commutative (I*A*B does usually not yield the same result as I*B*A).

For example, provided that the current matrix is GL_MODELVIEW

glRotatef(90,0,1,0);
glTranslate(5,5,5);

will first rotate the ship 90 degrees around <0,0,0> using the y-axis <0,1,0> and then move it to location <5,5,5>, while

glTranslate(5,5,5);
glRotatef(90,0,1,0);

will first move the object to location <5,5,5> and then rotate it around <0,0,0>. More specifically, by using the first order the ship will end up at location <5,5,5> while it will end up at location <5,5,-5> using the second one.

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!