rotating space ship

Started by
29 comments, last by unbird 10 years, 1 month ago

well I am going back to opengl.I am working on an asteroids game.it has been a long time since I have posted. I really like opengl.my question is how do I get a space ship rendered using line loop and vertices rotate around its center relative to where its drawn. I know I have asked this question before but I never solved this problem. I know I should use glRotate and glTranslate commands in the correct order.

Advertisement
What did you try? If that didn't work, try reversing the order of the rotation and the translation.

What did you try? If that didn't work, try reversing the order of the rotation and the translation.

Take a look here. Looks like it is still an unsolved problem...

phil, what's your native language?

I have tried reversing the order of the rotation and translate commands.

I am using c++ and opengl

First, you have to translate your object so its center is at the origin. Then you rotate your object, and then you translate your object to its final destination.

First, you have to translate your object so its center is at the origin. Then you rotate your object, and then you translate your object to its final destination.


Yes, but objects typically start centered around the origin (a.k.a. "model space" or "model coordinates") and then they get put in the world through a transformation that consists of a rotation and a translation. I don't know why that basic method won't work for him.

First, you have to translate your object so its center is at the origin. Then you rotate your object, and then you translate your object to its final destination.

That only works if you look at things from a "world view". Rotating (with glRotate) changes the local coordinate system of the object and the translation will move along the local coordinate system axes (just like rotation always happens around the current origin, aka. the objects position).

So the order in OpenGL (assuming the object is modeled around the origin) is glTranslate into position and then glRotate.

At least "thinking local" would seem a lot more intuitive than saying "OpenGL is doing everything backwards for some reason".

Of course those functions are technically deprecated and once handling matrices yourself it all boils down to multiplication order.

f@dzhttp://festini.device-zero.de

should I repost my code?

Please, do post an updated version of it.

Can you do a small test?

What happens if you only rotate, and remove the translate?

What happens if you only translate?

This topic is closed to new replies.

Advertisement