PDA

View Full Version : glTranslatef



nick2price
12-25-2008, 02:32 PM
I am being killed, by this, been working on it for a long time and still cant figure it out. I draw my car like so

if((frame>=0) &amp;&amp; (frame<300)) // Scene 1.
{
glPushMatrix();
glScalef(0.1,0.1,0.1);
glTranslatef(0.0,0.0,x);
glTranslatef(0.0,-100.0,0.0);
glTranslatef(-100.0,0.0,0.0);
glRotatef(270.0f,1.0f,0.0f,0.0f);
aSkyBox.draw_car();

glPopMatrix();
}

Now this makes the car drive toward me when looking at the screen, so the car is face on to me. I cannot figure out for the life of it how to get the car side on, so it looks like it is driving across the screen. Any advise?
cheers

tkunert
01-11-2009, 11:56 PM
To let the car move across the screen, the first glTranslate command need to be changed. For horizontal movement just use glTranslatef(x, 0.0, 0.0).

If you are facing the wrong side of the car, the arguments of the glRotatef command are either wrong or not sufficient. Maybe you have to add a further glRotatef command. I would guess that it helps to insert this glRotatef command before the existing one

glRotatef(90.0f, 0.0f, 1.0f, 0.0f);