Click or drag to resize
Ab4d.SharpEngine logo

FirstPersonCamera Class

FirstPersonCamera is a camera that simulates the person's view on the world.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.CamerasCamera
    Ab4d.SharpEngine.CamerasSphericalCamera
      Ab4d.SharpEngine.CamerasFirstPersonCamera

Namespace: Ab4d.SharpEngine.Cameras
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 1.0.8740+deb2991acfe86a95cca780cd4f82bcae2805c1a5
Syntax
C#
public class FirstPersonCamera : SphericalCamera, 
	ICameraPositionCamera

The FirstPersonCamera type exposes the following members.

Constructors
 NameDescription
Public methodFirstPersonCamera Constructor
Top
Properties
 NameDescription
Public propertyCameraPosition Gets the position of the camera as Vector3.
Top
Methods
 NameDescription
Public methodGetCameraPosition Returns the current position of the camera.
(Overrides CameraGetCameraPosition)
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 methodMoveBackward Moves the camera backward (in the opposite as look direction)
Public methodMoveCamera Moves the camera for the moveVector (regardless of the current camera's LookDirection and UpDirection)
Public methodMoveDown Moves the camera down (in the opposite up direction)
Public methodMoveFor Animates the CameraPosition by changing it for the specified cameraPositionOffset. The animation takes animationDurationInMilliseconds and uses the specified easingFunction.
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 methodMoveTo Animates the CameraPosition to the finalTargetPosition. The animation takes animationDurationInMilliseconds and uses the specified easingFunction.
Public methodMoveUp Moves the camera up (in the up direction)
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.
Protected methodStrafeCamera Strafes the camera - moves it in the direction perpendicular to the camera's LookDirection and UpDirection.
Public methodTurnToDirection Turns the camera to the specified direction
Public methodTurnToPosition Turns the camera to the direction of the specified position
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

FirstPersonCamera is a camera that simulates the person's view on the world. It is defined by the CameraPosition of the person and the direction of the camera - defined by Heading, Attitude and Bank properties.

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

The First person camera defines methods to simplify the movement of "the person":
MoveForward(Single), MoveBackward(Single), MoveRight(Single), MoveLeft(Single), MoveDown(Single), MoveUp(Single), StrafeCamera(Single, Single, Single) and MoveCamera(Vector3).

Example

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

C#
var firstPersonCamera = new FirstPersonCamera()
{
    CameraPosition = new Vector3(0, 30, 200),
    Heading = 30,
    Attitude = -10
};

sceneView.Camera = firstPersonCamera;
See Also