Plasma Engine  2.0
Loading...
Searching...
No Matches
plCamera Class Reference

A camera class that stores the orientation and some basic camera settings. More...

#include <Camera.h>

Public Member Functions

void SetCoordinateSystem (plBasisAxis::Enum forwardAxis, plBasisAxis::Enum rightAxis, plBasisAxis::Enum axis)
 Allows to specify a different coordinate system in which the camera input and output coordinates are given.
 
void SetCoordinateSystem (const plSharedPtr< plCoordinateSystemProvider > &pProvider)
 Allows to specify a full plCoordinateSystemProvider to determine forward/right/up vectors for camera movement.
 
plVec3 GetPosition (plCameraEye eye=plCameraEye::Left) const
 Returns the position of the camera that should be used for rendering etc.
 
plVec3 GetDirForwards (plCameraEye eye=plCameraEye::Left) const
 Returns the forwards vector that should be used for rendering etc.
 
plVec3 GetDirUp (plCameraEye eye=plCameraEye::Left) const
 Returns the up vector that should be used for rendering etc.
 
plVec3 GetDirRight (plCameraEye eye=plCameraEye::Left) const
 Returns the right vector that should be used for rendering etc.
 
plAngle GetFovX (float fAspectRatioWidthDivHeight) const
 Returns the horizontal FOV.
 
plAngle GetFovY (float fAspectRatioWidthDivHeight) const
 Returns the vertical FOV.
 
float GetDimensionX (float fAspectRatioWidthDivHeight) const
 Returns the horizontal dimension for an orthographic view.
 
float GetDimensionY (float fAspectRatioWidthDivHeight) const
 Returns the vertical dimension for an orthographic view.
 
plVec3 GetCenterPosition () const
 Returns the average camera position.
 
plVec3 GetCenterDirForwards () const
 Returns the average forwards vector.
 
plVec3 GetCenterDirUp () const
 Returns the average up vector.
 
plVec3 GetCenterDirRight () const
 Returns the average right vector.
 
float GetNearPlane () const
 Returns the near plane distance that was passed to SetCameraProjectionAndMode().
 
float GetFarPlane () const
 Returns the far plane distance that was passed to SetCameraProjectionAndMode().
 
void SetCameraMode (plCameraMode::Enum mode, float fFovOrDim, float fNearPlane, float fFarPlane)
 Specifies the mode and the projection settings that this camera uses.
 
void SetStereoProjection (const plMat4 &mProjectionLeftEye, const plMat4 &mProjectionRightEye, float fAspectRatioWidthDivHeight)
 
float GetFovOrDim () const
 Returns the fFovOrDim parameter that was passed to SetCameraProjectionAndMode().
 
plCameraMode::Enum GetCameraMode () const
 Returns the current camera mode.
 
bool IsPerspective () const
 
bool IsOrthographic () const
 
bool IsStereoscopic () const
 Whether this is a stereoscopic camera.
 
void SetViewMatrix (const plMat4 &mLookAtMatrix, plCameraEye eye=plCameraEye::Left)
 Sets the view matrix directly.
 
void LookAt (const plVec3 &vCameraPos, const plVec3 &vTargetPos, const plVec3 &vUp)
 Repositions the camera such that it looks at the given target position.
 
void MoveLocally (float fForward, float fRight, float fUp)
 Moves the camera in its local space along the forward/right/up directions of the coordinate system.
 
void MoveGlobally (float fForward, float fRight, float fUp)
 Moves the camera in global space along the forward/right/up directions of the coordinate system.
 
void RotateLocally (plAngle forwardAxis, plAngle rightAxis, plAngle axis)
 Rotates the camera around the forward, right and up axis in its own local space.
 
void RotateGlobally (plAngle forwardAxis, plAngle rightAxis, plAngle axis)
 Rotates the camera around the forward, right and up axis of the coordinate system in global space.
 
const plMat4GetViewMatrix (plCameraEye eye=plCameraEye::Left) const
 Returns the view matrix for the given eye.
 
void GetProjectionMatrix (float fAspectRatioWidthDivHeight, plMat4 &out_mProjectionMatrix, plCameraEye eye=plCameraEye::Left, plClipSpaceDepthRange::Enum depthRange=plClipSpaceDepthRange::Default) const
 Calculates the projection matrix from the current camera properties and stores it in out_projectionMatrix.
 
float GetExposure () const
 
void SetExposure (float fExposure)
 
float GetAperture () const
 
void SetAperture (float fAperture)
 
float GetShutterSpeed () const
 
void SetShutterSpeed (float fShutterSpeed)
 
float GetISO () const
 
void SetISO (float fISO)
 
float GetFocusDistance () const
 
void SetFocusDistance (float fFocusDistance)
 
plUInt32 GetSettingsModificationCounter () const
 Returns a counter that is increased every time the camera settings are modified.
 
plUInt32 GetOrientationModificationCounter () const
 Returns a counter that is increased every time the camera orientation is modified.
 

Detailed Description

A camera class that stores the orientation and some basic camera settings.

Member Function Documentation

◆ GetCenterDirForwards()

plVec3 plCamera::GetCenterDirForwards ( ) const
inline

Returns the average forwards vector.

For all cameras execpt Stereo cameras this is identical to GetDirForwards()

◆ GetCenterDirRight()

plVec3 plCamera::GetCenterDirRight ( ) const
inline

Returns the average right vector.

For all cameras execpt Stereo cameras this is identical to GetDirRight()

◆ GetCenterDirUp()

