Skip to main content
gamedev.net
🔒 Locked

transforms

Started by Lev Me Dec 18, 2001 at 7:08 AM 0 replies 250+ views
Original Post
Lev Me
Lev Me
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.
lev
python_regious
python_regious
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
If at first you don't succeed, redefine success.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.