This project is read-only.

Question for Camera3D.LookAt Method

Jul 9, 2010 at 9:26 AM

hi all.

   I read code for tutorials 02.  I found below codes.

Camera3D camera = new Camera3D();

   //look at the sphere, which will be at 0,0,0. Look from 0,0,4
   camera.LookAt(Vector3.Zero, new Vector3(0, 0, 4), Vector3.UnitY);

I search API for XEN.  below

public void LookAt(
	Vector3 lookAtTarget,
	Vector3 cameraPosition,
	Vector3 upVector


Type: Vector3
Type: Vector3
Type: Vector3
My questions : What is means for upVector? Thanks for your help.


Jul 10, 2010 at 2:23 AM
Edited Jul 10, 2010 at 2:24 AM


When you set the camera to look at an object (ie, look at A, from B) then all you have is two positions - which forms a straight line.
The code cannot know how the camera should be rotated around that line.

The concept of an 'up vector' is the direction you want to 'up' to be for the camera.
Ie, for a first person game, you may have the positive Z axis as 'up' (ie, if the character jumps, they jump upwards on the +Z axis). The camera needs to know this direction in order to figure out a sensible rotation around the lookat line.

Does that make sense?
Sorry the docs aren't very descriptive.

Jul 12, 2010 at 4:14 AM

Thank you very much for your help ..  : )