Rotating - hmmm Tricky

Started by
2 comments, last by Solias 19 years, 4 months ago
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.
Advertisement
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.
If at first you don't succeed, redefine success.
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
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.

This topic is closed to new replies.

Advertisement