PDA

View Full Version : transforms



12-19-2001, 06:13 AM
The problem:
Each time I press some keybord button I want all the objects
in the 2D scene to rotate around it's center in 10 degrees.
(I know the data about the objects so I have to do it in 'for'
loop)
How can I do it using only glTranslate(),glRotate()
and without matrix staff ??
example:

for(all objects in the scene)
{
glTranslatef(midpoint_x,midpoint_y,0.0);
glRotatef(10,0.0,0.0,1.0);
glTranslatef(-midpoint_x,-midpoint_y,0.0);
draw_object(i);
}

The problem is that the midpoint data is not the same for the objects
ans there is only one MODELVIEW matrix.
Using push/pop ?? how??


Thank you.

Rob The Bloke
12-19-2001, 06:44 AM
for(all objects in the scene)
{
glPushMatrix();
glTranslatef(midpoint_x,midpoint_y,0.0);
glRotatef(10,0.0,0.0,1.0);
glTranslatef(-midpoint_x,-midpoint_y,0.0);
draw_object(i);
glPopMatrix();
}

probably need to keep track of the rotation values as you increment them to be able to get the objects to rotate fully around.