Ocean
GLESView.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_GLES_VIEW_H
9 #define META_OCEAN_RENDERING_GLES_VIEW_H
10 
13 
15 #include "ocean/rendering/View.h"
16 
17 
18 namespace Ocean
19 {
20 
21 namespace Rendering
22 {
23 
24 namespace GLESceneGraph
25 {
26 
27 /**
28  * This class implements a GLESceneGraph view object.
29  * @ingroup renderinggles
30  */
31 class OCEAN_RENDERING_GLES_EXPORT GLESView :
32  virtual public GLESObject,
33  virtual public View
34 {
35  friend class GLESFramebuffer;
36 
37  public:
38 
39  /**
40  * Returns the aspect ratio of this view.
41  * @see View::aspectRatio().
42  */
43  Scalar aspectRatio() const override;
44 
45  /**
46  * Returns the distance to the near clipping plane.
47  * @see View::nearDistance().
48  */
49  Scalar nearDistance() const override;
50 
51  /**
52  * Returns the distance to the far clipping plane.
53  * @see View::farDistance().
54  */
55  Scalar farDistance() const override;
56 
57  /**
58  * Returns the view projection matrix.
59  * @return Projection matrix
60  */
61  SquareMatrix4 projectionMatrix() const override;
62 
63  /**
64  * Returns the transformation between view and world (the inverse of the known View Matrix).
65  * @see View::transformation().
66  */
68 
69  /**
70  * Returns the background color of the view.
71  * @see View::backgroundColor().
72  */
73  RGBAColor backgroundColor() const override;
74 
75  /**
76  * Returns whether the headlight is enabled.
77  * @see View::useHeadlight().
78  */
79  bool useHeadlight() const override;
80 
81  /**
82  * Returns the headlight object of this view
83  * @return Headlight object, if any
84  */
85  const LightSourceRef& headlight() const;
86 
87  /**
88  * Sets the aspect ratio of this view.
89  * @param aspectRatio Rate between width and height
90  */
91  bool setAspectRatio(const Scalar aspectRatio) override;
92 
93  /**
94  * Sets the distance to the near clippling plane.
95  * @see View::setNearDistance().
96  */
97  bool setNearDistance(const Scalar distance) override;
98 
99  /**
100  * Sets the distance to the far clipping plane.
101  * @see View::setFarDistance().
102  */
103  bool setFarDistance(const Scalar distance) override;
104 
105  /**
106  * Sets the distance to the near and far clipping plane.
107  * @see View::setNearFarDistance().
108  */
109  bool setNearFarDistance(const Scalar nearDistance, const Scalar farDistance) override;
110 
111  /**
112  * Sets the position and orientation of the view by a viewing matrix.
113  * @see View::setTransformation().
114  */
115  void setTransformation(const HomogenousMatrix4& transformation) override;
116 
117  /**
118  * Sets the background color of the view.
119  * @see View::setBackgroundColor().
120  */
121  bool setBackgroundColor(const RGBAColor& color) override;
122 
123  /**
124  * Sets whether the headlight should be activated.
125  * @see View::setUseHeadlight().
126  */
127  void setUseHeadlight(const bool state) override;
128 
129  /**
130  * Sets the phantom mode of this view.
131  * @see View::setPhantomMode().
132  */
134 
135  /**
136  * Returns the phantom mode of this view.
137  * @return Phantom mode
138  * @exception NotSupportedException Is thrown if this function is not supported
139  * @see setPhantomMode().
140  */
142 
143  protected:
144 
145  /**
146  * Creates a new view object.
147  */
149 
150  /**
151  * Destructs a view object.
152  */
153  ~GLESView() override;
154 
155  /**
156  * (Re-)calculates the view projection matrix.
157  * @return True, if succeeded
158  */
160 
161  protected:
162 
163  /// The view's projection matrix, which is clip_T_view
164  SquareMatrix4 clip_T_view_ = SquareMatrix4(false);
165 
166  /// The transformation between view and world.
167  HomogenousMatrix4 world_T_view_ = HomogenousMatrix4(true);
168 
169  /// Thew view's aspect ratio defined by the ratio between width and height, with range (0, infinity)
170  Scalar aspectRatio_ = Scalar(1);
171 
172  /// The view's near clipping plane, with range (0, farDistance_)
173  Scalar nearDistance_ = Scalar(0.01);
174 
175  /// The view's far clipping plane, with range (nearDistance_, infinity)
176  Scalar farDistance_ = Scalar(1000);
177 
178  /// The view's background color.
179  RGBAColor backgroundColor_ = RGBAColor(0.0f, 0.0f, 0.0f);
180 
181  /// True, if the view's headlight is enabled.
182  bool useHeadlight_ = true;
183 
184  /// Thew view's headlight object.
186 
187  /// The phantom mode which is used in this view.
189 };
190 
191 }
192 
193 }
194 
195 }
196 
197 #endif // META_OCEAN_RENDERING_GLES_VIEW_H
This class implements a color defined by red, green, blue and alpha parameters.
Definition: RGBAColor.h:41
This class implements a base for all GLESceneGraph framebuffers.
Definition: rendering/glescenegraph/GLESFramebuffer.h:34
This class is the base class for all GLESceneGraph objects.
Definition: GLESObject.h:57
This class implements a GLESceneGraph view object.
Definition: GLESView.h:34
Scalar aspectRatio() const override
Returns the aspect ratio of this view.
RGBAColor backgroundColor() const override
Returns the background color of the view.
HomogenousMatrix4 transformation() const override
Returns the transformation between view and world (the inverse of the known View Matrix).
bool setPhantomMode(const PhantomAttribute::PhantomMode mode) override
Sets the phantom mode of this view.
bool setNearDistance(const Scalar distance) override
Sets the distance to the near clippling plane.
Scalar farDistance() const override
Returns the distance to the far clipping plane.
GLESView()
Creates a new view object.
LightSourceRef headlight_
Thew view's headlight object.
Definition: GLESView.h:185
bool setAspectRatio(const Scalar aspectRatio) override
Sets the aspect ratio of this view.
void setTransformation(const HomogenousMatrix4 &transformation) override
Sets the position and orientation of the view by a viewing matrix.
Scalar nearDistance() const override
Returns the distance to the near clipping plane.
bool useHeadlight() const override
Returns whether the headlight is enabled.
virtual bool calculateProjectionMatrix()
(Re-)calculates the view projection matrix.
PhantomAttribute::PhantomMode phantomMode() const override
Returns the phantom mode of this view.
bool setBackgroundColor(const RGBAColor &color) override
Sets the background color of the view.
SquareMatrix4 projectionMatrix() const override
Returns the view projection matrix.
bool setFarDistance(const Scalar distance) override
Sets the distance to the far clipping plane.
bool setNearFarDistance(const Scalar nearDistance, const Scalar farDistance) override
Sets the distance to the near and far clipping plane.
void setUseHeadlight(const bool state) override
Sets whether the headlight should be activated.
const LightSourceRef & headlight() const
Returns the headlight object of this view.
~GLESView() override
Destructs a view object.
PhantomMode
Definition of different phantom modes.
Definition: PhantomAttribute.h:43
@ PM_DEFAULT
Default phantom mode.
Definition: PhantomAttribute.h:47
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
SquareMatrixT4< Scalar > SquareMatrix4
Definition of the SquareMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition: SquareMatrix4.h:32
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15