Ah, the wonders of a few cout commands and taking it one transform at a time.
The order of transforms for setting the camera position is this:
glRotatef(Camera->theta,1,0,0);
glRotatef(Camera->phi,0,1,0);
glTranslatef(Camera->pos.x, -Camera->pos.y, Camera->pos.z);
And the order of transforms for adding an object in front of the camera is this:
glTranslatef(-Camera->pos.x, Camera->pos.y, -Camera->pos.z);
glRotatef(-Camera->phi,0,1,0);
glRotatef(-Camera->theta,1,0,0);
So it's essentially an inverse matrix.
Now I have to figure out why on earth my mouse is seemingly warping at specific instances, causing the object location (and camera) to move drastically. Eesh.
No comments:
Post a Comment