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?
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.)
The position passed to
gluLookAt() is relative to the origin. Since you have one point relative to another point, then get that point relative to the origin by subtracting the second point from it, i.e.
V1 - V2 = (v1.x-v2.x,v1.y-v2.y,v1.z-v2.z)
And pass the result to
glTranslate() to "move" the camera to its position vector.