XII Release 0.1.0
Loading...
Searching...
No Matches
xiiCamera Class Reference

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

#include <Camera.h>

Public Member Functions

void SetCoordinateSystem (xiiBasisAxis::Enum forwardAxis, xiiBasisAxis::Enum rightAxis, xiiBasisAxis::Enum axis)
 Allows to specify a different coordinate system in which the camera input and output coordinates are given.
 
void SetCoordinateSystem (const xiiSharedPtr< xiiCoordinateSystemProvider > &pProvider)
 Allows to specify a full xiiCoordinateSystemProvider to determine forward/right/up vectors for camera movement.
 
xiiVec3 GetPosition (xiiCameraEye eye=xiiCameraEye::Left) const
 Returns the position of the camera that should be used for rendering etc.
 
xiiVec3 GetDirForwards (xiiCameraEye eye=xiiCameraEye::Left) const
 Returns the forwards vector that should be used for rendering etc.
 
xiiVec3 GetDirUp (xiiCameraEye eye=xiiCameraEye::Left) const
 Returns the up vector that should be used for rendering etc.
 
xiiVec3 GetDirRight (xiiCameraEye eye=xiiCameraEye::Left) const
 Returns the right vector that should be used for rendering etc.
 
xiiAngle GetFovX (float fAspectRatioWidthDivHeight) const
 Returns the horizontal FOV.
 
xiiAngle 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.
 
xiiVec3 GetCenterPosition () const
 Returns the average camera position.
 
xiiVec3 GetCenterDirForwards () const
 Returns the average forwards vector.
 
xiiVec3 GetCenterDirUp () const
 Returns the average up vector.
 
xiiVec3 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 (xiiCameraMode::Enum mode, float fFovOrDim, float fNearPlane, float fFarPlane)
 Specifies the mode and the projection settings that this camera uses.
 
void SetStereoProjection (const xiiMat4 &mProjectionLeftEye, const xiiMat4 &mProjectionRightEye, float fAspectRatioWidthDivHeight)
 
float GetFovOrDim () const
 Returns the fFovOrDim parameter that was passed to SetCameraProjectionAndMode().
 
xiiCameraMode::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 xiiMat4 &mLookAtMatrix, xiiCameraEye eye=xiiCameraEye::Left)
 Sets the view matrix directly.
 
void LookAt (const xiiVec3 &vCameraPos, const xiiVec3 &vTargetPos, const xiiVec3 &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 (xiiAngle forwardAxis, xiiAngle rightAxis, xiiAngle axis)
 Rotates the camera around the forward, right and up axis in its own local space.
 
void RotateGlobally (xiiAngle forwardAxis, xiiAngle rightAxis, xiiAngle axis)
 Rotates the camera around the forward, right and up axis of the coordinate system in global space.
 
const xiiMat4GetViewMatrix (xiiCameraEye eye=xiiCameraEye::Left) const
 Returns the view matrix for the given eye.
 
void GetProjectionMatrix (float fAspectRatioWidthDivHeight, xiiMat4 &out_mProjectionMatrix, xiiCameraEye eye=xiiCameraEye::Left, xiiClipSpaceDepthRange::Enum depthRange=xiiClipSpaceDepthRange::Default) const
 Calculates the projection matrix from the current camera properties and stores it in out_projectionMatrix.
 
float GetExposure () const
 
void SetExposure (float fExposure)
 
xiiUInt32 GetSettingsModificationCounter () const
 Returns a counter that is increased every time the camera settings are modified.
 
xiiUInt32 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()

xiiVec3 xiiCamera::GetCenterDirForwards ( ) const
inline

Returns the average forwards vector.

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

◆ GetCenterDirRight()

xiiVec3 xiiCamera::GetCenterDirRight ( ) const
inline

Returns the average right vector.

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

◆ GetCenterDirUp()

xiiVec3 xiiCamera::GetCenterDirUp ( ) const
inline

Returns the average up vector.

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

◆ GetCenterPosition()

xiiVec3 xiiCamera::GetCenterPosition ( ) const
inline

Returns the average camera position.

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

◆ GetDimensionX()

float xiiCamera::GetDimensionX ( float fAspectRatioWidthDivHeight) const

Returns the horizontal dimension for an orthographic view.

Works only with xiiCameraMode::OrthoFixedWidth and xiiCameraMode::OrthoFixedWidth

◆ GetDimensionY()

float xiiCamera::GetDimensionY ( float fAspectRatioWidthDivHeight) const

Returns the vertical dimension for an orthographic view.

Works only with xiiCameraMode::OrthoFixedWidth and xiiCameraMode::OrthoFixedWidth

◆ GetFovX()

xiiAngle xiiCamera::GetFovX ( float fAspectRatioWidthDivHeight) const

Returns the horizontal FOV.

Works only with xiiCameraMode::PerspectiveFixedFovX and xiiCameraMode::PerspectiveFixedFovY

◆ GetFovY()

xiiAngle xiiCamera::GetFovY ( float fAspectRatioWidthDivHeight) const

Returns the vertical FOV.

Works only with xiiCameraMode::PerspectiveFixedFovX and xiiCameraMode::PerspectiveFixedFovY

◆ GetOrientationModificationCounter()

xiiUInt32 xiiCamera::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 xiiCamera::GetProjectionMatrix ( float fAspectRatioWidthDivHeight,
xiiMat4 & out_mProjectionMatrix,
xiiCameraEye eye = xiiCameraEye::Left,
xiiClipSpaceDepthRange::Enum depthRange = xiiClipSpaceDepthRange::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()

xiiUInt32 xiiCamera::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()

XII_ALWAYS_INLINE const xiiMat4 & xiiCamera::GetViewMatrix ( xiiCameraEye eye = xiiCameraEye::Left) const

Returns the view matrix for the given eye.

Note
The view matrix is given in OpenGL convention.

◆ LookAt()

void xiiCamera::LookAt ( const xiiVec3 & vCameraPos,
const xiiVec3 & vTargetPos,
const xiiVec3 & vUp )

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

Not supported for stereo cameras.

◆ MoveGlobally()

void xiiCamera::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 xiiCamera::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 xiiCamera::RotateGlobally ( xiiAngle forwardAxis,
xiiAngle rightAxis,
xiiAngle 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 xiiCamera::RotateLocally ( xiiAngle forwardAxis,
xiiAngle rightAxis,
xiiAngle 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 xiiCamera::SetCameraMode ( xiiCameraMode::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 xiiCamera::SetCoordinateSystem ( xiiBasisAxis::Enum forwardAxis,
xiiBasisAxis::Enum rightAxis,
xiiBasisAxis::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 xiiCamera::SetStereoProjection ( const xiiMat4 & mProjectionLeftEye,
const xiiMat4 & 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 xiiCamera::SetViewMatrix ( const xiiMat4 & mLookAtMatrix,
xiiCameraEye eye = xiiCameraEye::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: