Gazebo Common

API Reference

5.7.0
gz/common/SubMesh.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_COMMON_SUBMESH_HH_
18 #define GZ_COMMON_SUBMESH_HH_
19 
20 #include <memory>
21 #include <optional>
22 #include <string>
23 
24 #include <gz/math/Vector3.hh>
25 #include <gz/math/Vector2.hh>
26 
27 #include <gz/utils/ImplPtr.hh>
28 
30 #include <gz/common/graphics/Export.hh>
31 
32 namespace gz
33 {
34  namespace common
35  {
36  class Material;
37  class NodeAssignment;
38 
40  class GZ_COMMON_GRAPHICS_VISIBLE SubMesh
41  {
43  public: enum PrimitiveType
44  {
61  TRISTRIPS
62  };
63 
65  public: SubMesh();
66 
69  public: explicit SubMesh(const std::string &_name);
70 
72  public: virtual ~SubMesh();
73 
76  public: void SetName(const std::string &_name);
77 
80  public: std::string Name() const;
81 
84  public: void SetPrimitiveType(PrimitiveType _type);
85 
89 
92  public: void AddIndex(const unsigned int _index);
93 
96  public: void AddVertex(const gz::math::Vector3d &_v);
97 
102  public: void AddVertex(const double _x, const double _y, const double _z);
103 
106  public: void AddNormal(const gz::math::Vector3d &_n);
107 
112  public: void AddNormal(const double _x, const double _y, const double _z);
113 
121  public: void AddTexCoord(const double _u, const double _v);
122 
129  public: void AddTexCoord(const gz::math::Vector2d &_uv);
130 
135  public: void AddTexCoordBySet(double _u, double _v,
136  unsigned int _setIndex);
137 
142  public: void AddTexCoordBySet(const gz::math::Vector2d &_uv,
143  unsigned int _setIndex);
144 
149  public: void AddNodeAssignment(const unsigned int _vertex,
150  const unsigned int _node,
151  const float _weight);
157  public: gz::math::Vector3d Vertex(const unsigned int _index) const;
158 
163  public: const gz::math::Vector3d* VertexPtr() const;
164 
168  public: void SetVertex(const unsigned int _index,
169  const gz::math::Vector3d &_v);
170 
176  public: gz::math::Vector3d Normal(const unsigned int _index) const;
177 
181  public: void SetNormal(const unsigned int _index,
182  const gz::math::Vector3d &_n);
183 
190  const unsigned int _index) const;
191 
200  unsigned int _index,
201  unsigned int _setIndex) const;
202 
209  public: void SetTexCoord(const unsigned int _index,
210  const gz::math::Vector2d &_uv);
211 
216  public: void SetTexCoordBySet(unsigned int _index,
217  const gz::math::Vector2d &_uv,
218  unsigned int _setIdex);
219 
223  public: int Index(const unsigned int _index) const;
224 
229  public: const unsigned int* IndexPtr() const;
230 
234  public: void SetIndex(const unsigned int _index,
235  const unsigned int _i);
236 
244  const unsigned int _index) const;
245 
248  public: gz::math::Vector3d Max() const;
249 
252  public: gz::math::Vector3d Min() const;
253 
256  public: unsigned int VertexCount() const;
257 
260  public: unsigned int NormalCount() const;
261 
264  public: unsigned int IndexCount() const;
265 
273  public: unsigned int TexCoordCount() const;
274 
279  public: unsigned int TexCoordCountBySet(unsigned int _setIndex) const;
280 
283  public: unsigned int TexCoordSetCount() const;
284 
287  public: unsigned int NodeAssignmentsCount() const;
288 
291  public: unsigned int MaxIndex() const;
292 
296  public: void SetMaterialIndex(const unsigned int _index);
297 
302  public: unsigned int GZ_DEPRECATED(5) MaterialIndex() const;
303 
307  public: std::optional<unsigned int> GetMaterialIndex() const;
308 
312  public: bool HasVertex(const gz::math::Vector3d &_v) const;
313 
319  public: bool HasVertex(const unsigned int _index) const;
320 
326  public: bool HasNormal(const unsigned int _index) const;
327 
338  public: bool HasTexCoord(const unsigned int _index) const;
339 
346  public: bool HasTexCoordBySet(unsigned int _index, unsigned int _setIndex)
347  const;
348 
354  public: bool HasNodeAssignment(const unsigned int _index) const;
355 
359  public: int IndexOfVertex(const gz::math::Vector3d &_v) const;
360 
364  public: void FillArrays(double **_vertArr, int **_indexndArr) const;
365 
367  public: void RecalculateNormals();
368 
372  public: void GenSphericalTexCoord(
373  const gz::math::Vector3d &_center);
374 
379  public: void GenSphericalTexCoordBySet(
380  const gz::math::Vector3d &_center,
381  unsigned int _setIndex);
382 
385  public: void Scale(const gz::math::Vector3d &_factor);
386 
389  public: void Scale(const double &_factor);
390 
394  public: void Center(const gz::math::Vector3d &_center =
395  gz::math::Vector3d::Zero);
396 
399  public: void Translate(const gz::math::Vector3d &_vec);
400 
412  public: double Volume() const;
413 
415  GZ_UTILS_IMPL_PTR(dataPtr)
416  };
417 
420  class GZ_COMMON_GRAPHICS_VISIBLE NodeAssignment
421  {
423  public: NodeAssignment();
424 
426  public: unsigned int vertexIndex;
427 
429  public: unsigned int nodeIndex;
430 
433  public: float weight;
434  };
435  }
436 }
437 
438 #endif