Controlling Camera Position

Anonymous 9 years ago 0
This discussion was imported from CodePlex

jacobya wrote at 2012-01-23 06:00:

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.



objo wrote at 2012-01-26 20:02:

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