ezEngine  Release 25.03
ezCamera Class Reference

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

#include <Camera.h>

Public Member Functions

void SetCoordinateSystem (ezBasisAxis::Enum forwardAxis, ezBasisAxis::Enum rightAxis, ezBasisAxis::Enum axis)
 Allows to specify a different coordinate system in which the camera input and output coordinates are given. More...
 
void SetCoordinateSystem (const ezSharedPtr< ezCoordinateSystemProvider > &pProvider)
 Allows to specify a full ezCoordinateSystemProvider to determine forward/right/up vectors for camera movement.
 
ezVec3 GetPosition (ezCameraEye eye=ezCameraEye::Left) const
 Returns the position of the camera that should be used for rendering etc.
 
ezVec3 GetDirForwards (ezCameraEye eye=ezCameraEye::Left) const
 Returns the forwards vector that should be used for rendering etc.
 
ezVec3 GetDirUp (ezCameraEye eye=ezCameraEye::Left) const
 Returns the up vector that should be used for rendering etc.
 
ezVec3 GetDirRight (ezCameraEye eye=ezCameraEye::Left) const
 Returns the right vector that should be used for rendering etc.
 
ezAngle GetFovX (float fAspectRatioWidthDivHeight) const
 Returns the horizontal FOV. More...
 
ezAngle GetFovY (float fAspectRatioWidthDivHeight) const
 Returns the vertical FOV. More...
 
float GetDimensionX (float fAspectRatioWidthDivHeight) const
 Returns the horizontal dimension for an orthographic view. More...
 
float GetDimensionY (float fAspectRatioWidthDivHeight) const
 Returns the vertical dimension for an orthographic view. More...
 
ezVec3 GetCenterPosition () const
 Returns the average camera position. More...
 
ezVec3 GetCenterDirForwards () const
 Returns the average forwards vector. More...
 
ezVec3 GetCenterDirUp () const
 Returns the average up vector. More...
 
ezVec3 GetCenterDirRight () const
 Returns the average right vector. More...
 
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 (ezCameraMode::Enum mode, float fFovOrDim, float fNearPlane, float fFarPlane)
 Specifies the mode and the projection settings that this camera uses. More...
 
void SetStereoProjection (const ezMat4 &mProjectionLeftEye, const ezMat4 &mProjectionRightEye, float fAspectRatioWidthDivHeight)
 
float GetFovOrDim () const
 Returns the fFovOrDim parameter that was passed to SetCameraProjectionAndMode().
 
ezCameraMode::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 ezMat4 &mLookAtMatrix, ezCameraEye eye=ezCameraEye::Left)
 Sets the view matrix directly. More...
 
void LookAt (const ezVec3 &vCameraPos, const ezVec3 &vTargetPos, const ezVec3 &vUp)
 Repositions the camera such that it looks at the given target position. More...
 
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. More...
 
void MoveGlobally (float fForward, float fRight, float fUp)
 Moves the camera in global space along the forward/right/up directions of the coordinate system. More...
 
void RotateLocally (ezAngle forwardAxis, ezAngle rightAxis, ezAngle axis)
 Rotates the camera around the forward, right and up axis in its own local space. More...
 
void RotateGlobally (ezAngle forwardAxis, ezAngle rightAxis, ezAngle axis)
 Rotates the camera around the forward, right and up axis of the coordinate system in global space. More...
 
const ezMat4GetViewMatrix (ezCameraEye eye=ezCameraEye::Left) const
 Returns the view matrix for the given eye. More...
 
void GetProjectionMatrix (float fAspectRatioWidthDivHeight, ezMat4 &out_mProjectionMatrix, ezCameraEye eye=ezCameraEye::Left, ezClipSpaceDepthRange::Enum depthRange=ezClipSpaceDepthRange::Default) const
 Calculates the projection matrix from the current camera properties and stores it in out_projectionMatrix. More...
 
float GetExposure () const
 
void SetExposure (float fExposure)
 
ezUInt32 GetSettingsModificationCounter () const
 Returns a counter that is increased every time the camera settings are modified. More...
 
ezUInt32 GetOrientationModificationCounter () const
 Returns a counter that is increased every time the camera orientation is modified. More...
 

Detailed Description

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

Member Function Documentation

◆ GetCenterDirForwards()

ezVec3 ezCamera::GetCenterDirForwards ( ) const
inline

Returns the average forwards vector.

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

◆ GetCenterDirRight()

ezVec3 ezCamera::GetCenterDirRight ( ) const
inline

Returns the average right vector.

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

◆ GetCenterDirUp()

ezVec3 ezCamera::GetCenterDirUp ( ) const
inline

Returns the average up vector.

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

◆ GetCenterPosition()

ezVec3 ezCamera::GetCenterPosition ( ) const
inline

Returns the average camera position.

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

◆ GetDimensionX()

float ezCamera::GetDimensionX ( float  fAspectRatioWidthDivHeight) const

Returns the horizontal dimension for an orthographic view.

Works only with ezCameraMode::OrthoFixedWidth and ezCameraMode::OrthoFixedWidth

◆ GetDimensionY()

float ezCamera::GetDimensionY ( float  fAspectRatioWidthDivHeight) const

Returns the vertical dimension for an orthographic view.

Works only with ezCameraMode::OrthoFixedWidth and ezCameraMode::OrthoFixedWidth

◆ GetFovX()

ezAngle ezCamera::GetFovX ( float  fAspectRatioWidthDivHeight) const

Returns the horizontal FOV.

Works only with ezCameraMode::PerspectiveFixedFovX and ezCameraMode::PerspectiveFixedFovY

◆ GetFovY()

ezAngle ezCamera::GetFovY ( float  fAspectRatioWidthDivHeight) const

Returns the vertical FOV.

Works only with ezCameraMode::PerspectiveFixedFovX and ezCameraMode::PerspectiveFixedFovY

◆ GetOrientationModificationCounter()

ezUInt32 ezCamera::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 ezCamera::GetProjectionMatrix ( float  fAspectRatioWidthDivHeight,
ezMat4 out_mProjectionMatrix,
ezCameraEye  eye = ezCameraEye::Left,
ezClipSpaceDepthRange::Enum  depthRange = ezClipSpaceDepthRange::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()

ezUInt32 ezCamera::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()

const EZ_ALWAYS_INLINE ezMat4 & ezCamera::GetViewMatrix ( ezCameraEye  eye = ezCameraEye::Left) const

Returns the view matrix for the given eye.

Note
The view matrix is given in OpenGL convention.

◆ LookAt()

void ezCamera::LookAt ( const ezVec3 vCameraPos,
const ezVec3 vTargetPos,
const ezVec3 vUp 
)

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

Not supported for stereo cameras.

◆ MoveGlobally()

void ezCamera::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 ezCamera::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 ezCamera::RotateGlobally ( ezAngle  forwardAxis,
ezAngle  rightAxis,
ezAngle  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 ezCamera::RotateLocally ( ezAngle  forwardAxis,
ezAngle  rightAxis,
ezAngle  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 ezCamera::SetCameraMode ( ezCameraMode::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 ezCamera::SetCoordinateSystem ( ezBasisAxis::Enum  forwardAxis,
ezBasisAxis::Enum  rightAxis,
ezBasisAxis::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 ezCamera::SetStereoProjection ( const ezMat4 mProjectionLeftEye,
const ezMat4 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 ezCamera::SetViewMatrix ( const ezMat4 mLookAtMatrix,
ezCameraEye  eye = ezCameraEye::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: