Sign in to follow this  

I don't understand rotation.

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

This topic is 2662 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this