I'm working on a test project to learn some basic OpenGL. Right now I'm trying to work on a "camera" with gluLookAt. My camera object is really simple, I have two vectors, one for the position and the other for the rotation (x, y and z on both). I'm having trouble with the target point gluLookAt receives, how can I find a target point using only the position and camera angle?
Answer
If you have desired rotation angles for your camera, then gluLookAt
is not really the appropriate function to use. Instead, use glRotate
three times, once for each axis of rotation (typically in roll, pitch, yaw order) using the negative of the desired camera angle on each axis, then glTranslate
with the negative of the camera position.
(Why the negatives? Because you're constructing a matrix to go from world space to camera space, so everything's opposite to the transformations that go from camera space to world space.)
No comments:
Post a Comment