Click or drag to resize
Ab4d.SharpEngine logo

CameraController Class

CameraController is an abstract class that provides the basic code for mouse or touch camera controller for camera rotation, movement and quick zoom. Usually this class is used by the platform specific MouseCameraController that is defined in per-platform assembly (for example Ab4d.SharpEngine.Wpf, Ab4d.SharpEngine.WinUI, Ab4d.SharpEngine.AvaloniaUI). The class can be also used by the ManualMouseCameraController to manually provide mouse events.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.UtilitiesCameraController
    Ab4d.SharpEngine.UtilitiesManualMouseCameraController

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 1.0.8740+deb2991acfe86a95cca780cd4f82bcae2805c1a5
Syntax
C#
public abstract class CameraController

The CameraController type exposes the following members.

Constructors
 NameDescription
Public methodCameraController Constructor
Public methodCameraController(SceneView) Constructor
Top
Properties
 NameDescription
Public propertyCamera Gets the camera from the used SceneView.
Public propertyCaptureMouseAction 
Public propertyEventsSourceElementRotationChange Gets or sets a float value that specifies for how many degrees the camera is rotates when the mouse moves from one side of theSceneView to another size. 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 [!:Cameras.Camera.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 [!:Cameras.Camera.StartRotation(double, double)] method.
Public propertyIsEnabled True when the camera controller is enabled
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. 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 float value that when set to a value that is not float.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 float.NaN.
Public propertyMouseMoveThreshold Gets or sets a float 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, then rotation, movement or quick zoom are started immediately when the correct mouse buttons and keyboard modifiers are pressed (no mouse movement needed). Default value is 2.
Public propertyMouseWheelDistanceChangeFactor Gets or sets a float 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 propertyQuickZoomMaxFactorScreenDistance QuickZoomZoomOutFactor is used when QuickZoom 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 QuickZoom 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 QuickZoom 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 propertyReleaseMouseCaptureAction 
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 propertySceneView SceneView that is used by this CameraController
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 CameraZoomMode enum that specifies the location into which camera is zoomed. Note that MousePosition and CameraRotationCenterPosition work only for TargetPositionCamera and FreeCamera. Default value is ViewCenter.
Top
Methods
 NameDescription
Protected methodCaptureMouse protected virtual CaptureMouse
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 methodEndCameraMovement protected EndCameraMovement
Protected methodEndCameraQuickZoom EndCameraQuickZoom
Protected methodEndCameraRotation protected EndCameraRotation
Protected methodEndMouseProcessing EndMouseProcessing is called when the mouse button that started rotation or movement is released.
Protected methodGetCameraMoveAdjustment protected virtual GetCameraMoveAdjustment
Protected methodGetCameraRotationCenterPosition protected GetCameraRotationCenterPosition
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.
Protected methodIsCameraRotationCenterPositionSupported protected IsCameraRotationCenterPositionSupported
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
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.
Protected methodReleaseMouseCapture protected virtual ReleaseMouseCapture
Protected methodResumeAnimationOrStartRotationEasing protected ResumeAnimationOrStartRotationEasing
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.
Protected methodSetCameraDistance protected SetCameraDistance
Protected methodSetCameraPositionForMouseMove protected SetCameraPositionForMouseMove
Protected methodSetCameraRotationCenterPosition protected SetCameraRotationCenterPosition
Protected methodStartCameraMovement protected StartCameraMovement
Protected methodStartCameraQuickZoom StartCameraQuickZoom
Protected methodStartCameraRotation protected StartCameraRotation
Protected methodSubscribeSceneView Protected virtual SubscribeSceneView
Protected methodSuspendAnimationOrStopEasingRotation protected SuspendAnimationOrStopEasingRotation
Protected methodUnsubscribeSceneView Protected virtual UnsubscribeSceneView
Protected methodUpdateRotationCenterPosition protected UpdateRotationCenterPosition
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
See Also