Original Post
I am having troubles with moving my camera. I have a position vector(x,y,z), a pitch value, a yaw value and a local move vector(_x,_y,_z) I understand that to get the cameras new position, I need to translate back to the origin, rotate the local vector,then translate back to the start, and add the local move vector to the position vector. The current code I have for this is; where COS() and SIN() are inline functions that convert cmath's cos() and sin() functions to degrees. However, when my program runs, although camera tilt and pan from the mouse works perfectly, the movement fails. Could someone correct me, and provide an explanation? Many thanks
glRotatef(yaw,0.0f,1.0f,0.0f);
glRotatef(pitch,1.0f,0.0f,0.0f);
x += _x*COS(yaw) - _z*SIN(yaw);
z += _x*SIN(yaw) + _z*COS(yaw);
glTranslatef(x*0.001f,y*0.001f,-5.0f+z*0.001f);