how to control two cameras on the same center
i m trying to use firstPersonCamera and thirdPersonCamera or targatPositionCamera but i cant set them to the same center as position (x,y,z) .
i use firstPersonCamera's events . but after then if i use the other camera's events it doesnt work correctly.I want the new event to work on firstPersonCamera's position.but i can't.Is there any way to control both camera in the same coordinates?
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
(07-18-2011, 12:50 PM)yunus Wrote: thank you for suggestions. That works.
I fixed my problem.
I was trying to use 2 two different cameras to control my objects.
but i wasnt able to control both cameras at t he same time. That means i want both camera to look at the same direction and both should be
at the same position. I couldnt do it. now i tried ur suggestions
and they works.
Thanks a lot...

Forum Jump:

Users browsing this thread:
1 Guest(s)