I'd like to program a virtual camera.
Now before you jump right on it, let me say that I want to avoid using camera(), beginCamera(), or the OCD camera lib. All of which are wonderful, but I can't use them since I have no control of the internal matrix stacking.
So my question is: how does one write a camera routine?
I want what basically is a (6dof?) camera system used in the most basic FPS games (think Quake). I want to do this with good ol push pop matrix, translate, and rotate.
The problem I'm running into is what order to rotate/translate. As of now:
Code:
translate(cameraSourceX, cameraSourceY, cameraSourceZ);
rotateX(cameraRX);
rotateY(cameraRY);
This isn't correct, since the rotation axis will always be at the center of the world (0,0,0) and the scene becomes basically a "model on a turntable". I want the rotation axis on the viewer (from your head).
So I tried:
Code:
rotateX(cameraRX);
rotateY(cameraRY);
translate(cameraSourceX, cameraSourceY, cameraSourceZ);
Which is also incorrect. The rotation is now locked onto the viewer's head, but the translate is locked into the world's XYZ axis.
I know there's a particular order in which to do this (and also an additional step to reverse a translation) but I can't, for the life of me, seem to find this through google or NeHe.
Help. Please!
OOPS I just realized this should be in the 3D forum. Please move this, thanks!