Ocean
IndexedFaceSet.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_SCENEDESCRIPTION_SDX_X3D_INDEXED_FACE_SET_H
9 #define META_OCEAN_SCENEDESCRIPTION_SDX_X3D_INDEXED_FACE_SET_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace SceneDescription
18 {
19 
20 namespace SDX
21 {
22 
23 namespace X3D
24 {
25 
26 /**
27  * This class implements a x3d indexed face set node.
28  * @ingroup scenedescriptionsdxx3d
29  */
30 class OCEAN_SCENEDESCRIPTION_SDX_X3D_EXPORT IndexedFaceSet : virtual public X3DComposedGeometryNode
31 {
32  public:
33 
34  /**
35  * Creates a new x3d indexed face set node.
36  * @param environment Node environment
37  */
38  IndexedFaceSet(const SDXEnvironment* environment);
39 
40  protected:
41 
42  /**
43  * Specifies the node type and the fields of this node.
44  * @return Unique node specification of this node
45  */
47 
48  /**
49  * Event function to inform the node that it has been initialized and can apply all internal values to corresponding rendering objects.
50  * @see SDXNode::onInitialize().
51  */
52  void onInitialize(const Rendering::SceneRef& scene, const Timestamp timestamp) override;
53 
54  /**
55  * Event function to inform the node about a changed field.
56  * @see SDXNode::onFieldChanged().
57  */
58  void onFieldChanged(const std::string& fieldName) override;
59 
60  /**
61  * Explicit changing event function for node fields.
62  * @see X3DNode::onFieldChanging().
63  */
64  bool onFieldChanging(const std::string& fieldName, const Field& field) override;
65 
66  /**
67  * Applies all recent changes to the rendering engine object.
68  */
69  void apply();
70 
71  /**
72  * Adds new normals per vertex to the rendering mesh.
73  * @param renderingNormals Rendering normals receiving the new generated normals
74  * @param normals Scene description normals providing the defined normals
75  * @param indices The indices used to arrange the scene description normals
76  * @param firstIndex Index of the first element of the specified indices
77  * @param endIndex Index of the end element (exclusively) of the specified indices
78  */
79  void addNormalsPerVertex(Rendering::Normals& renderingNormals, const MultiVector3::Values& normals, const MultiInt::Values& indices, const unsigned int firstIndex, const unsigned int endIndex) const;
80 
81  /**
82  * Adds new color per vertex to the rendering mesh.
83  * @param renderingColors Rendering colors receiving the new generated color values
84  * @param colors Scene description colors providing the defined colors
85  * @param indices The indices used to arrange the scene description colors
86  * @param firstIndex Index of the first element of the specified indices
87  * @param endIndex Index of the end element (exclusively) of the specified indices
88  * @return True, if succeeded
89  */
90  bool addColorsPerVertex(RGBAColors& renderingColors, const MultiColor::Values& colors, const MultiInt::Values& indices, const unsigned int firstIndex, const unsigned int endIndex);
91 
92  /**
93  * Adds new texture coordinate per vertex to the rendering mesh.
94  * @param renderingTextureCoordinates Rendering texture coordinates receiving the new generated texture coordinates
95  * @param textureCoordinates Scene description texture coordinates providing the defined texture coordinates
96  * @param indices The indices used to arrange the scene description texture coordinates
97  * @param firstIndex Index of the first element of the specified indices
98  * @param endIndex Index of the end element (exclusively) of the specified indices
99  * @return True, if succeeded
100  */
101  bool addTextureCoordinatesPerVertex(Rendering::TextureCoordinates& renderingTextureCoordinates, const MultiVector2::Values& textureCoordinates, const MultiInt::Values& indices, const unsigned int firstIndex, const unsigned int endIndex);
102 
103  /**
104  * Adds new Ocean specific phantom texture coordinate per vertex to the rendering mesh.
105  * @param renderingPhantomTextureCoordinates Rendering texture coordinates receiving the new generated texture coordinates
106  * @param phantomTextureCoordinates Scene description texture coordinates providing the defined texture coordinates
107  * @param indices The indices used to arrange the scene description texture coordinates
108  * @param firstIndex Index of the first element of the specified indices
109  * @param endIndex Index of the end element (exclusively) of the specified indices
110  * @return True, if succeeded
111  */
112  bool addPhantomTextureCoordinatesPerVertex(Rendering::Vertices& renderingPhantomTextureCoordinates, const MultiVector3::Values& phantomTextureCoordinates, const MultiInt::Values& indices, const unsigned int firstIndex, const unsigned int endIndex);
113 
114  /**
115  * Returns the address of the most derived object.
116  * @see Node::objectAddress().
117  */
118  size_t objectAddress() const override;
119 
120  protected:
121 
122  /// Set_colorIndex field.
124 
125  /// Set_coordIndex field.
127 
128  /// Set_normalIndex field.
130 
131  /// Set_texCoordIndex.
133 
134  /// ColorIndex field.
136 
137  /// Convex field.
139 
140  /// CoordIndex field.
142 
143  /// CreaseAngle field.
145 
146  /// NormalIndex field.
148 
149  /// TexCoordIndex field.
151 };
152 
153 }
154 
155 }
156 
157 }
158 
159 }
160 
161 #endif // META_OCEAN_SCENEDESCRIPTION_SDX_X3D_INDEXED_FACE_SET_H
std::vector< Vector3 > Values
Definition of a vector holding the single values.
Definition: Field1D.h:122
This class is the base class for all scene description fields.
Definition: Field.h:36
This class implements a node specification object.
Definition: scenedescription/Node.h:77
This class implements a x3d indexed face set node.
Definition: IndexedFaceSet.h:31
MultiInt coordIndex_
CoordIndex field.
Definition: IndexedFaceSet.h:141
SingleFloat creaseAngle_
CreaseAngle field.
Definition: IndexedFaceSet.h:144
NodeSpecification specifyNode()
Specifies the node type and the fields of this node.
void apply()
Applies all recent changes to the rendering engine object.
MultiInt setTexCoordIndex_
Set_texCoordIndex.
Definition: IndexedFaceSet.h:132
MultiInt setColorIndex_
Set_colorIndex field.
Definition: IndexedFaceSet.h:123
size_t objectAddress() const override
Returns the address of the most derived object.
bool addTextureCoordinatesPerVertex(Rendering::TextureCoordinates &renderingTextureCoordinates, const MultiVector2::Values &textureCoordinates, const MultiInt::Values &indices, const unsigned int firstIndex, const unsigned int endIndex)
Adds new texture coordinate per vertex to the rendering mesh.
MultiInt normalIndex_
NormalIndex field.
Definition: IndexedFaceSet.h:147
MultiInt setNormalIndex_
Set_normalIndex field.
Definition: IndexedFaceSet.h:129
bool addPhantomTextureCoordinatesPerVertex(Rendering::Vertices &renderingPhantomTextureCoordinates, const MultiVector3::Values &phantomTextureCoordinates, const MultiInt::Values &indices, const unsigned int firstIndex, const unsigned int endIndex)
Adds new Ocean specific phantom texture coordinate per vertex to the rendering mesh.
MultiInt colorIndex_
ColorIndex field.
Definition: IndexedFaceSet.h:135
MultiInt setCoordIndex_
Set_coordIndex field.
Definition: IndexedFaceSet.h:126
MultiInt texCoordIndex_
TexCoordIndex field.
Definition: IndexedFaceSet.h:150
void onInitialize(const Rendering::SceneRef &scene, const Timestamp timestamp) override
Event function to inform the node that it has been initialized and can apply all internal values to c...
IndexedFaceSet(const SDXEnvironment *environment)
Creates a new x3d indexed face set node.
void addNormalsPerVertex(Rendering::Normals &renderingNormals, const MultiVector3::Values &normals, const MultiInt::Values &indices, const unsigned int firstIndex, const unsigned int endIndex) const
Adds new normals per vertex to the rendering mesh.
bool onFieldChanging(const std::string &fieldName, const Field &field) override
Explicit changing event function for node fields.
bool addColorsPerVertex(RGBAColors &renderingColors, const MultiColor::Values &colors, const MultiInt::Values &indices, const unsigned int firstIndex, const unsigned int endIndex)
Adds new color per vertex to the rendering mesh.
SingleBool convex_
Convex field.
Definition: IndexedFaceSet.h:138
void onFieldChanged(const std::string &fieldName) override
Event function to inform the node about a changed field.
This class implements an abstract x3d composed geometry node.
Definition: X3DComposedGeometryNode.h:33
This class implements a node environment container.
Definition: SDXNode.h:62
This class implements a timestamp.
Definition: Timestamp.h:36
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
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