Camera.ixx File
Defines the Camera class providing view and projection matrices. More...
Included Headers
#include <cassert>
#include <helios.scene.SceneNode>
#include <helios.math.types>
#include <helios.math.transform>
#include <helios.math.utils>
Namespaces Index
| namespace | helios |
| namespace | scene |
Classes Index
| class | Camera |
|
Represents a camera for perspective or orthographic projection. More... | |
Description
Defines the Camera class providing view and projection matrices.
File Listing
The file content with the documentation metadata removed is:
16export namespace helios::scene {
50 mutable helios::math::mat4f perspectiveMatrix_;
57 mutable helios::math::mat4f orthographicMatrix_;
69 float aspectRatio_ = 1.0f;
90 float fovY_ = helios::math::radians(90);
95 mutable bool needsUpdate_ = true;
123 bool usePerspective_ = true;
133 if (!needsUpdate_) {
137 if (usePerspective_) {
140 orthographicMatrix_ = helios::math::ortho(left_, right_, bottom_, top_, zNear_, zFar_);
143 needsUpdate_ = false;
151 perspectiveMatrix_(helios::math::mat4f::identity()),
152 orthographicMatrix_(helios::math::mat4f::identity()),
153 viewMatrix_(helios::math::mat4f::identity())
163 [[nodiscard]] const helios::math::mat4f& projectionMatrix() const noexcept {
164 update();
166 if (usePerspective_) {
167 return perspectiveMatrix_;
169 return orthographicMatrix_;
180 [[nodiscard]] const helios::math::mat4f& viewMatrix() const noexcept {
181 return viewMatrix_;
196 Camera& setViewMatrix(const helios::math::mat4f& viewMatrix) noexcept {
197 viewMatrix_ = viewMatrix;
208 Camera& setAspectRatio(float aspectRatio) noexcept {
209 needsUpdate_ = true;
210 aspectRatio_ = aspectRatio;
227 if (usePerspective_) {
228 setAspectRatio(width / height);
233 right_ = width;
234 top_ = height;
237 left_ = -width/2.0f;
238 right_ = width/2.0f;
239 bottom_ = -height/2.0f;
240 top_ = height/2.0f;
243 needsUpdate_ = true;
256 Camera& setPerspective(float fovY, float aspectRatio, float zNear, float zFar) noexcept {
257 assert(zNear > 0 && "zNear must be positive");
260 aspectRatio_ = aspectRatio;
263 needsUpdate_ = true;
264 usePerspective_ = true;
296 left_ = left;
297 right_ = right;
298 bottom_ = bottom;
299 top_ = top;
301 aspectRatio_ = (right - left) / (top - bottom); // w/h
303 usePerspective_ = false;
305 needsUpdate_ = true;
318 needsUpdate_ = true;
331 needsUpdate_ = true;
344 needsUpdate_ = true;
354 return fovY_;
362 [[nodiscard]] float aspectRatio() const noexcept {
363 return aspectRatio_;
372 return zNear_;
381 return zFar_;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.