Skip to content

Camera

Abstract base class for camera types.

This class is not intended to be used directly. Use PerspectiveCamera or OrthographicCamera unless you are defining your own camera, in which case it should inherit from this class.

INFO

Derives from Node and inherits all public properties and methods.

Properties

projection_matrix Matrix4

Projection matrix that maps camera-space coordinates to clip space.

cpp
Matrix4 projection_matrix {Matrix4::Identity()};

view_matrix Matrix4

View matrix that maps world space to camera space.

cpp
Matrix4 view_matrix {Matrix4::Identity()};

Functions

Forward() Vector3

Camera forward axis in world space.

cpp
Vector3 Camera::Forward();

GetFrustum() Frustum

Computes a Frustum from the combined projection and view matrices.

Used for applying frustum culling to renderable nodes.

cpp
Frustum Camera::GetFrustum();

GetNodeType() Node::Type virtual

Identifies this node as Node::Type::Camera.

cpp
Type vglx::Camera::GetNodeType() const override;

LookAt() void virtual

Overrides Node::LookAt to orient the camera toward a world-space target.

Accounts for the camera’s -Z viewing direction so the camera faces the given point.

cpp
void Camera::LookAt(const Vector3& target) override;
ParameterDescription
targetWorld-space position for the camera to look at.

Resize() void pure virtual

Updates projection_matrix to reflect the current viewport size.

Must be implemented by derived cameras to apply the appropriate projection logic.

cpp
virtual void Camera::Resize(int width, int height)=0;
ParameterDescription
widthViewport width in pixels.
heightViewport height in pixels.

Right() Vector3

Camera right axis in world space.

cpp
Vector3 Camera::Right();

Camera up axis in world space.

cpp
Vector3 Camera::Up();

UpdateViewMatrix() void

Sets view_matrix to the inverse of the camera's world transform.

Called internally by the renderer before rendering a frame; manual calls are rarely necessary.

cpp
void Camera::UpdateViewMatrix();

Released under the MIT License.