Click or drag to resize
AB4D logo

FreeCamera Class

FreeCamera is a camera that is not defined by heading, attitude and bank angle. It is also not rotated around y axis. Instead the camera is defined by CameraPosition, TargetPosition and UpDirection. The camera is not limited to rotation around y axis.
Inheritance Hierarchy
SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      System.Windows.MediaVisual
        System.WindowsUIElement
          System.WindowsFrameworkElement
            Ab3d.CamerasBaseCamera
              Ab3d.CamerasFreeCamera

Namespace: Ab3d.Cameras
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.2.9104.2045
Syntax
C#
public class FreeCamera : BaseCamera, IMovableCamera, 
	IFitIntoViewCamera

The FreeCamera type exposes the following members.

Constructors
 NameDescription
Public methodFreeCameraInitializes a new instance of the FreeCamera class
Top
Properties
 NameDescription
Public propertyCameraPosition Gets or sets the position of the camera.
Public propertyRotationCenterPosition Gets or sets a nullable Point3D that can specify a custom 3D position around which this FreeCamera is rotated. When RotationCenterPosition is set (not null) and this camera is rotated then the TargetPosition and CameraPosition are changed.
Public propertyRotationUpAxis Gets or sets a nullable Vector3D that can specify a custom rotation up axis that is used to when camera is rotated "horizontally" (e.g when user drags the mouse horizontally). When RotationUpAxis is not set (is null) then camera rotates around the current camera's UpDirection. This provides the standard free camera experience and is the default setting.
Public propertyTargetPosition Gets or sets the position where the camera is looking at and around which point the camera is being rotated.
Public propertyUpDirection Gets or sets a Vector3D that specifies the up direction of the camera.
Top
Methods
 NameDescription
Protected methodBaseCreateFrom This method is called from CreateFrom method and actually sets the properties on this camera.
(Overrides BaseCameraBaseCreateFrom(Camera))
Public methodFitIntoView(FitIntoViewType, Boolean, Double, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or CameraWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that all the objects on the scene will be visible from one edge of the viewport to another edge.
Public methodFitIntoView(IListPoint3D, Boolean, Double, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or CameraWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that all the specified positions will be visible from one edge of the viewport to another edge.
Public methodFitIntoView(Rect3D, Boolean, Double, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or CameraWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that all the specified Rect3D will be visible from one edge of the viewport to another edge.
Public methodFitIntoView(IListVisual3D, FitIntoViewType, Boolean, Double, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or CameraWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that all the objects on defined in list of Visual3D objects will be visible from one edge of the viewport to another edge.
Public methodGetFitIntoViewDistanceOrCameraWidth GetFitIntoViewDistanceOrCameraWidth returns Distance (for PerspectiveCamera) or CameraWidth (for OrthographicCamera) and sets the newTargetPosition that will adjust the camera so that all the objects on the scene will be visible from one edge of the viewport to another edge.
Public methodGetNormalizedUpDirection GetNormalizedUpDirection returns the normalized UpDirection vector. If the vector that is set to the UpDirection property is not perpendicular to the look direction, the returned up direction is corrected to be perpendicular.
Public methodGetNormalizedUpDirection(Vector3D, Vector3D) GetNormalizedUpDirection returns the normalized UpDirection vector. If the specified upDirection is not perpendicular to the look direction, the returned up direction is corrected to be perpendicular.
Public methodGetRotatedCamera GetRotatedCamera method calculates rotatedCameraPosition, rotatedTargetPosition and rotatedUpDirection based on the rotating the camera from the initial camera position and direction.
Public methodIsValid Gets a Boolean that specifies if the camera is valid (has TargetViewport3D that has a valid size; has valid values for all properties). When camera is valid the Point3DTo2D(Point3D) returns correct value; when the camera is not valid, the Point3DTo2D method cannot calculate the 2D screen position.
(Overrides BaseCameraIsValid(Boolean))
Public methodMoveBackward Moves the camera backward (in the opposite as look direction)
Public methodMoveDown Moves the camera down (in the opposite up direction)
Public methodMoveForward Moves the camera forward (in the look direction)
Public methodMoveLeft Moves the camera left (strafe)
Public methodMoveRight Moves the camera right (strafe)
Public methodMoveUp Moves the camera up (in the up direction)
Protected methodOnIsValidChanged OnIsValidChanged is called on IsValidChanged event. The event is subscribed by calling SubscribeToIsValidChanged and unsubscribed by calling UnsubscribeFromIsValidChanged.
(Overrides BaseCameraOnIsValidChanged(Object, EventArgs))
Public methodRotateCamera(Double, Double) Rotates the free camera for the specified heading and attitude. When RotationCenterPosition is set, the camera rotates around RotationCenterPosition which changes the TargetPosition and CameraPosition.
(Overrides BaseCameraRotateCamera(Double, Double))
Public methodRotateCamera(Double, Double, Double) Rotates the free camera for the specified heading, attitude and bank. When RotationCenterPosition is set, the camera rotates around RotationCenterPosition which changes the TargetPosition and CameraPosition.
Public methodRotateCamera(Double, Double, Double, Int32, FuncDouble, Double, FreeCameraAnimationNodeFreeCameraAnimationTypes) Rotates the free camera for the specified heading, attitude and bank. When RotationCenterPosition is set, the camera rotates around RotationCenterPosition which changes the TargetPosition and CameraPosition. When animationDurationInMilliseconds parameter is bigger then 0, then rotation is animated.
Public methodRotateTo(Point3D, Vector3D, Int32, FuncDouble, Double, FreeCameraAnimationNodeFreeCameraAnimationTypes) Animates the CameraPosition and UpDirection to the targetCameraPosition and targetUpDirection. The rotation preserves the TargetPosition and the distance between CameraPosition and TargetPosition. The animation takes animationDurationInMilliseconds and uses easingFunction. By default (when animationType is SphericalInterpolation), the animation uses spherical interpolation instead of linear interpolation to come from the current to the target position.
Public methodRotateTo(Point3D, Point3D, Vector3D, Int32, FuncDouble, Double, FreeCameraAnimationNodeFreeCameraAnimationTypes) Animates the CameraPosition, TargetPosition and UpDirection to the targetCameraPosition, targetTargetPosition and targetUpDirection. The animation takes animationDurationInMilliseconds and uses easingFunction. By default (when animationType is SphericalInterpolation), the animation uses spherical interpolation instead of linear interpolation to come from the current to the target position.
Public methodSetCameraPosition SetCameraPosition method preserves the current TargetPosition and sets the CameraPosition and the UpDirection based on the specified heading, attitude, bank and distance values.
Public methodSetTargetPosition SetTargetPosition method preserves the current CameraPosition and sets the TargetPosition and the UpDirection based on the specified heading, attitude, bank and distance values.
Protected methodStrafeCamera Calculates the moveVector based on the current camera's LookDirection and UpDirection
Protected methodUpdateCamera Updates the ProjectionCamera
(Overrides BaseCameraUpdateCamera(ProjectionCamera))
Top
Fields
 NameDescription
Public fieldStatic memberCameraPositionProperty CameraPositionProperty
Public fieldStatic memberRotationCenterPositionProperty RotationCenterPositionProperty
Public fieldStatic memberRotationUpAxisProperty RotationUpAxisProperty
Public fieldStatic memberTargetPositionProperty TargetPositionProperty
Public fieldStatic memberUpDirectionProperty UpDirectionProperty
Top
See Also