Skip to main content

PerspectiveCameraComponent.ixx File

Stores perspective projection parameters for a camera entity. More...

Included Headers

#include <cassert> #include <helios.math>

Namespaces Index

namespacehelios
namespaceengine
namespacescene
namespacecomponents

Classes Index

classPerspectiveCameraComponent<THandle>

Component that stores perspective camera projection parameters. More...

Description

Stores perspective projection parameters for a camera entity.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <cassert>
8
9export module helios.engine.scene.components.PerspectiveCameraComponent;
10
11
12import helios.math;
13
14using namespace helios::math;
16
22 template<typename THandle>
24
30 float aspectRatio_ = 1.0f;
31
37 float zNear_ = 0.1f;
38
44 float zFar_ = 1000.0f;
45
51 float fovY_ = radians(90);
52
56 bool isDirty_ = true;
57 public:
58
59
60 explicit PerspectiveCameraComponent(const float fovY, const float aspectRatio, const float zNear = 0.1f, const float zFar = 1000.0f) {
62 }
63
72 void setPerspective(const float fovY, const float aspectRatio, const float zNear, const float zFar) noexcept {
73 assert(zNear > 0 && "zNear must be positive");
74 assert(zFar > 0 && zFar > zNear && "zFar must be positive and greater than zNear");
75 fovY_ = fovY;
76 aspectRatio_ = aspectRatio;
77 zNear_ = zNear;
78 zFar_ = zFar;
79 isDirty_ = true;
80 }
81
87 void setZNear(const float zNear) noexcept {
88 assert(zNear > 0 && "zNear must be positive");
89 zNear_ = zNear;
90
91 isDirty_ = true;
92 }
93
99 void setZFar(const float zFar) noexcept {
100 assert(zFar > 0 && "zFar must be positive and greater than zNear");
101 zFar_ = zFar;
102 isDirty_ = true;
103 }
104
110 void setFovY(const float fovY) noexcept {
111 fovY_ = fovY;
112 isDirty_ = true;
113 }
114
120 void setAspectRatio(const float aspectRatio) noexcept {
121 aspectRatio_ = aspectRatio;
122 }
123
124
131 return fovY_;
132 }
133
140 return aspectRatio_;
141 }
142
149 return zNear_;
150 }
151
158 return zFar_;
159 }
160
167 return isDirty_;
168 }
169
174 isDirty_ = false;
175 }
176
177 };
178
179}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.