how to control two cameras on the same center
I am not sure that I fully understand your questions.

I am wondering how do you want to use two cameras - do you have two Viewport3D controls each with its own camera?

Anyway if you would like to change the camera from FirstPersonCamera to TargatPositionCamera you can calculate the TargetPosition with the following:

targatPositionCamera.TargetPosition = FirstPersonCamera.Position + FirstPersonCamera.CurrentCamera.LookDirection;

The CurrentCamera property is the WPF's PerspectivCamera. If it is controlled by the FirstPersonCamera (or any other camera), than the LookDirection vector is not normalized - this way it besides direction it also stores the distance.

You could also use:
targatPositionCamera.TargetPosition = FirstPersonCamera.CurrentCamera.Position + FirstPersonCamera.CurrentCamera.LookDirection;

Note that you cannot set the TargetPosition for the ThirdPersonCamera, because that camera uses the CenterObject property - it is looking at the center of the specified CenterObject.

You can also use the CurrentCamera property to go from the TargatPositionCamera or ThirdPersonCamera to FirstPersonCamera:
FirstPersonCamera.Position = targatPositionCamera .CurrentCamera.Position;

Note that currently the CurrentCamera is always PerspectiveCamera. But this will change in the future because OrthographicCamera will be also supported. Therefore the CurrentCamera will return the basic Camera objects and you will have to make an explicit cast to PerspectiveCamera - for example:
targatPositionCamera.TargetPosition = FirstPersonCamera.Position + ((PerspectiveCamera)FirstPersonCamera.CurrentCamera).LookDirection;

This will make your code more future proof.

I do not understand your question regarding the events. Could you be more specific please.
Andrej Benedik

Messages In This Thread
RE: how to control two cameras on the same center - by abenedik - 07-18-2011, 08:37 AM

Forum Jump:

Users browsing this thread:
1 Guest(s)