Advertisement Jump to content
Sign in to follow this  
phil67rpg

rotating space ship

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

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.

Share this post


Link to post
Share on other sites
Advertisement
What did you try? If that didn't work, try reversing the order of the rotation and the translation.

Share this post


Link to post
Share on other sites

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?

Edited by dejaime

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

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!