AB4D Forum

Full Version: Camera Controller Animation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If I animate a scene camera's distance property it causes the mouse wheel to no longer function.

DoubleAnimation daDistance = new DoubleAnimation();
daDistance.From = sceneCamera.Distance;
daDistance.To = ZoomDistance;
daDistance.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(2.0))

sceneCamera.BeginAnimation(Ab3d.Cameras.SceneCamera.DistanceProperty, daDistance, HandoffBehavior.Compose);

I have a MouseCameraController tied to the same viewport. After the animation is over I can no longer use the mouse wheel to zoom in and out, yet the rotate still works.

Any ideas?
I think you should set the FillBehavior to Stop.

daDistance.FillBehavior = System.Windows.Media.Animation.FillBehavior.Stop;

By default it is set to HoldEnd that prevents any other changes.


(10-26-2009, 09:51 PM)richardpruitt96 Wrote: [ -> ]If I animate a scene camera's distance property it causes the mouse wheel to no longer function.

DoubleAnimation daDistance = new DoubleAnimation();
daDistance.From = sceneCamera.Distance;
daDistance.To = ZoomDistance;
daDistance.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(2.0))

sceneCamera.BeginAnimation(Ab3d.Cameras.SceneCamera.DistanceProperty, daDistance, HandoffBehavior.Compose);

I have a MouseCameraController tied to the same viewport. After the animation is over I can no longer use the mouse wheel to zoom in and out, yet the rotate still works.

Any ideas?
Having issues with adding the pan capability on my own with the 3d math.

To pan (i.e. sidestepping/strafe) I assume I have to move both the camera location and the camera target position in the direction of the mouse movement. While, to change look direction (i.e. turn my head) I only change target position in direction of mouse movement.

Any clues on how I might do this? Thanks.
Panning is very easy to implement with Ab3d.Cameras.FirstPersonCamera.

There are already methods to do this:
MoveLeft and MoveRight methods actually pan the camera left and right.

There are other useful methods:
MoveBackward, MoveForward, MoveUp and MoveDown.

Those methods are used to move the camera around.
To rotate the camera you can simply change the Heading property on the FirstPersonCamera.
I really need the combination of both a first person movement (pan) and a Scene Camera together. I am trying to inspect objects in 3D (scenecamera style) then be able to move from object to object (firstpersoncamera style).

* Also, If I set a property on a PerspectiveCamera while it is tied to a MouseCameraController then I go back to using the mouse the scene jumps back to where it was before I updated the PerspectiveCamera. It is as if the Ab3d.Cameras don't recognize a change that I make directly to the PerspectiveCamera. Is there some sort of Ab3d.Camera Refresh I have to call?

Thanks again for the great support.
It's almost like what I need is a FirstPersonCamera Navigation with Left Mouse button and SceneCamera Navigation with the right mouse button.

I can mimic this by just changing my MouseCameraController.TargetCamera, but the issue is that the FirstPersonCamera and the SceneCamera perspective cameras are not synched. So when you switch TargetCamera's you are back at the last position of that camera.

Thanks.
First I need to say that while the PerspectiveCamera is being controlled by the Ab3d.Camera, you should not change the PerspectiveCamera directly. Because the PerspectiveCamera does not have a Changed event, the Ab3d.Camera is not aware of the change.

Quote:I really need the combination of both a first person movement (pan) and a Scene Camera together. I am trying to inspect objects in 3D (scenecamera style) then be able to move from object to object (firstpersoncamera style).

This request lead to redesigning the cameras for the release candidate.
Now you also have the MoveLeft, MoveUp, etc. methods available on TargetPositionCamera.

This way you can use the TargetPositionCamera for inspecting each 3D object (just set the TargetPosition property to center of the 3D object's Bounds) or for inspecting the whole scene (set the TargetPosition property to center of the 3D Bounds of the root Model3DGroup or Visual3D).

You can also animate the TargetPosition from one object to another with WPF's Point3DAnimation.

When you have set the TargetPosition you can rotate the camera around the object with changing Heading and Attitude (or by MouseCameraController or CameraControlPanel). You can also strafe the camera left and right by calling MoveLeft or MoveRight methods. You can also use MoveUp, MoveDown, MoveBackward and MoveForeward.

I hope this will suite your needs.
Hi

I'm also having issues with this.

I TwoWay bind the scene cameras heading property to my viewmodel.

I the have a 'reset view' function which animates thing back to a default view.

Code:
// reset heading
                DoubleAnimation daHeading = new DoubleAnimation();
                daHeading.From = App.ViewModel.ProjectMissionVM.ActiveProjectMission.SceneCameraHeading;
                daHeading.To = 0;
                daHeading.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(1000));
                daHeading.FillBehavior = System.Windows.Media.Animation.FillBehavior.HoldEnd;
                SceneCamera.BeginAnimation(Ab3d.Cameras.SceneCamera.HeadingProperty, daHeading, HandoffBehavior.Compose);

The animation works fine, but the MouseCameraController I have no longer works!! So I can't move the scene anymore with the mouse.

There must be a simple explanation but I cant figure it out.

I have tried to rebind the Heading property to my viewmodel in code but that did not work.

It is the MouseCameraController that needs rebinding??

Thanks in advance.. Jason.
The problem is that WPF animation locks the property value even after the animation is completed. To prevent that you need to change the animation's FillBehavior from HoldEnd to Stop.

You can also try any of the steps described here: https://msdn.microsoft.com/en-us/library....110).aspx
(06-01-2015, 07:55 AM)abenedik Wrote: [ -> ]The problem is that WPF animation locks the property value even after the animation is completed. To prevent that you need to change the animation's FillBehavior from HoldEnd to Stop.

You can also try any of the steps described here: https://msdn.microsoft.com/en-us/library....110).aspx

Thanks Andrej

The .Stop did not work, but removing the animation from the property on completion does!