Sign in to follow this  
jolyqr

LookAt Camera

Recommended Posts

jolyqr    100
Basically, I would like to create a first person camera. I know the trigonometric formulas for the rotations, but I don't know on which components of the opengl LookAt function apply them. Besides I would like my camera to move in the right direction. How could I do these operations... cheers

Share this post


Link to post
Share on other sites
jpetrie    13138
gluLookAt() does not employ trig at all.

You supply it nine parameters -- the (x,y,z) of the eye's location, the (x,y,z) of the eye's target, and the (x,y,z) of an "up" vector. The location represents the 3D point where the eye is located in world space; the target represents the location that the eye is "looking at." The last parameter is used as a temporary.

What gluLookAt() is use its parameters to build an orthonormal basis for view space and use that basis to compte a rotation matrix that it applies to the current matrix stack (usually the GL_MODELVIEW stack). The matrix will rotate and displace geometry in world space to eye space, so it appears "as the eye sees it."

Two good books covering these topics, and other related ones, are "The Geometry Toolbox," and "Essential Mathematics for Games and Interactive Applications." I strongly suggest that you purchase one or both if you can, because a solid grasp of these concepts is fundamental to 3D graphics programming.

Share this post


Link to post
Share on other sites
jpetrie    13138
Is *is* possible to move the camera using the glTranslate/glRotate et cetera functions appropriately as well. They modify the same matrix stack (if the stack is set correctly).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this