Nebula
Loading...
Searching...
No Matches
camerasettings.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
12#include "math/mat4.h"
13#include "math/vec2.h"
14#include "math/frustum.h"
15
16//------------------------------------------------------------------------------
17namespace Graphics
18{
20{
21public:
24
26 void SetupPerspectiveFov(float fov, float aspect, float zNear, float zFar);
28 void SetupOrthogonal(float w, float h, float zNear, float zFar);
29
31 const Math::mat4& GetProjTransform() const;
33 const Math::mat4& GetInvProjTransform() const;
35 const Math::vec2& GetFocalLength() const;
36
38 bool IsPerspective() const;
40 bool IsOrthogonal() const;
42 float GetZNear() const;
44 float GetZFar() const;
46 float GetFov() const;
48 float GetAspect() const;
50 float GetNearWidth() const;
52 float GetNearHeight() const;
54 float GetFarWidth() const;
56 float GetFarHeight() const;
57
58private:
59
62
63 bool isPersp;
64 float zNear;
65 float zFar;
66 float fov;
67 float aspect;
68 float nearWidth;
70 float farWidth;
71 float farHeight;
73};
74
75//------------------------------------------------------------------------------
78inline const Math::mat4&
80{
81 return this->projMatrix;
82}
83
84//------------------------------------------------------------------------------
87inline const Math::mat4&
89{
90 return this->invProjMatrix;
91}
92
93//------------------------------------------------------------------------------
96inline bool
98{
99 return this->isPersp;
100}
101
102//------------------------------------------------------------------------------
105inline bool
107{
108 return !this->isPersp;
109}
110
111//------------------------------------------------------------------------------
114inline float
116{
117 return this->zNear;
118}
119
120//------------------------------------------------------------------------------
123inline float
125{
126 return this->zFar;
127}
128
129//------------------------------------------------------------------------------
132inline float
134{
135 return this->fov;
136}
137
138//------------------------------------------------------------------------------
141inline float
143{
144 return this->aspect;
145}
146
147//------------------------------------------------------------------------------
150inline float
152{
153 return this->nearWidth;
154}
155
156//------------------------------------------------------------------------------
159inline float
161{
162 return this->nearHeight;
163}
164
165//------------------------------------------------------------------------------
168inline float
170{
171 return this->farWidth;
172}
173
174//------------------------------------------------------------------------------
177inline float
179{
180 return this->farHeight;
181}
182
183//------------------------------------------------------------------------------
186inline const Math::vec2&
188{
189 return this->focalLength;
190}
191
192} // namespace Graphics
193//------------------------------------------------------------------------------
194
Definition camerasettings.h:20
const Math::mat4 & GetInvProjTransform() const
get the inverse projection matrix
Definition camerasettings.h:88
float zNear
Definition camerasettings.h:64
const Math::vec2 & GetFocalLength() const
get focal length (computed from fov and aspect ratio)
Definition camerasettings.h:187
const Math::mat4 & GetProjTransform() const
get projection matrix
Definition camerasettings.h:79
float GetFarHeight() const
get height of far plane
Definition camerasettings.h:178
bool isPersp
Definition camerasettings.h:63
float nearWidth
Definition camerasettings.h:68
Math::mat4 projMatrix
Definition camerasettings.h:60
float farWidth
Definition camerasettings.h:70
float aspect
Definition camerasettings.h:67
bool IsPerspective() const
return true if this is a perspective projection
Definition camerasettings.h:97
void SetupPerspectiveFov(float fov, float aspect, float zNear, float zFar)
setup a perspective view volume
Definition camerasettings.cc:32
float GetZFar() const
get far plane distance
Definition camerasettings.h:124
Math::mat4 invProjMatrix
Definition camerasettings.h:61
float GetNearHeight() const
get height of near plane
Definition camerasettings.h:160
float GetFarWidth() const
get width of far plane
Definition camerasettings.h:169
float zFar
Definition camerasettings.h:65
Math::vec2 focalLength
Definition camerasettings.h:72
void SetupOrthogonal(float w, float h, float zNear, float zFar)
setup an orthogonal projection transform
Definition camerasettings.cc:63
float GetNearWidth() const
get width of near plane
Definition camerasettings.h:151
float GetFov() const
get field-of-view (only if perspective)
Definition camerasettings.h:133
float farHeight
Definition camerasettings.h:71
float GetAspect() const
get aspect ration (only if perspective)
Definition camerasettings.h:142
float GetZNear() const
get near plane distance
Definition camerasettings.h:115
CameraSettings()
default constructor
Definition camerasettings.cc:19
float fov
Definition camerasettings.h:66
bool IsOrthogonal() const
return true if this is an orthogonal transform
Definition camerasettings.h:106
float nearHeight
Definition camerasettings.h:69
Implements the shader server used by Vulkan.
Definition cameramanager.h:21
A 4x4 single point precision float matrix.
Definition mat4.h:47
A 2-component float vector class.
Definition vec2.h:21