Ocean
GIView.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_GI_VIEW_H
9 #define META_OCEAN_RENDERING_GI_VIEW_H
10 
13 
15 #include "ocean/rendering/View.h"
16 
19 
20 namespace Ocean
21 {
22 
23 namespace Rendering
24 {
25 
26 namespace GlobalIllumination
27 {
28 
29 /**
30  * This class implements a Global Illumination view object.
31  * @ingroup renderinggi
32  */
33 class OCEAN_RENDERING_GI_EXPORT GIView :
34  virtual public GIObject,
35  virtual public View
36 {
37  friend class GIFramebuffer;
38 
39  public:
40 
41  /**
42  * Returns the aspect ratio of this view.
43  * @see View::aspectRatio().
44  */
45  Scalar aspectRatio() const override;
46 
47  /**
48  * Returns the distance to the near clipping plane.
49  * @see View::nearDistance().
50  */
51  Scalar nearDistance() const override;
52 
53  /**
54  * Returns the distance to the far clipping plane.
55  * @see View::farDistance().
56  */
57  Scalar farDistance() const override;
58 
59  /**
60  * Returns the view (extrinsic) matrix.
61  * @return View matrix
62  */
63  inline HomogenousMatrix4 matrix() const;
64 
65  /**
66  * Returns the inverted view (extrinsic) matrix.
67  * @return Inverted view matrix
68  */
69  inline HomogenousMatrix4 invertedMatrix() const;
70 
71  /**
72  * Returns the view projection matrix.
73  * @return Projection matrix
74  */
75  SquareMatrix4 projectionMatrix() const override;
76 
77  /**
78  * Returns the viewing matrix of the viewer as homogenous transformation.
79  * @see View::transformation().
80  */
82 
83  /**
84  * Returns the background color of the view.
85  * @see View::backgroundColor().
86  */
87  RGBAColor backgroundColor() const override;
88 
89  /**
90  * Returns whether the headlight is enabled.
91  * @see View::useHeadlight().
92  */
93  bool useHeadlight() const override;
94 
95  /**
96  * Returns the headlight object of this view
97  * @return Headlight object, if any
98  */
99  const LightSourceRef& headlight() const;
100 
101  /**
102  * Sets the aspect ration of the view.
103  * @param aspectRatio Rate between width and height
104  */
105  bool setAspectRatio(const Scalar aspectRatio) override;
106 
107  /**
108  * Sets the distance of the near clippling plane.
109  * @see View::setNearDistance().
110  */
111  bool setNearDistance(const Scalar distance) override;
112 
113  /**
114  * Sets the distance of the far clipping plane.
115  * @see View::setFarDistance().
116  */
117  bool setFarDistance(const Scalar distance) override;
118 
119  /**
120  * Sets the distance of the near and far clipping plane.
121  * @see View::setNearFarDistance().
122  */
123  bool setNearFarDistance(const Scalar nearDistance, const Scalar farDistance) override;
124 
125  /**
126  * Sets the position and orientation of the view by a viewing matrix.
127  * @see View::setTransformation().
128  */
129  void setTransformation(const HomogenousMatrix4& transformation) override;
130 
131  /**
132  * Sets the background color of the view.
133  * @see View::setBackgroundColor().
134  */
135  bool setBackgroundColor(const RGBAColor& color) override;
136 
137  /**
138  * Sets whether the headlight should be activated.
139  * @see View::setUseHeadlight().
140  */
141  void setUseHeadlight(const bool state) override;
142 
143  protected:
144 
145  /**
146  * Creates a new view object.
147  */
149 
150  /**
151  * Destructs a view object.
152  */
153  ~GIView() override;
154 
155  /**
156  * (Re-)calculates the view projection matrix.
157  */
158  virtual void calculateProjectionMatrix() = 0;
159 
160  protected:
161 
162  /// View projection matrix.
164 
165  /// View (extrinsic camera) matrix.
167 
168  /// Inverted view (extrinsic camera) matrix.
170 
171  /// View aspect ratio defined by (width / height).
173 
174  /// View near clipping plane.
176 
177  /// View far clipping plane.
179 
180  /// Holds the view background color.
182 
183  /// Determines whether the headlight is enabled.
185 
186  /// View headlight object.
188 };
189 
191 {
192  ocean_assert(viewMatrix == invertedViewMatrix.inverted());
193  return viewMatrix;
194 }
195 
197 {
198  ocean_assert(viewMatrix.inverted() == invertedViewMatrix);
199  return invertedViewMatrix;
200 }
201 
202 }
203 
204 }
205 
206 }
207 
208 #endif // META_OCEAN_RENDERING_GI_VIEW_H
HomogenousMatrixT4< T > inverted() const noexcept
Returns the inverted of this matrix.
Definition: HomogenousMatrix4.h:1575
This class implements a color defined by red, green, blue and alpha parameters.
Definition: RGBAColor.h:41
This class implements a base for all Global Illumination framebuffers.
Definition: GIFramebuffer.h:39
This class is the base class for all Global Illumination objects.
Definition: GIObject.h:29
This class implements a Global Illumination view object.
Definition: GIView.h:36
Scalar farDistance() const override
Returns the distance to the far clipping plane.
RGBAColor backgroundColor() const override
Returns the background color of the view.
~GIView() override
Destructs a view object.
Scalar viewNearDistance
View near clipping plane.
Definition: GIView.h:175
Scalar viewAspectRatio
View aspect ratio defined by (width / height).
Definition: GIView.h:172
SquareMatrix4 viewProjectionMatrix
View projection matrix.
Definition: GIView.h:163
bool setBackgroundColor(const RGBAColor &color) override
Sets the background color of the view.
HomogenousMatrix4 invertedMatrix() const
Returns the inverted view (extrinsic) matrix.
Definition: GIView.h:196
HomogenousMatrix4 viewMatrix
View (extrinsic camera) matrix.
Definition: GIView.h:166
bool setNearFarDistance(const Scalar nearDistance, const Scalar farDistance) override
Sets the distance of the near and far clipping plane.
bool setNearDistance(const Scalar distance) override
Sets the distance of the near clippling plane.
bool setFarDistance(const Scalar distance) override
Sets the distance of the far clipping plane.
const LightSourceRef & headlight() const
Returns the headlight object of this view.
HomogenousMatrix4 matrix() const
Returns the view (extrinsic) matrix.
Definition: GIView.h:190
virtual void calculateProjectionMatrix()=0
(Re-)calculates the view projection matrix.
Scalar aspectRatio() const override
Returns the aspect ratio of this view.
LightSourceRef viewHeadlight
View headlight object.
Definition: GIView.h:187
void setTransformation(const HomogenousMatrix4 &transformation) override
Sets the position and orientation of the view by a viewing matrix.
bool useHeadlight() const override
Returns whether the headlight is enabled.
SquareMatrix4 projectionMatrix() const override
Returns the view projection matrix.
RGBAColor viewBackgroundColor
Holds the view background color.
Definition: GIView.h:181
Scalar nearDistance() const override
Returns the distance to the near clipping plane.
void setUseHeadlight(const bool state) override
Sets whether the headlight should be activated.
bool setAspectRatio(const Scalar aspectRatio) override
Sets the aspect ration of the view.
bool viewUseHeadlight
Determines whether the headlight is enabled.
Definition: GIView.h:184
Scalar viewFarDistance
View far clipping plane.
Definition: GIView.h:178
HomogenousMatrix4 transformation() const override
Returns the viewing matrix of the viewer as homogenous transformation.
HomogenousMatrix4 invertedViewMatrix
Inverted view (extrinsic camera) matrix.
Definition: GIView.h:169
This class is the base class for all rendering views.
Definition: View.h:46
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15