plVec3 plCamera::GetCenterDirUp ( ) const
inline

Returns the average up vector.

For all cameras execpt Stereo cameras this is identical to GetDirUp()

◆ GetCenterPosition()

plVec3 plCamera::GetCenterPosition ( ) const
inline

Returns the average camera position.

For all cameras execpt Stereo cameras this is identical to GetPosition()

◆ GetDimensionX()

float plCamera::GetDimensionX ( float fAspectRatioWidthDivHeight) const

Returns the horizontal dimension for an orthographic view.

Works only with plCameraMode::OrthoFixedWidth and plCameraMode::OrthoFixedWidth

◆ GetDimensionY()

float plCamera::GetDimensionY ( float fAspectRatioWidthDivHeight) const

Returns the vertical dimension for an orthographic view.

Works only with plCameraMode::OrthoFixedWidth and plCameraMode::OrthoFixedWidth

◆ GetFovX()

plAngle plCamera::GetFovX ( float fAspectRatioWidthDivHeight) const

Returns the horizontal FOV.

Works only with plCameraMode::PerspectiveFixedFovX and plCameraMode::PerspectiveFixedFovY

◆ GetFovY()

plAngle plCamera::GetFovY ( float fAspectRatioWidthDivHeight) const

Returns the vertical FOV.

Works only with plCameraMode::PerspectiveFixedFovX and plCameraMode::PerspectiveFixedFovY

◆ GetOrientationModificationCounter()

plUInt32 plCamera::GetOrientationModificationCounter ( ) const
inline

Returns a counter that is increased every time the camera orientation is modified.

The camera orientation is used to compute the view matrix. This counter can be used to determine whether the view matrix has changed and thus whether cached values need to be updated.

◆ GetProjectionMatrix()

void plCamera::GetProjectionMatrix ( float fAspectRatioWidthDivHeight,
plMat4 & out_mProjectionMatrix,
plCameraEye eye = plCameraEye::Left,
plClipSpaceDepthRange::Enum depthRange = plClipSpaceDepthRange::Default ) const

Calculates the projection matrix from the current camera properties and stores it in out_projectionMatrix.

If the camera is stereo and the given aspect ratio is close to the aspect ratio passed in SetStereoProjection, the matrix set in SetStereoProjection will be used.

◆ GetSettingsModificationCounter()

plUInt32 plCamera::GetSettingsModificationCounter ( ) const
inline

Returns a counter that is increased every time the camera settings are modified.

The camera settings are used to compute the projection matrix. This counter can be used to determine whether the projection matrix has changed and thus whether cached values need to be updated.

◆ GetViewMatrix()

PL_ALWAYS_INLINE const plMat4 & plCamera::GetViewMatrix ( plCameraEye eye = plCameraEye::Left) const

Returns the view matrix for the given eye.

Note
The view matrix is given in OpenGL convention.

◆ LookAt()

void plCamera::LookAt ( const plVec3 & vCameraPos,
const plVec3 & vTargetPos,
const plVec3 & vUp )

Repositions the camera such that it looks at the given target position.

Not supported for stereo cameras.

◆ MoveGlobally()

void plCamera::MoveGlobally ( float fForward,
float fRight,
float fUp )

Moves the camera in global space along the forward/right/up directions of the coordinate system.

Not supported for stereo cameras.

◆ MoveLocally()

void plCamera::MoveLocally ( float fForward,
float fRight,
float fUp )

Moves the camera in its local space along the forward/right/up directions of the coordinate system.

Not supported for stereo cameras.

◆ RotateGlobally()

void plCamera::RotateGlobally ( plAngle forwardAxis,
plAngle rightAxis,
plAngle axis )

Rotates the camera around the forward, right and up axis of the coordinate system in global space.

Rotate around Z for turning the camera left/right. Not supported for stereo cameras.

◆ RotateLocally()

void plCamera::RotateLocally ( plAngle forwardAxis,
plAngle rightAxis,
plAngle axis )

Rotates the camera around the forward, right and up axis in its own local space.

Rotate around rightAxis for looking up/down. \forwardAxis is roll. For turning left/right use RotateGlobally(). Not supported for stereo cameras.

◆ SetCameraMode()

void plCamera::SetCameraMode ( plCameraMode::Enum mode,
float fFovOrDim,
float fNearPlane,
float fFarPlane )

Specifies the mode and the projection settings that this camera uses.

Parameters
fFovOrDimFov X/Y in degree or width/height (depending on Mode).

◆ SetCoordinateSystem()

void plCamera::SetCoordinateSystem ( plBasisAxis::Enum forwardAxis,
plBasisAxis::Enum rightAxis,
plBasisAxis::Enum axis )

Allows to specify a different coordinate system in which the camera input and output coordinates are given.

The default in z is forward = PositiveX, right = PositiveY, Up = PositiveZ.

◆ SetStereoProjection()

void plCamera::SetStereoProjection ( const plMat4 & mProjectionLeftEye,
const plMat4 & mProjectionRightEye,
float fAspectRatioWidthDivHeight )

Sets the camera mode to stereo and specifies projection matrices directly.

Parameters
fAspectRatioThese stereo projection matrices will only be returned by getProjectionMatrix for the given aspectRatio.

◆ SetViewMatrix()

void plCamera::SetViewMatrix ( const plMat4 & mLookAtMatrix,
plCameraEye eye = plCameraEye::Left )

Sets the view matrix directly.

Works with all camera types. Position- and direction- getter/setter will work as usual.


The documentation for this class was generated from the following files: