Sign in to follow this  

rotations problem

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

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