I'm want to make the camera move forward depending on its x and y rotation.
What I have more or less works, it's just not moving in a perfectly straight line:
const double PI180 = 3.14159265 / 180;
double movex, movey, movez, hs;
double yRad, xRad;
yRad = rotation.y * PI180;
xRad = rotation.x * PI180;
movex = sin( yRad );
movey = sin( xRad );
movez = -cos( yRad );
// Adjust horizontal speed
hs = movey / 1;
if ( hs < 0 ) hs *= -1;
hs = 1 - hs;
hs = hs * speed;
position.x += movex * hs;
position.y -= movey * speed;
position.z += movez * hs;
I adjust the horizontal speed depending on how steep the camera is looking e.g. looking straight down or up means that the camera doesn't move on either x or z axis.
There's probably a better way of doing this that I'm being slow about but in theory my way should work fine, I'm having trouble understanding why the camera moves down faster than it should.
Hopefully I've not been too confusing. If you know a better way of calculating the forward movement using the x, y and z rotations please let me know, it's been annoying me for ages.
Thanks in advance, Dan.