Archived

This topic is now archived and is closed to further replies.

Lev Me

transforms

Recommended Posts

Lev Me    122
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.

Share this post


Link to post
Share on other sites
python_regious    929
You could just do this:

for( each object in scene )
{
glPushMatrix()
Transform
Draw
glPopMatrix()
}


That will be pretty slow though, because you will be pushing a matrix onto the stack for each object. A better way would be to find out the reletive positions of each of the objects, so that instead of having the position vector of object2 from the origin, you have it from object1. This would mean that you won''t need to use Push/Pop matrix calls. It''s a bit harder though :p

Share this post


Link to post
Share on other sites