#### Archived

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

# 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.

## 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 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);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 on other sites
thanks..but what does focus refer to here ??

##### Share on other sites
focus is the point being looked-at. eye is the camera location.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
Rutin
30
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632961
• Total Posts
3009494
• ### Who's Online (See full list)

There are no registered users currently online

×