Jump to content
  • Advertisement

Archived

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

gowron67

camera look at

This topic is 5639 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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);

matrix4X4(x_axis.x,x_axis.y,x_axis.z,0,
y_axis.x,y_axis.y,y_axis.z,0,
z_axis.x,z_axis.y,z_axis.z,0,
0.0,0.0,0.0,1.0);


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!