Click or drag to resize
Ab4d.SharpEngine logo

TargetPositionCamera Class

TargetPositionCamera is a camera that is looking at the specified position from the specified angle and distance. The camera is rotated around the up axis in the current coordinate system.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.CamerasCamera
    Ab4d.SharpEngine.CamerasSphericalCamera
      Ab4d.SharpEngine.CamerasTargetPositionCamera

Namespace: Ab4d.SharpEngine.Cameras
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 1.0.8740+deb2991acfe86a95cca780cd4f82bcae2805c1a5
Syntax
C#
public class TargetPositionCamera : SphericalCamera, 
	ITargetPositionCamera, IDistanceCamera, IRotationCenterPositionCamera, IFitIntoViewCamera

The TargetPositionCamera type exposes the following members.

Constructors
 NameDescription
Public methodTargetPositionCamera Constructor
Top
Properties
 NameDescription
Public propertyDistance Gets or sets a distance from the camera to the target position
Public propertyRotationCenterPosition Gets or sets a nullable Vector3 that can specify a custom 3D position around which this TargetPositionCamera is rotated. Rotation around custom center position changes the camera angles (Heading and Attitude) and also TargetPosition. When RotationCenterPosition is null, the rotation is done with changing only Heading and Attitude properties.
Public propertyTargetPosition Gets the camera look position as Vector3.
Top
Methods
 NameDescription
Public methodFitIntoView(BoundingBox, Boolean, Single, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or ViewWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that the specified BoundingBox will be visible from one edge of the SceneView to another edge.
Public methodFitIntoView(FitIntoViewType, Boolean, Single, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or ViewWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that all the objects on the scene will be visible from one edge of the SceneView to another edge. This is the same as calling FitIntoView and passing Scene.RootNode as parameter.
Public methodFitIntoView(Vector3, Boolean, Single, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or ViewWidth (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(SceneNode, FitIntoViewType, Boolean, Single, Boolean) FitIntoView adjusts the camera's Distance (for PerspectiveCamera) or ViewWidth (for OrthographicCamera) and TargetPosition (if adjustTargetPosition is true) so that the specified sceneNode (or all child SceneNodes if sceneNode is GroupNode) will be visible from one edge of the SceneView to another edge.
Public methodGetCameraPosition Returns the current position of the camera.
(Overrides CameraGetCameraPosition)
Public methodGetFitIntoViewDistanceOrViewWidth(SceneNode, FitIntoViewType, Boolean, Vector3) GetFitIntoViewDistanceOrViewWidth returns a Distance (for PerspectiveCamera) or a ViewWidth (for OrthographicCamera) and sets the newTargetPosition that will adjust the camera so that all the specified sceneNodes will be visible from one edge of the viewport to another edge.
Public methodGetFitIntoViewDistanceOrViewWidth(Vector3, FitIntoViewType, Boolean, Vector3) GetFitIntoViewDistanceOrViewWidth returns a Distance (for PerspectiveCamera) or a ViewWidth (for OrthographicCamera) and sets the newTargetPosition that will adjust the camera so that all the specified positions will be visible from one edge of the viewport to another edge.
Public methodGetLookDirection Returns the normalized look direction of the camera.
(Overrides CameraGetLookDirection)
Public methodGetUpDirection Returns the normalized up direction of the camera.
(Overrides CameraGetUpDirection)
Public methodMoveTargetPositionFor Animates the TargetPosition by changing it for the specified targetPositionOffset. The animation takes animationDurationInMilliseconds and uses the specified easingFunction.
Public methodMoveTargetPositionTo Animates the TargetPosition to the finalTargetPosition. The animation takes animationDurationInMilliseconds and uses the specified easingFunction.
Public methodRotateCamera Rotates this camera for the specified heading and attitude. When RotationCenterPosition is set, the camera rotates around RotationCenterPosition which can change Heading, Attitude, TargetPosition and Distance.
(Overrides SphericalCameraRotateCamera(Single, Single))
Public methodRotateFor Animates the camera rotation with changing the Camera's Heading and Attitude for the specified amount. The animation takes animationDurationInMilliseconds and uses easingFunction.
Public methodRotateTo Animates the camera rotation to the targetHeading and targetAttitude. The animation takes animationDurationInMilliseconds and uses easingFunction. By default (when useShortestPath is true), the animation uses the shortest path to get to the target heading and attitude.
Public methodUpdate Update method updates the camera matrices when needed (when there were any change in the camera properties) or when forceMatrixUpdate is set to true.
(Overrides CameraUpdate(Boolean))
Top
Remarks

TargetPositionCamera is a camera that is looking at the TargetPosition from the specified angle and distance.

The angle is specified by Heading, Attitude and Bank properties.

The distance from the camera to the TargetPosition is defined by the Distance property.

The camera is rotated around the up axis in the current coordinate system.

The ShowCameraLight and the CameraLight properties can be used to add a CameraLight to the Scene. The CameraLight is a DirectionalLight is illuminating the scene looking from the position of the camera and in the camera's look direction. In the real world this would be a light that is mounted to the camera. This way the 3D objects that are viewed with the camera are always illuminated regardless of the cameras position.

The ShowCameraLight defines when the camera light is shown. The possible values are:

  • Never – Never add additional camera light
  • Auto – (Default value) Show camera light only if there is no other light defined in the Scene controlled by the camera.
  • Always – Always add a camera light
Example

The following code creates a TargetPositionCamera and assign it to the SceneView:

C#
var camera = new TargetPositionCamera()
{
    TargetPosition = new Vector3(0, 0, 0),
    Heading = -40,
    Attitude = -25,
    Distance = 300,
    ShowCameraLight = ShowCameraLightType.Auto // If there are no other light in the Scene, then add a camera light that illuminates the scene in the camera's look direction
};

sceneView.Camera = camera;
See Also