Original Post
I know there are lots of threads about this subjects, but the all didn't help. The camera should move with this code: And this part not to be forgotten: What is wrong with this code..? The camera moves, but only in the direction i don't want :)
void Bcamera::MoveLeft(Bfloat angle) {
rotation.angle -= angle;
if (rotation.angle < 0) rotation.angle += 360.0f;
}
void Bcamera::MoveRight(Bfloat angle) {
rotation.angle += angle;
if (rotation.angle > 359.0f) rotation.angle -= 360.0f;
}
void Bcamera::MoveForward(Bfloat speed) {
position.x -= (float) sin(rotation.angle * 0.017453292519943295769236907684886f) * speed;
position.z -= (float) cos(rotation.angle * 0.017453292519943295769236907684886f) * speed;
// that long number (0.01743 etc.) is PI / 180
}
void Bcamera::MoveBackward(Bfloat speed) {
position.x += (float) sin(rotation.angle * 0.017453292519943295769236907684886f) * speed;
position.z += (float) cos(rotation.angle * 0.017453292519943295769236907684886f) * speed;
}
// current matrix mode is GL_MODELVIEW
glRotatef(current_cam->rotation.angle, current_cam->rotation.x, current_cam->rotation.y, current_cam->rotation.z);
glTranslatef(-current_cam->position.x, -current_cam->position.y, -current_cam->position.z);