Skip to main content

Camera Class

Represents a camera for perspective projection. More...

Declaration

class helios::scene::Camera { ... }

Public Constructors Index

Camera () noexcept

Constructs a camera with identity projection and view matrices. More...

Public Member Functions Index

const helios::math::mat4f &projectionMatrix () const noexcept

Gets the current projection matrix. More...

const helios::math::mat4f &viewMatrix () const noexcept

Gets the current view matrix. More...

Camera &setViewMatrix (const helios::math::mat4f &viewMatrix) noexcept

Sets the view matrix for this camera. More...

Camera &setAspectRatio (float aspectRatio) noexcept

Sets the aspect ratio used by the camera. More...

Camera &setPerspective (float fovY, float aspectRatio, float zNear, float zFar) noexcept

Sets the perspective projection parameters. More...

Camera &setZNear (float zNear) noexcept

Sets the near clipping plane distance. More...

Camera &setZFar (float zFar) noexcept

Sets the far clipping plane distance. More...

Camera &setFovY (float fovY) noexcept

Sets the vertical field of view. More...

floatfovY () const noexcept

Gets the current vertical field of view. More...

floataspectRatio () const noexcept

Gets the current aspect ratio. More...

floatzNear () const noexcept

Gets the current near clipping plane distance. More...

floatzFar () const noexcept

Gets the current far clipping plane distance. More...

Protected Member Functions Index

voidupdate () const

Updates the view and projection matrices if needed. More...

Protected Member Attributes Index

helios::math::mat4fprojectionMatrix_

The projection matrix of this camera. More...

helios::math::mat4fviewMatrix_

The view matrix of this camera. More...

floataspectRatio_ = 1.0f

The aspect ratio of the camera (width/height). More...

floatzNear_ = 0.1f

The near clipping plane distance. More...

floatzFar_ = 1000.0f

The far clipping plane distance. More...

floatfovY_ = helios::math::radians(90)

The vertical field of view in radians. More...

boolneedsUpdate_ = true

Flag indicating whether the matrices need to be updated. More...

Description

Represents a camera for perspective projection.

The camera provides the view and projection matrices, whereas the view matrix is computed as the inverse of the camera's world transform.

Definition at line 22 of file Camera.ixx.

Public Constructors

Camera()

helios::scene::Camera::Camera ()
noexcept

Constructs a camera with identity projection and view matrices.

Definition at line 91 of file Camera.ixx.

Referenced by setAspectRatio, setFovY, setPerspective, setViewMatrix, setZFar and setZNear.

Public Member Functions

aspectRatio()

float helios::scene::Camera::aspectRatio ()
nodiscard noexcept

Gets the current aspect ratio.

Returns

The aspect ratio (width/height).

Definition at line 185 of file Camera.ixx.

Reference aspectRatio.

Referenced by aspectRatio, setAspectRatio and setPerspective.

fovY()

float helios::scene::Camera::fovY ()
nodiscard noexcept

Gets the current vertical field of view.

Returns

The vertical field of view in radians.

Definition at line 178 of file Camera.ixx.

Reference fovY.

Referenced by fovY, setFovY and setPerspective.

projectionMatrix()

const helios::math::mat4f & helios::scene::Camera::projectionMatrix ()
nodiscard noexcept

Gets the current projection matrix.

Typically set to a perspective or orthographic projection.

Returns

A const reference to this camera's projection matrix.

Definition at line 100 of file Camera.ixx.

Reference projectionMatrix.

Referenced by projectionMatrix.

setAspectRatio()

Camera & helios::scene::Camera::setAspectRatio (float aspectRatio)
noexcept

Sets the aspect ratio used by the camera.

Parameters
aspectRatio

The new aspect ratio (width/height).

Returns

A reference to this camera instance.

Definition at line 132 of file Camera.ixx.

References aspectRatio, Camera and setAspectRatio.

Referenced by setAspectRatio.

setFovY()

Camera & helios::scene::Camera::setFovY (float fovY)
noexcept

Sets the vertical field of view.

Parameters
fovY

The new vertical field of view in radians.

Returns

A reference to this camera instance.

Definition at line 171 of file Camera.ixx.

References Camera, fovY and setFovY.

Referenced by setFovY.

setPerspective()

Camera & helios::scene::Camera::setPerspective (float fovY, float aspectRatio, float zNear, float zFar)
noexcept

Sets the perspective projection parameters.

Parameters
fovY

The vertical field of view in radians.

aspectRatio

The aspect ratio (width/height).

zNear

The near clipping plane distance.

zFar

The far clipping plane distance.

