How to move forward - again

glTranslatef(x,y,z);
glRotatef(ax,1,0,0);
glRotatef(ay,0,1,0);
glRotatef(az,0,0,1);

How to calculate the correct x,y,z to make me move forward,backward,right and left?

Depends on the size of your world and unit that you are using.

let’s use Z as our forward axis.

if( Object.forward == TRUE )z++; // The number we give to Z is based on our world size.
You may want to play around to see what value gives you the smoothes movement.
The same goes with turning right of left, start with 1 and go from there.

What each variable does, at least in a first person shooter…

Z axis is our forward and backward movement.
X axis would be strafe right of left(side step).
Y axis is our up/down movement.

ax look to the right or left and direction of travel on the x plane.
ay is look up/down
az … rotating your whole body… 180 would be your standing on your head.

Originally posted by MyNameIsJohnny:
[b]glTranslatef(x,y,z);
glRotatef(ax,1,0,0);
glRotatef(ay,0,1,0);
glRotatef(az,0,0,1);

How to calculate the correct x,y,z to make me move forward,backward,right and left?[/b]

But the question is, when I rotate the camera, Z its not my front anymore…

use sin and cos, i’d give more info but I have too much of a headache to think

You have two planes.

One is your worlds XYZ plane.
Two is your person’s XYZ.

Z is always your front, thought your not facing the worlds Z. Just like if you are walking north or south, ether direction you are still moving forward.

Remember in openGL your camara can not move, what happens is you move your world around it.

Originally posted by MyNameIsJohnny:
But the question is, when I rotate the camera, Z its not my front anymore…

nexusone.

I undestand what your are saying. But please, I know that you understood my problem. Its just a liltle trigonometry formula… help me

Maybe later I will feel like finding some code to post… kind of late here.

but it has to do with sin/cos to find movement along a angle vector.

Originally posted by MyNameIsJohnny:
[b]nexusone.

I undestand what your are saying. But please, I know that you understood my problem. Its just a liltle trigonometry formula… help me [/b]

Back to the subject of movement…

xa = cos(angle); Where angle is direction of movement.
ya = sin(angle);

player.x = player.x + xa * rate;rate is => 1, the higher the number the faster the movement.
player.y = player.x + ya * rate;

// In your drawing routine something like this.

glTranslatef(player.x, player.y, 0); move player the correct position.
glRotatef(angle, 0,0,1); rotate player to correct direction.
draw_player.

note this is sample code not everything needed is presented here.

player.x and player.y keep track of player current location.