I am trying to implement a 3rd-person camera. I figured out the position of an object that acts as a camera to another object using polar coordinates. Now from a view just looking down the z axis at 0,0,0 if I draw both the object being followed and the object representing the camera it appears that the camera is at the right position and angle to be a camera for the other object. So I'm pretty sure that calculating the position of everything isn't the problem So I have these variables: For the object I want to be looking at: xpos, zpos, yrot. For the camera: camerax, cameraz and cameradist. I'm pretty sure the y-axis rotation should be the same for each. So let's say I want to use these to make a 3rd person camera. I thought this would work (it didn't):
//already cleared the buffers and loaded an identity matrix
//Draw the main object, directly in front of the camera
glTranslatef(0.0f, 0.0f, -cameradist);
//Draw the scenery
glTranslatef(-camerax, 0.0f, -cameraz);
glRotatef(yrot, 0.0f, 1.0f, 0.0f);
Please let me know if you know the right way to display everything!
Edited by - atcdevil on August 27, 2001 10:18:56 PM
Thanks for the advice. The problem is that, I do not fully understand how to use gluLookAt. I know this much: gluLookAt(camerax, 0.0f, cameraz, ?, 0.0f, ?, 0.0f, 1.0f, 0.0f); What would I put in those two ?''s.