Sign in to follow this  

Rotating - hmmm Tricky

This topic is 4759 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 its tricky for me anyhow. Basically the problem i am having at the moment is making my objects rotate independently rather than around the screens centre point. What i am aiming for is the object to rotate about 'on the spot' where it is generated - this way means that once i have generated a number of objects using my random function they don't then all rotate around (0,0) of the window co-ords. I am using display lists to call the code and at the moment it is only my translations that are grouped in with the drawing of the object - do i need to put the rotate in here as well to make it rotate on the spot. Cheers in advance and if you need any more info about the problem don't hesitate to ask as i will check everyday.

Share this post


Link to post
Share on other sites
You can group your rotations into the display lists if you like. Personally, I'd take all the transformations out of the display list. You need to swap the order in which you translate and rotate to get your object to rotate on the spot.

Share this post


Link to post
Share on other sites
I have had that but that was causing muchos problems with zooming etc.

In practice if i wanted them to rotate on their own how would i do it rotate then translate or translate then rotate?

Currently i have something like this

glPopMatrix();
CallList();
glRotatef(angle, 0.0, 1.0, 0.0);
glPushMatrix();

I'm using a timer func which adds to the angle number every 10th of a second. Can i define this in the display list and use it in their?

Cheers Neil

Share this post


Link to post
Share on other sites
Quote:
Original post by neilski_2003
I have had that but that was causing muchos problems with zooming etc.

In practice if i wanted them to rotate on their own how would i do it rotate then translate or translate then rotate?


Transformations in opengl are applied to geometry in the reverse order that they are added to the modelview matrix.

So this:

glTranslate()
glRotate()

will cause an object to be rotated around it's local origin and then translated.

This order is useful because it allows you to define a common view transform first and have it applied after the local transforms for each object.

Quote:

Currently i have something like this

glPopMatrix();
CallList();
glRotatef(angle, 0.0, 1.0, 0.0);
glPushMatrix();

I'm using a timer func which adds to the angle number every 10th of a second. Can i define this in the display list and use it in their?

Cheers Neil


I wouldn't really recomend using display lists for transformations. (Although the red book does actually mention glRotate() as an example of something to put into one.) In any event display lists are only useful for static data. If you are animating the rotation you would need to recreate the display list every time it changes.

Share this post


Link to post
Share on other sites

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