Ocean
VertexSet.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_VERTEX_SET_H
9 #define META_OCEAN_RENDERING_VERTEX_SET_H
10 
12 #include "ocean/rendering/Object.h"
14 
15 #include "ocean/math/RGBAColor.h"
16 
17 namespace Ocean
18 {
19 
20 namespace Rendering
21 {
22 
23 // Forward declaration
24 class VertexSet;
25 
26 /**
27  * Definition of a smart object reference holding a vertex set node.
28  * @see SmartObjectRef, VertexSet.
29  * @ingroup rendering
30  */
32 
33 /**
34  * This class is the base class for all rendering vertex sets.
35  * A vertex set holds vertices, normals, texture coordinates and color values.<br>
36  * A vertex set must define vertices to be valid, normals, texture coordinates and color values are optional.<br>
37  * All elements of a vertex set are one by one mapping elements.<br>
38  * Meaning that e.g. the first vertex corresponds to the first normal or the first color value, the second to the second and so on.<br>
39  * However, a vertex set does not define the topology of a mesh.<br>
40  * Therefore, a vertex set has to be used in combination with primitive objects like e.g. triangles or triangle strips objects.<br>
41  * A vertex set can be used in combination with different primitive objects.<br>
42  * Beware: Once e.g. normals are defined make sure that the number of defined normals is equal to or larger than the number of vertices.<br>
43  * @see Triangles, TriangleFans, TriangleStrips, Quads, QuadStrips, Vertices, Normals, TextureCoordinates, RGBAColors.
44  * @ingroup rendering
45  */
46 class OCEAN_RENDERING_EXPORT VertexSet : virtual public Object
47 {
48  public:
49 
50  /**
51  * Returns the normals of this set.
52  * @return Normals
53  * @exception NotSupportedException Is thrown if this function is not supported
54  */
55  virtual Normals normals() const;
56 
57  /**
58  * Returns the texture coordinates of this set.
59  * @param layerIndex Index of the texture layer to receive the coordinates for
60  * @return Texture coordinates
61  * @exception NotSupportedException Is thrown if this function is not supported
62  */
63  virtual TextureCoordinates textureCoordinates(const unsigned int layerIndex) const;
64 
65  /**
66  * Returns the explicit reference coordinate system of the phantom object, if any.
67  * @return The name of the reference coordinate system
68  */
69  virtual std::string phantomTextureCoordinateSystem() const;
70 
71  /**
72  * Returns the vertices of this set.
73  * @return Vertices
74  * @exception NotSupportedException Is thrown if this function is not supported
75  */
76  virtual Vertices vertices() const;
77 
78  /**
79  * Returns the colors of this set.
80  * @return Colors
81  * @exception NotSupportedException Is thrown if this function is not supported
82  */
83  virtual RGBAColors colors() const;
84 
85  /**
86  * Returns the number of normals of this set.
87  * @return Number of normals
88  * @exception NotSupportedException Is thrown if this function is not supported
89  */
90  virtual unsigned int numberNormals() const;
91 
92  /**
93  * Returns the number of texture coordinates of this set.
94  * @param layerIndex Index of the texture layer to receive the coordinate number for
95  * @return Number of texture coordinates
96  * @exception NotSupportedException Is thrown if this function is not supported
97  */
98  virtual unsigned int numberTextureCoordinates(const unsigned int layerIndex) const;
99 
100  /**
101  * Returns the number of vertices of this set.
102  * @return Number of vertices
103  * @exception NotSupportedException Is thrown if this function is not supported
104  */
105  virtual unsigned int numberVertices() const;
106 
107  /**
108  * Returns the number of colors of this set.
109  * @return Number of colors
110  * @exception NotSupportedException Is thrown if this function is not supported
111  */
112  virtual unsigned int numberColors() const;
113 
114  /**
115  * Sets the normals for this set.
116  * @param normals New normals to set
117  * @exception NotSupportedException Is thrown if this function is not supported
118  */
119  virtual void setNormals(const Normals& normals);
120 
121  /**
122  * Sets the normals for this set.
123  * @param normals New normals to set, nullptr to reset previously set normals
124  * @param size The number of normals to set, with range [0, infinity)
125  * @exception NotSupportedException Is thrown if this function is not supported
126  */
127  virtual void setNormals(const Vector3* normals, const size_t size);
128 
129  /**
130  * Sets the texels for this set.
131  * @param textureCoordinates New texture coordinates to set
132  * @param layerIndex Index of the texture layer to set the coordinates for
133  * @exception NotSupportedException Is thrown if this function is not supported
134  */
135  virtual void setTextureCoordinates(const TextureCoordinates& textureCoordinates, const unsigned int layerIndex);
136 
137  /**
138  * Sets 3D texels for this set used for phantom objects.
139  * @param textureCoordinates New 3D texture coordinate to set
140  * @param layerIndex Index of the 3D phantom texture layer to set the coordinates for
141  * @exception NotSupportedException Is thrown if this function is not supported
142  */
143  virtual void setPhantomTextureCoordinates(const Vertices& textureCoordinates, const unsigned int layerIndex);
144 
145  /**
146  * Sets the explicit reference coordinate system of the phantom objects.
147  * @param reference The reference coordinate system to be used for the phantom texture coordinates
148  * @exception NotSupportedException Is thrown if this function is not supported
149  */
150  virtual void setPhantomTextureCoordinateSystem(const std::string& reference);
151 
152  /**
153  * Sets the vertices for this set.
154  * @param vertices New vertices to set
155  * @exception NotSupportedException Is thrown if this function is not supported
156  */
157  virtual void setVertices(const Vertices& vertices);
158 
159  /**
160  * Sets the vertices for this set.
161  * @param vertices New vertices to set, nullptr to reset previously set vertices
162  * @param size The number of vertices to set, with range [0, infinity)
163  * @exception NotSupportedException Is thrown if this function is not supported
164  */
165  virtual void setVertices(const Vector3* vertices, const size_t size);
166 
167  /**
168  * Sets the colors for this set.
169  * @param colors New colors to set
170  * @exception NotSupportedException Is thrown if this function is not supported
171  */
172  virtual void setColors(const RGBAColors& colors);
173 
174  /**
175  * Sets several attributes concurrently.
176  * @param vertices New vertices to set
177  * @param normals New normals to set
178  * @param textureCoordinates New texture coordinates for the first texture layer to set
179  * @param colors New colors to set
180  * @exception NotSupportedException Is thrown if this function is not supported
181  */
182  virtual void set(const Vertices& vertices, const Normals& normals, const TextureCoordinates& textureCoordinates, const RGBAColors& colors);
183 
184  /**
185  * Returns the type of this object.
186  * @see Object::type().
187  */
188  ObjectType type() const override;
189 
190  protected:
191 
192  /**
193  * Creates a new vertex set object.
194  */
196 
197  /**
198  * Destructs a vertex set object.
199  */
200  ~VertexSet() override;
201 };
202 
203 }
204 
205 }
206 
207 #endif // META_OCEAN_RENDERING_VERTEX_SET_H
This class is the base class for all rendering objects.
Definition: Object.h:54
ObjectType
Definition of different object type.
Definition: Object.h:63
This class is the base class for all rendering vertex sets.
Definition: VertexSet.h:47
virtual TextureCoordinates textureCoordinates(const unsigned int layerIndex) const
Returns the texture coordinates of this set.
virtual std::string phantomTextureCoordinateSystem() const
Returns the explicit reference coordinate system of the phantom object, if any.
virtual void set(const Vertices &vertices, const Normals &normals, const TextureCoordinates &textureCoordinates, const RGBAColors &colors)
Sets several attributes concurrently.
virtual RGBAColors colors() const
Returns the colors of this set.
virtual void setVertices(const Vector3 *vertices, const size_t size)
Sets the vertices for this set.
virtual void setTextureCoordinates(const TextureCoordinates &textureCoordinates, const unsigned int layerIndex)
Sets the texels for this set.
virtual void setNormals(const Vector3 *normals, const size_t size)
Sets the normals for this set.
virtual void setVertices(const Vertices &vertices)
Sets the vertices for this set.
virtual Vertices vertices() const
Returns the vertices of this set.
virtual void setPhantomTextureCoordinateSystem(const std::string &reference)
Sets the explicit reference coordinate system of the phantom objects.
VertexSet()
Creates a new vertex set object.
virtual unsigned int numberNormals() const
Returns the number of normals of this set.
virtual unsigned int numberColors() const
Returns the number of colors of this set.
virtual unsigned int numberVertices() const
Returns the number of vertices of this set.
virtual Normals normals() const
Returns the normals of this set.
virtual void setPhantomTextureCoordinates(const Vertices &textureCoordinates, const unsigned int layerIndex)
Sets 3D texels for this set used for phantom objects.
virtual void setNormals(const Normals &normals)
Sets the normals for this set.
~VertexSet() override
Destructs a vertex set object.
ObjectType type() const override
Returns the type of this object.
virtual void setColors(const RGBAColors &colors)
Sets the colors for this set.
virtual unsigned int numberTextureCoordinates(const unsigned int layerIndex) const
Returns the number of texture coordinates of this set.
std::vector< RGBAColor > RGBAColors
Definition of a vector holding rgba color objects.
Definition: RGBAColor.h:21
std::vector< Vertex > Vertices
Definition of a vector holding vertices.
Definition: rendering/Rendering.h:119
SmartObjectRef< VertexSet > VertexSetRef
Definition of a smart object reference holding a vertex set node.
Definition: VertexSet.h:24
std::vector< TextureCoordinate > TextureCoordinates
Definition of a vector holding texture coordinates.
Definition: rendering/Rendering.h:113
std::vector< Normal > Normals
Definition of a vector holding normals.
Definition: rendering/Rendering.h:107
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15