Jump to content
  • Advertisement
Sign in to follow this  
andr0cles

rotations problem

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

Hi, I am making a game where I have several objects and I need each one to rotate around its own center of rotation. Is there a way of setting independent coordinate systems for each object (other than using glPushMatrix() / glPopMatrix) 'cos this seems a bit computationally intensive when there a quite a few objects?

Share this post


Link to post
Share on other sites
Advertisement
Quote:

Is there a way of setting independent coordinate systems for each object (other than using glPushMatrix() / glPopMatrix) 'cos this seems a bit computationally intensive when there a quite a few objects?

No, using coordinate system matrices is the only way to do that. And it is not really computationally expensive, even with thousands of objects.

Share this post


Link to post
Share on other sites
sorry, what do you mean by 'coordinate system matrices'? Do you mean I have to use a separate glPushMatrix() ... glPopMatrix() block for each object I want to rotate?

Share this post


Link to post
Share on other sites
Quote:
Original post by andr0cles
sorry, what do you mean by 'coordinate system matrices'? Do you mean I have to use a separate glPushMatrix() ... glPopMatrix() block for each object I want to rotate?

Yes. You begin rendering the scene by transforming the scene according to the camera position/rotation, preferably using glMultMatrix. Then, for each object in the scene, you do the following:
glPushMatrix();
glMultMatrix(this->transformationMatrix);
//render object here
glPopMatrix();

Pushing and popping matrices is extremely cheap. Multiplying matrices is also pretty cheap and unavoidable. The alternative to pushing and popping is to construct rotation matrices for each object that are dependent on the rotation matrix of the previously rendered object, which is completely irrational for most applications.

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!