Ocean
Triangles.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_TRIANGLES_H
9 #define META_OCEAN_RENDERING_TRIANGLES_H
10 
14 
15 namespace Ocean
16 {
17 
18 namespace Rendering
19 {
20 
21 // Forward declaration
22 class Triangles;
23 
24 /**
25  * Definition of a smart object reference holding a triangles node.
26  * @see SmartObjectRef, Triangles.
27  * @ingroup rendering
28  */
30 
31 /**
32  * This class is the base for all triangles objects.
33  * A triangles object defines a mesh using a vertex set and triangle faces.<br>
34  * The mesh is composed by several independent triangles.<br>
35  * The vertices of all triangles are given by the vertex set, the mesh topology is given by triangle faces.<br>
36  * Each triangle can hold a normal, a texture coordinate or/and a color value for ech triangle vertex.<br>
37  * Different triangles objects can use the same vertex set to share common vertices and to reduce memory usage.<br>
38  * @see VertexSet, TriangleFaces
39  * @ingroup rendering
40  */
41 class OCEAN_RENDERING_EXPORT Triangles : virtual public IndependentPrimitive
42 {
43  public:
44 
45  /**
46  * Returns the faces of this triangles object.
47  * @return Triangle faces
48  * @exception NotSupportedException Is thrown if this function is not supported
49  */
50  virtual TriangleFaces faces() const;
51 
52  /**
53  * Returns the number of triangle faces defined in this primitive.
54  * @return Number of triangle faces
55  * @exception NotSupportedException Is thrown if this function is not supported
56  */
57  virtual unsigned int numberFaces() const;
58 
59  /**
60  * Sets the faces of this triangles object.
61  * @param faces The vertex indices of the individual triangles to set
62  * @exception NotSupportedException Is thrown if this function is not supported
63  */
64  virtual void setFaces(const TriangleFaces& faces);
65 
66  /**
67  * Sets the faces of this triangles object.
68  * @param numberImplicitTriangleFaces The number of triangle faces based on vertices with consecutive indices, with range [0, infinity)
69  * @exception NotSupportedException Is thrown if this function is not supported
70  */
71  virtual void setFaces(const unsigned int numberImplicitTriangleFaces);
72 
73  /**
74  * Returns the type of this object.
75  * @see Object::type().
76  */
77  ObjectType type() const override;
78 
79  /**
80  * Creates a new set of triangles with face normals out of a given set of vertices and corresponding triangle faces.
81  * @param vertices The existing set of vertices out of which the new mesh will be created
82  * @param faces The set of existing triangles for which the new mesh will be created, corresponding to the set of existing vertices
83  * @param triangleVertices The resulting new triangle vertices
84  * @param triangleNormals The resulting (new) triangle normals, one normal for each resulting vertex
85  * @param triangleFaces The resulting triangle faces, corresponding to the resulting vertices
86  * @param skipIrregularTriangles True, to skip an irregular triangle and to proceed with the next one; False, to stop the creating immediately if an irregular triangle occurs
87  * @return True, if succeeded
88  * @exception NotSupportedException Is thrown if this function is not supported
89  */
90  static bool createTriangleMesh(const Vertices& vertices, const TriangleFaces& faces, Vertices& triangleVertices, Normals& triangleNormals, TriangleFaces& triangleFaces, const bool skipIrregularTriangles = true);
91 
92  protected:
93 
94  /**
95  * Creates a new triangles object.
96  */
98 
99  /**
100  * Destructs a triangles object.
101  */
102  ~Triangles() override;
103 };
104 
105 }
106 
107 }
108 
109 #endif // META_OCEAN_RENDERING_TRIANGLES_H
This class is the base class for all independent primitive objects.
Definition: IndependentPrimitive.h:25
ObjectType
Definition of different object type.
Definition: Object.h:63
This class is the base for all triangles objects.
Definition: Triangles.h:42
virtual void setFaces(const TriangleFaces &faces)
Sets the faces of this triangles object.
virtual unsigned int numberFaces() const
Returns the number of triangle faces defined in this primitive.
virtual TriangleFaces faces() const
Returns the faces of this triangles object.
Triangles()
Creates a new triangles object.
~Triangles() override
Destructs a triangles object.
static bool createTriangleMesh(const Vertices &vertices, const TriangleFaces &faces, Vertices &triangleVertices, Normals &triangleNormals, TriangleFaces &triangleFaces, const bool skipIrregularTriangles=true)
Creates a new set of triangles with face normals out of a given set of vertices and corresponding tri...
ObjectType type() const override
Returns the type of this object.
virtual void setFaces(const unsigned int numberImplicitTriangleFaces)
Sets the faces of this triangles object.
std::vector< Vertex > Vertices
Definition of a vector holding vertices.
Definition: rendering/Rendering.h:119
std::vector< Normal > Normals
Definition of a vector holding normals.
Definition: rendering/Rendering.h:107
std::vector< TriangleFace > TriangleFaces
Definition of a vector holding triangle faces.
Definition: TriangleFace.h:23
SmartObjectRef< Triangles > TrianglesRef
Definition of a smart object reference holding a triangles node.
Definition: Triangles.h:22
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15