Reset camera position using TrackballDecorator

Nov 17, 2008 at 11:08 AM
Edited Nov 17, 2008 at 11:23 AM
Hello, I'm using the TrackballDecorator for mouse movement in a viewport3D ... at some point i need to reset the camera position to the original position ...

I've tryed various methods to do that ... I managed to reset the camera position using 

this

 

.camera.Transform = new MatrixTransform3D();

But when I start moving the camera after that ... it seems that the class remembers some how the last position and continues from the last positon ... I've tryed doing something like this ... 

public void ResetPosition()
{
    this.scale = new ScaleTransform3D();
    this.previousPosition2D = new Point();
    this.rotation = new AxisAngleRotation3D();
    this.previousPosition3D = new Vector3D(0, 0, 1);
    transform.Children.Add(scale);
    transform.Children.Add(
    new RotateTransform3D(rotation));
    previousPosition3D = projectToTrackball(ActualWidth, ActualHeight, previousPosition2D);
}

A reset method ... to resest all the stuff ... in the class ... but it's not working ...

What am I mising ... any help will be apreciated ...

Thanks

 

 

 

 

 

 

 

 

 

Aug 19, 2010 at 4:15 PM
Try this: public void Reset() { this.Viewport3D.Camera.ClearValue(Camera.TransformProperty); _previousPosition3D = new Vector3D(0, 0, 1); _scale = new ScaleTransform3D(); _rotation = new AxisAngleRotation3D(); _transform = new Transform3DGroup(); _transform.Children.Add(_scale); _transform.Children.Add(new RotateTransform3D(_rotation)); }