This topic is now archived and is closed to further replies.


camera look at

Recommended Posts

I''ve got a basic camera class up and running where it uses a quaternion to store it''s orientation, a 4x4 matrix is then created from this quaternion and passed to OpenGL. My question is I want to be able to give my camera class a point to look at, similar to the way gluLookAt works, but I can''t figure out what to do to the camera''s orientation quaternion to make the camera look at the specified point. Can anyone help please ?

Share this post

Link to post
Share on other sites
If you really must store the orientation as a quaternion, then just construct the rotation matrix for the lookat, then convert that back to your quaternion. (the rotation matrix is simple to construct:

z_axis = normalize( -(focus - eye) );

x_axis = normalize( cross(up,z_axis) );

y_axis = cross(z_axis,x_axis);


You''ll need to fiddle it a bit depending on your matrix system, this one here adheres to the OpenGL conventions).

Share this post

Link to post
Share on other sites