Controlling Camera Position

Jan 23, 2012 at 5:00 AM

Hi objo,

I have a question regarding controlling the camera position and the direction the camera is looking.  What I'm essentially trying to do is to move the camera to a specific position (i.e. new Point3D(0, 100, 100)) and have the camera look at position 0, 0, 0.  The code I am using is this:

Viewport.CameraController.CameraPosition = new Point3D

(0, 100, 100);

Viewport.LookAt(new Point3D

(0, 0, 0), 1500);

This doesn't seem to have the expected behavior.  After I move the camera around in the Viewport and change the Rotation etc..., executing the following code seems to move the camera and then puts it back where it was before the code was executed.  Any idea what I'm doing wrong?  I noticed there is a LookAt overload that takes a Vector3D as the second argument, but I'm not sure what should be passed here.

Thanks,

Jason

Coordinator
Jan 26, 2012 at 7:02 PM

hi Jason, the LookAt method you are using should keep the LookDirection unchanged and is changing the Position of the camera. There is an overload that also takes a LookDirection as an argument:

public static void LookAt(ProjectionCamera camera, Point3D target, Vector3D newLookDirection, double animationTime)

Also note that it should be possible to write

Viewport.Camera.Position = new Point3D(0,100,100);

(not using CameraController).