Camera Class
Represents a camera for perspective projection. More...
Declaration
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... | |
| float | fovY () const noexcept |
|
Gets the current vertical field of view. More... | |
| float | aspectRatio () const noexcept |
|
Gets the current aspect ratio. More... | |
| float | zNear () const noexcept |
|
Gets the current near clipping plane distance. More... | |
| float | zFar () const noexcept |
|
Gets the current far clipping plane distance. More... | |
Protected Member Functions Index
| void | update () const |
|
Updates the view and projection matrices if needed. More... | |
Protected Member Attributes Index
| helios::math::mat4f | projectionMatrix_ |
|
The projection matrix of this camera. More... | |
| helios::math::mat4f | viewMatrix_ |
|
The view matrix of this camera. More... | |
| float | aspectRatio_ = 1.0f |
|
The aspect ratio of the camera (width/height). More... | |
| float | zNear_ = 0.1f |
|
The near clipping plane distance. More... | |
| float | zFar_ = 1000.0f |
|
The far clipping plane distance. More... | |
| float | fovY_ = helios::math::radians(90) |
|
The vertical field of view in radians. More... | |
| bool | needsUpdate_ = 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()
| 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()
| 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()
| 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()
| 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()
| 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()
| noexcept |
setPerspective()
| 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()
| 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.
Definition at line 123 of file Camera.ixx.
References Camera, setViewMatrix and viewMatrix.
Referenced by setViewMatrix.
setZFar()
| noexcept |
setZNear()
| noexcept |
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()
| 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()
| 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()
| 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.
References aspectRatio_, fovY_, needsUpdate_, helios::math::perspective, projectionMatrix_, zFar_ and zNear_.
Protected Member Attributes
aspectRatio_
| protected |
The aspect ratio of the camera (width/height).
Defaults to 1.0.
Definition at line 40 of file Camera.ixx.
Referenced by update.
fovY_
| 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_
| protected mutable |
Flag indicating whether the matrices need to be updated.
Definition at line 66 of file Camera.ixx.
Referenced by update.
projectionMatrix_
| protected mutable |
The projection matrix of this camera.
Definition at line 28 of file Camera.ixx.
Referenced by update.
viewMatrix_
| protected |
The view matrix of this camera.
Definition at line 33 of file Camera.ixx.
zFar_
| protected |
The far clipping plane distance.
Defaults to 1000.0.
Definition at line 54 of file Camera.ixx.
Referenced by update.
zNear_
| protected |
The near clipping plane distance.
Defaults to 0.1.
Definition at line 47 of file Camera.ixx.
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.