Returns

A reference to this camera instance.

Definition at line 144 of file Camera.ixx.

References aspectRatio, Camera, fovY, setPerspective, zFar and zNear.

Referenced by setPerspective.

setViewMatrix()

Camera & helios::scene::Camera::setViewMatrix (const helios::math::mat4f & viewMatrix)
noexcept

Sets the view matrix for this camera.

This method is typically called by `CameraSceneNode::worldTransform()` to update the view matrix based on the camera node's position and orientation in the scene graph.

Parameters
viewMatrix

The new view matrix to assign.

Returns

A const reference to this camera instance.

See Also

helios::scene::CameraSceneNode::worldTransform()

Definition at line 123 of file Camera.ixx.

References Camera, setViewMatrix and viewMatrix.

Referenced by setViewMatrix.

setZFar()

Camera & helios::scene::Camera::setZFar (float zFar)
noexcept

Sets the far clipping plane distance.

Parameters
zFar

The new far clipping plane distance.

Returns

A reference to this camera instance.

Definition at line 162 of file Camera.ixx.

References Camera, setZFar and zFar.

Referenced by setZFar.

setZNear()

Camera & helios::scene::Camera::setZNear (float zNear)
noexcept

Sets the near clipping plane distance.

Parameters
zNear

The new near clipping plane distance.

Returns

A reference to this camera instance.

Definition at line 153 of file Camera.ixx.

References Camera, setZNear and zNear.

Referenced by setZNear.

viewMatrix()

const helios::math::mat4f & helios::scene::Camera::viewMatrix ()
nodiscard noexcept

Gets the current view matrix.

The view matrix represents the inverse of the camera's world transform.

Returns

A const reference to this camera's view matrix.

Definition at line 109 of file Camera.ixx.

Reference viewMatrix.

Referenced by setViewMatrix and viewMatrix.

zFar()

float helios::scene::Camera::zFar ()
nodiscard noexcept

Gets the current far clipping plane distance.

Returns

The far clipping plane distance.

Definition at line 199 of file Camera.ixx.

Reference zFar.

Referenced by setPerspective, setZFar and zFar.

zNear()

float helios::scene::Camera::zNear ()
nodiscard noexcept

Gets the current near clipping plane distance.

Returns

The near clipping plane distance.

Definition at line 192 of file Camera.ixx.

Reference zNear.

Referenced by setPerspective, setZNear and zNear.

Protected Member Functions

update()

void helios::scene::Camera::update ()
inline protected

Updates the view and projection matrices if needed.

This function recalculates the view and projection matrices based on the current camera parameters.

Definition at line 76 of file Camera.ixx.

76 void update() const {
77
78 if (!needsUpdate_) {
79 return;
80 }
81
83
84 needsUpdate_ = false;
85 }

References aspectRatio_, fovY_, needsUpdate_, helios::math::perspective, projectionMatrix_, zFar_ and zNear_.

Protected Member Attributes

aspectRatio_

float helios::scene::Camera::aspectRatio_ = 1.0f
protected

The aspect ratio of the camera (width/height).

Defaults to 1.0.

Definition at line 40 of file Camera.ixx.

40 float aspectRatio_ = 1.0f;

Referenced by update.

fovY_

float helios::scene::Camera::fovY_ = helios::math::radians(90)
protected

The vertical field of view in radians.

Defaults to 90 degrees (converted to radians).

Definition at line 61 of file Camera.ixx.

Referenced by update.

needsUpdate_

bool helios::scene::Camera::needsUpdate_ = true
protected mutable

Flag indicating whether the matrices need to be updated.

Definition at line 66 of file Camera.ixx.

66 mutable bool needsUpdate_ = true;

Referenced by update.

projectionMatrix_

helios::math::mat4f helios::scene::Camera::projectionMatrix_
protected mutable

The projection matrix of this camera.

Definition at line 28 of file Camera.ixx.

Referenced by update.

viewMatrix_

helios::math::mat4f helios::scene::Camera::viewMatrix_
protected

The view matrix of this camera.

Definition at line 33 of file Camera.ixx.

zFar_

float helios::scene::Camera::zFar_ = 1000.0f
protected

The far clipping plane distance.

Defaults to 1000.0.

Definition at line 54 of file Camera.ixx.

54 float zFar_ = 1000.0f;

Referenced by update.

zNear_

float helios::scene::Camera::zNear_ = 0.1f
protected

The near clipping plane distance.

Defaults to 0.1.

Definition at line 47 of file Camera.ixx.

47 float zNear_ = 0.1f;

Referenced by update.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.