Click or drag to resize
AB4D logo

MouseCameraController Class

MouseCameraController is a helper class that can be used to add mouse rotation and zooming to the Ab3d.Camera.
Inheritance Hierarchy
SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      System.Windows.MediaVisual
        System.WindowsUIElement
          System.WindowsFrameworkElement
            System.Windows.ControlsControl
              Ab3d.ControlsBaseControllerControl
                Ab3d.ControlsMouseCameraController

Namespace: Ab3d.Controls
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.2.9104.2045
Syntax
C#
public class MouseCameraController : BaseControllerControl

The MouseCameraController type exposes the following members.

Constructors
 NameDescription
Public methodMouseCameraController Constructor
Top
Properties
 NameDescription
Public propertyClosedHandCursor Gets a predefined cursor that shows a closed hand.
Public propertyEventsSourceElement Gets or sets the element where the mouse events are subscribed. If the property is not set, Viewport3D element on the TargetCamera is used as event source.
Public propertyEventsSourceElementName Gets or sets the name of the element where the mouse events are subscribed.
Public propertyEventsSourceElementRotationChange Gets or sets a double value that specifies for how many degrees the camera is rotates when the mouse moves from one side of the EventsSourceElement to another size. The default value is 270.
Public propertyIsAttitudeRotationEnabled Gets or sets a Boolean that specifies if attitude rotation (around x axis) is enabled. Default value is true.
Public propertyIsCameraAnimationStoppedOnUserAction Gets or sets a boolean that specifies if camera animation that is running with AnimationController is stopped if user start rotating or moving the camera with mouse or touch. If false then animation is not stopped and this prevents user from rotating or moving the camera with mouse or touch. Default value is true. This value does not have any effect on camera rotation that is started with StartRotation(Double, Double) method.
Public propertyIsConcurrentTouchZoomEnabled Gets or sets a boolean that specifies if scaling with pinch while rotating the camera with touch is enabled (requires .Net 4 version of Ab3d.PowerToys to work). Default value is true.
Public propertyIsHeadingRotationEnabled Gets or sets a Boolean that specifies if heading rotation (when changing the mouse in x direction) is enabled. Default value is true.
Public propertyIsMouseWheelZoomEnabled Gets or sets if zooming (moving camera forward and backward) by mouse wheel is enabled
Public propertyIsRotateCursorShownOnMouseOver Gets or sets a boolean that specifies if RotationCursor is shown if UsedMouseButton is set to Left and mouse is over the EventsSourceElement. Default value is true.
Public propertyIsRotationDirectionAdjusted Gets or sets Boolean that specifies if rotation direction is based on current mouse position and attitude angle. When false (by default), moving the mouse to the right always increases the heading regardless of mouse position and attitude angle. When true, the rotation direction is based on the current mouse position in the 3D scene and current attitude angle.
Public propertyIsTouchEnabled Gets a boolean that specifies if any of IsTouchRotateEnabled or IsTouchMoveEnabled or IsTouchZoomEnabled is enabled.
Public propertyIsTouchMoveEnabled Gets or sets a boolean that specifies if moving the camera with touch is enabled (requires .Net 4 version of Ab3d.PowerToys to work). Default value is false.
Public propertyIsTouchRotateEnabled Gets or sets a boolean that specifies if rotating the camera with touch is enabled (requires .Net 4 version of Ab3d.PowerToys to work). Default value is true.
Public propertyIsTouchZoomEnabled Gets or sets a boolean that specifies if zooming the camera with multi-touch pinch is enabled (requires .Net 4 version of Ab3d.PowerToys to work). Default value is true.
Public propertyIsXAxisInverted Gets or sets if x axis (heading) is inverted. Default value is false.
Public propertyIsXMovementEnabled Gets or sets a Boolean that specifies if movement the mouse in x direction is processed by this MouseCameraController. Default value is true.
Public propertyIsYAxisInverted Gets or sets if y axis (attitude) is inverted. Default value is false.
Public propertyIsYMovementEnabled Gets or sets a Boolean that specifies if movement the mouse in y direction is processed by this MouseCameraController. Default value is true.
Public propertyMaxCameraDistance Gets or sets a double value that when set to a value that is not double.NaN, than it specifies the maximum Distance of the camera or the maximum CameraWidth when OrthographicCamera is used. This property can be set to a reasonable number to prevent float imprecision when the camera distance is very big. Default value is double.NaN.
Public propertyMouseMoveThreshold Gets or sets a double value that specifies how much user needs to move the mouse before rotation, movement or quick zoom are started. Until mouse is moved for the specified amount, the MouseCameraController does not handle mouse events so they can be get for other processing (for example to handle mouse click). When 0 (by default), then rotation, movement or quick zoom are started immediately when the correct mouse buttons and keyboard modifiers are pressed (no mouse movement needed).
Public propertyMouseWheelDistanceChangeFactor Gets or sets a double value that specifies a value that used when zooming with mouse wheel. When zooming out the Camera's Distance or CameraWidth is multiplied with this value. When zooming in the Camera's Distance or CameraWidth is divided with this value. Default value is 1.05. Bigger value increases the speed of zooming with mouse wheel. The value should be bigger then 1.
Public propertyCode exampleMoveCameraConditions Gets or sets conditions from MouseAndKeyboardConditions enum that must be met to move the camera. Default value is MouseAndKeyboardConditions.RightMouseButtonPressed and MouseAndKeyboardConditions.AltKey.
Public propertyMovementCursor Gets or sets a Cursor that is used when the mouse is moving the Ab3d.Camera.
Public propertyMoveOnlyHorizontally When true he camera moving is restricted only to horizontal (XZ) plane. This means that the camera cannot be moved up and down. Default value is false that moves the camera based on the current look and up direction.
Public propertyOpenedHandCursor Gets a predefined cursor that shows an open hand.
Public propertyQuickZoomConditions Gets or sets conditions from MouseCameraControllerMouseAndKeyboardConditions enum that must be met to start quick zooming - quickly zooming in and out with moving the mouse forward and backward. Default value is MouseAndKeyboardConditions.Disabled.
Public propertyQuickZoomCursor Gets or sets a Cursor that is used when user is using quick zooming. Default value is Cursors.ScrollNS.
Public propertyQuickZoomMaxFactorScreenDistance QuickZoomZoomOutFactor is used when QuickZoomConditions are satisfied and defines the zoom out speed. The QuickZoomMaxFactorScreenDistance defines how much the mouse needs to travel in the forward or backward direction to reach the QuickZoomMaxZoomInFactor or QuickZoomZoomOutFactor. Default value is 200.
Public propertyQuickZoomMaxZoomInFactor QuickZoomMaxZoomInFactor is used when QuickZoomConditions are satisfied and defines the maximum zoom in factor. The maximum zoom in factor is reached when the user moves the mouse for the QuickZoomMaxFactorScreenDistance distance in the forward direction. If user moves the mouse farther away the zooming is not performed any more. Default value is 20 and means that the max zoom in factor is 20x - the Camera.Distance will be reduced to its 0.05 (1/20) initial value.
Public propertyQuickZoomZoomOutFactor QuickZoomZoomOutFactor is used when QuickZoomConditions are satisfied and defines the zoom out speed. The property defines the zoom out factor that is used when the mouse travels for the QuickZoomMaxFactorScreenDistance amount in the backwards mouse direction. Zoom out does not stop at this zoom factor as with zooming in (see QuickZoomMaxZoomInFactor). Default value is 10 and means that the zoom out factor is 10x - the Camera.Distance will be increased to 10 times its initial value after the mouse moves for the QuickZoomMaxFactorScreenDistance amount in the backwards mouse direction.
Public propertyRotateAroundMousePosition Gets or sets a Boolean that specifies if TargetPositionCamera or FreeCamera is rotated around a 3D position that is "behind" current mouse position. When RotateAroundMousePosition is true and user starts cameras rotation, MouseCameraController sets the TargetPositionCamera.RotationCenterPosition or FreeCamera.RotationCenterPosition property. Default value is false.
Public propertyCode exampleRotateCameraConditions Gets or sets conditions from MouseAndKeyboardConditions enum that must be met to rotate the camera. Default value is MouseAndKeyboardConditions.RightMouseButtonPressed.
Public propertyRotateCursorLeft Gets a predefined cursor that can be used while rotating the camera with the mouse.
Public propertyRotateCursorRight Gets a predefined cursor that can be used while rotating the camera with the mouse. This is the default cursor that is used by the MouseCameraController.
Public propertyRotationCenterAdorner Gets or sets a CameraTargetPositionAdorner that is used to show the position around which the camera is rotating. This adorner is shown only when ShowRotationCenterMarker is set to true. When this property is not set, a new instance of CameraTargetPositionAdorner is used.
Public propertyRotationCursor Gets or sets a Cursor that is used when the mouse is rotating the Ab3d.Camera.
Public propertyRotationEasingFunction Gets or sets a delegate that specifies the easing functions used to calculate the rotation inertia.
Public propertyRotationInertiaRatio Gets or sets a double that specifies how strong the camera rotation inertial is. When set to 0 (or negative value), camera does not have any inertia. Default value is 1. Values bigger than 1, increase the time it takes to stop the camera.
Public propertyShowQuickZoomMarker Gets or sets a Boolean that specifies if RotationCenterAdorner is shown at the position that represents the quick zoom target on the 2D screen. Default value is true.
Public propertyShowRotationCenterMarker Gets or sets a Boolean that specifies if RotationCenterAdorner is shown at the position around which the camera is rotating. If RotationCenterAdorner is not specified, a new instance of CameraTargetPositionAdorner is created and set to the RotationCenterAdorner property. Default value is false.
Public propertyUsedMouseButtonObsolete.
Gets or sets a MouseButton that specifies on which mouse button will be used to rotate and move the camera. Default value is Right mouse button. UsedMouseButton is obsolete. Please use the RotateCameraConditions and the MoveCameraConditions properties instead.
Public propertyUseMousePositionForMovementSpeed When true then the camera movement speed is determined by the distance to the 3D object behind the mouse. When no 3D object is behind the mouse or when UseMousePositionForMovementSpeed is set to false, then movement speed is determined by the distance from the camera to the TargetPosition is used. Default value is true.
Public propertyZoomMode Gets or sets a value from a MouseCameraControllerCameraZoomMode enum that specifies the location into which camera is zoomed. Note that MousePosition and CameraRotationCenterPosition work only for TargetPositionCamera and FreeCamera. Default value is Viewport3DCenter.
Top
Methods
 NameDescription
