First-person camera managing view and projection matrices.
More...
#include <Camera.hpp>
|
| | Camera () |
| | Construct with default eye position, 60 degree FOV, and Quake-unit near/far.
|
| void | setAspect (float width, float height) |
| | Update aspect ratio from viewport dimensions and recompute projection.
|
| void | setFov (float fovyDegrees) |
| | Set vertical field of view in degrees and recompute projection.
|
| void | setZNear (float zNear) |
| | Set the near clip plane distance (Quake units) and recompute projection.
|
| void | setZFar (float zFar) |
| | Set the far clip plane distance (Quake units) and recompute projection.
|
| void | setEye (glm::vec3 eye) |
| | Set camera world-space position and recompute view matrix.
|
| void | setTarget (float pitch, float yaw, float roll) |
| | Set view direction from pitch, yaw, and roll (all radians).
|
| void | setUp (glm::vec3 up) |
| | Override the up direction explicitly.
|
| void | computeViewMatrix () |
| | Recompute the view matrix from current eye, target, and up.
|
| void | computeProjectionMatrix () |
| | Recompute the projection matrix from current FOV, aspect, near, far.
|
| const glm::mat4 & | getViewMatrix () const |
| const glm::mat4 & | getProjectionMatrix () const |
| const glm::vec3 & | getEye () const |
| const glm::vec3 | getRight () const |
| | Return the camera right vector (normalized cross of forward and up).
|
| const glm::vec3 | getForward () const |
| | Return the camera forward vector (normalized target - eye).
|
| const glm::vec3 & | getUp () const |
| glm::mat4 | getViewProjection () const |
| | Return the combined view-projection matrix.
|
| float | getFovy () const |
| | Return the vertical field of view in degrees.
|
| float | getAspect () const |
| | Return the aspect ratio (width / height).
|
| float | getNear () const |
| | Return the near clip plane distance.
|
| float | getFar () const |
| | Return the far clip plane distance.
|
| void | applySubpixelJitter (float jitterX, float jitterY) |
| | Apply a sub-pixel jitter offset to the projection matrix.
|
|
| glm::vec3 | eye_ {0.0f, 0.0f, 3.0f} |
| glm::vec3 | target_ {0.0f, 0.0f, 0.0f} |
| glm::vec3 | up_ {0.0f, 1.0f, 0.0f} |
| float | fovy_ = glm::radians(60.0f) |
| float | aspect_ = 1.0f |
| float | zNear_ = 5.0f |
| | Near clip (Quake units); 5 ≈ half a foot.
|
| float | zFar_ = 15000.0f |
| | Far clip; covers the 4 000-unit play area with margin.
|
| glm::mat4 | view_ {1.0f} |
| glm::mat4 | projection_ {1.0f} |
First-person camera managing view and projection matrices.
◆ Camera()
Construct with default eye position, 60 degree FOV, and Quake-unit near/far.
◆ applySubpixelJitter()
| void Camera::applySubpixelJitter |
( |
float | jitterX, |
|
|
float | jitterY ) |
Apply a sub-pixel jitter offset to the projection matrix.
Used by SMAA T2x temporal supersampling. Call after setAspect()/computeProjectionMatrix() so the base projection is established first. The offset is in NDC units (already scaled by 2/resolution).
- Parameters
-
| jitterX | Horizontal jitter in NDC. |
| jitterY | Vertical jitter in NDC. |
◆ computeProjectionMatrix()
| void Camera::computeProjectionMatrix |
( |
| ) |
|
Recompute the projection matrix from current FOV, aspect, near, far.
- Note
- Flips Y for Vulkan NDC convention.
◆ computeViewMatrix()
| void Camera::computeViewMatrix |
( |
| ) |
|
Recompute the view matrix from current eye, target, and up.
◆ getAspect()
| float Camera::getAspect |
( |
| ) |
const |
|
inlinenodiscard |
Return the aspect ratio (width / height).
◆ getEye()
| const glm::vec3 & Camera::getEye |
( |
| ) |
const |
|
inlinenodiscard |
◆ getFar()
| float Camera::getFar |
( |
| ) |
const |
|
inlinenodiscard |
Return the far clip plane distance.
◆ getForward()
| const glm::vec3 Camera::getForward |
( |
| ) |
const |
|
nodiscard |
Return the camera forward vector (normalized target - eye).
◆ getFovy()
| float Camera::getFovy |
( |
| ) |
const |
|
inlinenodiscard |
Return the vertical field of view in degrees.
Internally fovy_ is stored in radians (matches glm::perspective and setFov's conversion). Convert back here so the public API contract stays consistent with setFov(fovyDegrees).
◆ getNear()
| float Camera::getNear |
( |
| ) |
const |
|
inlinenodiscard |
Return the near clip plane distance.
◆ getProjectionMatrix()
| const glm::mat4 & Camera::getProjectionMatrix |
( |
| ) |
const |
|
inlinenodiscard |
◆ getRight()
| const glm::vec3 Camera::getRight |
( |
| ) |
const |
|
nodiscard |
Return the camera right vector (normalized cross of forward and up).
◆ getUp()
| const glm::vec3 & Camera::getUp |
( |
| ) |
const |
|
inlinenodiscard |
◆ getViewMatrix()
| const glm::mat4 & Camera::getViewMatrix |
( |
| ) |
const |
|
inlinenodiscard |
◆ getViewProjection()
| glm::mat4 Camera::getViewProjection |
( |
| ) |
const |
|
inlinenodiscard |
Return the combined view-projection matrix.
◆ setAspect()
| void Camera::setAspect |
( |
float | width, |
|
|
float | height ) |
Update aspect ratio from viewport dimensions and recompute projection.
- Parameters
-
| width | Viewport width in pixels. |
| height | Viewport height in pixels. |
◆ setEye()
| void Camera::setEye |
( |
glm::vec3 | eye | ) |
|
Set camera world-space position and recompute view matrix.
- Parameters
-
| eye | New camera position in world space. |
◆ setFov()
| void Camera::setFov |
( |
float | fovyDegrees | ) |
|
Set vertical field of view in degrees and recompute projection.
- Parameters
-
| fovyDegrees | Vertical FOV in degrees. |
◆ setTarget()
| void Camera::setTarget |
( |
float | pitch, |
|
|
float | yaw, |
|
|
float | roll ) |
Set view direction from pitch, yaw, and roll (all radians).
Roll rotates the up vector around the forward axis (wallrun tilt).
- Parameters
-
| pitch | Vertical angle in radians (positive looks down). |
| yaw | Horizontal angle in radians (0 faces +Z). |
| roll | Roll angle in radians for camera tilt. |
◆ setUp()
| void Camera::setUp |
( |
glm::vec3 | up | ) |
|
Override the up direction explicitly.
Useful for non-gravity-aligned orientations.
- Parameters
-
| up | New up direction vector. |
◆ setZFar()
| void Camera::setZFar |
( |
float | zFar | ) |
|
Set the far clip plane distance (Quake units) and recompute projection.
- Parameters
-
| zFar | Far clip plane distance. |
◆ setZNear()
| void Camera::setZNear |
( |
float | zNear | ) |
|
Set the near clip plane distance (Quake units) and recompute projection.
- Parameters
-
| zNear | Near clip plane distance. |
◆ aspect_
| float Camera::aspect_ = 1.0f |
|
private |
◆ eye_
| glm::vec3 Camera::eye_ {0.0f, 0.0f, 3.0f} |
|
private |
◆ fovy_
| float Camera::fovy_ = glm::radians(60.0f) |
|
private |
◆ projection_
| glm::mat4 Camera::projection_ {1.0f} |
|
private |
◆ target_
| glm::vec3 Camera::target_ {0.0f, 0.0f, 0.0f} |
|
private |
◆ up_
| glm::vec3 Camera::up_ {0.0f, 1.0f, 0.0f} |
|
private |
◆ view_
| glm::mat4 Camera::view_ {1.0f} |
|
private |
◆ zFar_
| float Camera::zFar_ = 15000.0f |
|
private |
Far clip; covers the 4 000-unit play area with margin.
◆ zNear_
| float Camera::zNear_ = 5.0f |
|
private |
Near clip (Quake units); 5 ≈ half a foot.
The documentation for this class was generated from the following files: