PDA

View Full Version : Translating different objects at different speeds



Hameem
04-26-2009, 12:56 PM
I want to translate three circles at three different velocities but at the same time. How do i do that? If i use the glTranslatef() funciton, it translates all the objects/circles i have dreawn.
I'm absolutely new to the openGL. Im using C.
Thank you.

Sarah22
04-26-2009, 02:06 PM
You can use glPushMatrix() then translate the first object and draw it then end it with glPopMatrix().

Hameem
04-27-2009, 02:42 AM
Could you pls give more details with a bit of codes?
Suppose drawCircle1() draws the 1st circle and drawCircle2() draws the 2nd circle. What code do i have to write to translate the 2 cirlces at different speeds/velocities?

todayman
04-29-2009, 02:49 PM
Well, each frame the circles are in some spot. You compute the spot in your code ( I don't know how you want them to move ). Then you do something like this:



glPushMatrix();
glTranslatef(x,y,z);
drawCircle1();
glPopMatrix();

glPushMatrix();
glTranslatef(x,y,z);
drawCircle2();
glPopMatrix();


In the first section, x,y and z are the location of the first circle, and the second time they are the location of the second circle. Update the screen, recompute the positions for the next frame, and repeat.