Public methodChangeCameraDistance ChangeCameraDistance method change the distance of the TargetCamera by multiplying it by the changeFactor. When RotationCenterPosition is set in the TargetPositionCamera or FreeCamera, then we zoom into the specified RotationCenterPosition (if this is not disabled by setting the zoomToRotationCenterPosition parameters to false).
Public methodStatic memberCubicEaseOut Simple cubic easing function used to decelerate the rotation: y = (x - 1) * (x - 1) * (x - 1) + 1x
Protected methodEndMouseProcessing EndMouseProcessing is called when the mouse button that started rotation or movement is released.
Protected methodGetEventsSourceElementSize GetEventsSourceElementSize returns size of EventsSourceElement. This method can be overridden to provide custom size (for example when used with SharpDX.RenderForm)
Protected methodGetIsHeadingAngleChangeInverted GetIsHeadingAngleChangeInverted returns true if mouse position is in such location that we need to invert the heading rotation direction.
Protected methodGetManipulationActions GetManipulationActions method gets the ManipulationDeltaEventArgs and based on that sets which actions should be performed by MouseCameraController. This method can be overridden to specify custom behavior with touch events.
Protected methodGetRotationCenterPositionFromMousePosition GetRotationPivotPointFromMousePosition methods returns a Point3D that is get by 3D hit testing of specified mousePosition with the 3D objects defined in the Viewport3D. If no 3D object is hit and calculatePositionWhenNoObjectIsHit parameter is set to true, then the returned Point3D is calculated with creating a ray from mouse position and advancing in the ray direction for the distance from camera's position and camera target position. The method is called when the RotateAroundMousePosition property is true. The method can be overridden to provide custom logic to get rotation pivot point.
Public methodHideRotationAdorner HideRotationAdorner hides the shown RotationCenterAdorner.
Protected methodIsKeyboardConditionTrue IsKeyboardConditionTrue returns true when the correct keyboard modifier is pressed according to the specified conditions (only keyboard part of the conditions are checked).
Protected methodIsMouseButtonsConditionTrue IsMouseButtonsConditionTrue returns true when the correct mouse button is pressed according to the specified conditions (only mouse part of the conditions are checked; keyboard part is checked in IsKeyboardConditionTrue).
Protected methodLoadRotateCursor LoadRotateCursor loads the rotate cursor from assembly resources
Public methodMoveCamera Moves the camera for the mouse change defined by mouseDx and mouseDy parameters.
Protected methodOnCameraMoveEnded Fires CameraMoveEnded event
Protected methodOnCameraMoveStarted Fires CameraMoveStarted event
Protected methodOnCameraQuickZoomEnded Fires CameraQuickZoomEnded event
Protected methodOnCameraQuickZoomStarted Fires CameraQuickZoomStarted event
Protected methodOnCameraRotateEnded Fires CameraRotateEnded event
Protected methodOnCameraRotateStarted Fires OnCameraRotateStarted event
Protected methodOnManipulationCompleted OnManipulationCompleted is called when touch event is completed. This method starts rotation easing or resumes the suspended camera rotation. Users can override the method but it is highly recommended to call this method from the overridden method.
Protected methodOnManipulationDelta OnManipulationDelta handles the manipulation events. The method can be overridden.
Protected methodOnManipulationStarted OnManipulationStarted is called when the touch event is started. Users can override the method but it is highly recommended to call this method from the overridden method.
Protected methodOnMouseButtonDown OnMouseButtonDown processes mouse down event.
Protected methodOnMouseButtonUp OnMouseButtonUp processes mouse up event.
Protected methodOnMouseMove OnMouseMove processes mouse move event.
Protected methodOnMouseWheel OnMouseWheel processes mouse wheel event.
Protected methodOnTargetCameraChanged virtual OnTargetCameraChanged
(Overrides BaseControllerControlOnTargetCameraChanged(BaseCamera, BaseCamera))
Protected methodProcessMouseMove(Double, Double, MouseEventArgs) ProcessMouseMove handles mouse moves and calls the RotateCamera or the MoveCamera method based on the MouseCameraController settings and pressed modifier keys. The method can be overridden to move the camera based on some custom logic.
Protected methodProcessMouseMove(Double, Double, Point, Boolean, Boolean, Boolean, ModifierKeys) ProcessMouseMove handles mouse moves and calls the RotateCamera or the MoveCamera method based on the MouseCameraController settings and pressed modifier keys. The method can be overridden to move the camera based on some custom logic.
Public methodStatic memberQuadraticEaseOut Simple quadratic easing function used to decelerate the rotation: y = -1 * x * x + 2 * x
Public methodQuickZoomCamera Quickly zooms the camera for the mouse change defined by mouseDx and mouseDy parameters.
Public methodRotateCamera RotateCamera method rotates the camera for the mouse change defined by mouseDx and mouseDy parameters. The method can be overridden in a derived class to provide custom camera rotation implementation.
Public methodShowRotationAdorner ShowRotationAdorner method shows the RotationCenterAdorner at the specified rotationCenterPosition. The method can be overridden to show some other shape when rotation is started (you also need to override the HideRotationAdorner method.
Public methodStartCameraMovement Starts the camera movement by changing the changing cursor to MovementCursor. To stop mouse processing call StopCurrentMouseProcessing.
Public methodStartCameraQuickZoom Starts the camera quick zoom by changing cursor (to QuickZoomCursor) and updating the zoom target position (when ZoomMode is MousePosition or CameraRotationCenterPosition). To stop mouse processing call StopCurrentMouseProcessing.
Public methodStartCameraRotation Starts the camera rotation by showing the rotation center marker (when ShowRotationCenterMarker is true), changing cursor (to RotationCursor) and updating the rotation center position (when RotateAroundMousePosition is true). To stop mouse processing call StopCurrentMouseProcessing.
Protected methodStartMouseProcessing(Point) StartMouseProcessing is called when the correct mouse button and keyboard is pressed to start rotating or moving the camera.
Protected methodStartMouseProcessing(Point, Boolean, Boolean, Boolean, ModifierKeys) StartMouseProcessing is called when the correct mouse button and keyboard is pressed to start rotating or moving the camera.
Public methodStopCurrentMouseProcessing StopCurrentMouseProcessing can be called after calling StartCameraRotation(Point), StartCameraMovement or StartCameraQuickZoom(Point) to stop the started mouse processing.
Protected methodSubscribeEvents SubscribeEvents method subscribe mouse events to the newEventsSourceElement. The method can be overridden.
Protected methodUnsubscribeEvents UnsubscribeEvents unsubscribes from the mouse events on the subscribedEventsSourceElement.
Protected methodUpdateEnabled UpdateEnabled method checks the Target Camera's IsEnabled property and enable or disable this controller.
(Overrides BaseControllerControlUpdateEnabled)
Top
Events
 NameDescription
Public eventCameraMoveEnded CameraMoveEnded is fired when the camera movement has ended.
Public eventCameraMoveStarted CameraMoveStarted is fired when the camera movement is started.
Public eventCameraQuickZoomEnded CameraQuickZoomEnded is fired when the camera quick zoom has ended.
Public eventCameraQuickZoomStarted CameraQuickZoomStarted is fired when the camera quick zoom is started.
Public eventCameraRotateEnded CameraRotateEnded is fired when the camera rotation has ended.
Public eventCameraRotateStarted CameraRotateStarted is fired when the camera rotation is started.
Top
Fields
 NameDescription
Public fieldStatic memberEventsSourceElementNameProperty EventsSourceElementNameProperty
Public fieldStatic memberEventsSourceElementProperty EventsSourceElementProperty
Public fieldStatic memberEventsSourceElementRotationChangeProperty EventsSourceElementRotationChangeProperty
Public fieldStatic memberIsAttitudeRotationEnabledProperty IsAttitudeRotationEnabledProperty
Public fieldStatic memberIsConcurrentTouchZoomEnabledProperty IsConcurrentTouchZoomEnabledProperty
Public fieldStatic memberIsHeadingRotationEnabledProperty IsHeadingRotationEnabledProperty
Public fieldStatic memberIsMouseWheelZoomEnabledProperty IsMouseWheelZoomEnabledProperty
Public fieldStatic memberIsRotateCursorShownOnMouseOverProperty IsRotateCursorShownOnMouseOverProperty
Public fieldStatic memberIsRotationDirectionAdjustedProperty IsRotationDirectionAdjustedProperty
Public fieldStatic memberIsTouchMoveEnabledProperty IsMoveEnabledProperty
Public fieldStatic memberIsTouchRotateEnabledProperty IsTouchRotateEnabledProperty
Public fieldStatic memberIsTouchZoomEnabledProperty IsTouchZoomEnabledProperty
Public fieldStatic memberIsXAxisInvertedProperty IsYAxisInvertedProperty
Public fieldStatic memberIsXMovementEnabledProperty IsXMovementEnabledProperty
Public fieldStatic memberIsYAxisInvertedProperty IsYAxisInvertedProperty
Public fieldStatic memberIsYMovementEnabledProperty IsYMovementEnabledProperty
Public fieldStatic memberMaxCameraDistanceProperty MaxCameraDistanceProperty
Public fieldStatic memberMouseMoveThresholdProperty MouseMoveThresholdProperty
Public fieldStatic memberMouseWheelDistanceChangeFactorProperty MouseWheelDistanceChangeFactorProperty
Public fieldStatic memberMoveCameraConditionsProperty MoveCameraConditionsProperty
Public fieldStatic memberMoveOnlyHorizontallyProperty MoveOnlyHorizontallyProperty
Public fieldStatic memberQuickZoomConditionsProperty QuickZoomConditionsProperty
Public fieldStatic memberQuickZoomMaxFactorScreenDistanceProperty QuickZoomMaxFactorScreenDistanceProperty
Public fieldStatic memberQuickZoomMaxZoomInFactorProperty QuickZoomMaxZoomInFactorProperty
Public fieldStatic memberQuickZoomZoomOutFactorProperty QuickZoomZoomOutFactorProperty
Public fieldStatic memberRotateAroundMousePositionProperty RotateAroundMousePositionProperty
Public fieldStatic memberRotateCameraConditionsProperty RotateCameraConditionsProperty
Public fieldStatic memberRotationCenterAdornerProperty RotationCenterAdornerProperty
Public fieldStatic memberShowQuickZoomMarkerProperty ShowQuickZoomMarkerProperty
Public fieldStatic memberShowRotationCenterMarkerProperty ShowRotationCenterMarkerProperty
Protected fieldsubscribedEventsSourceElement FrameworkElement that is used to subscribe to mouse events
Public fieldStatic memberUsedMouseButtonProperty UsedMouseButtonProperty
Public fieldUseDXEngineHitTesting UseDXEngineHitTesting specifies if DXEngine's hit testing is used when the Viewport3D is rendered with DXEngine. Hit testing in MouseCameraController is used when RotateAroundMousePosition property is set to true and determines the center of rotation. Default value is true, but if you set UseDXEngineHitTesting to false, then WPF hit testing is used even when rendered with DXEngine.
Public fieldStatic memberUseMousePositionForMovementSpeedProperty UseMousePositionForMovementSpeedProperty
Public fieldStatic memberZoomModeProperty ZoomToMousePositionProperty
Top
See Also