Jump to content
  • Advertisement

Archived

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

Lev Me

transforms

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

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!