Gazebo Common

API Reference

7.4.0
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
32namespace gz
33{
34 namespace common
35 {
36 class Material;
37 class NodeAssignment;
38
40 class GZ_COMMON_GRAPHICS_VISIBLE SubMesh
41 {
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
141 public: void AddTexCoordBySet(const gz::math::Vector2d &_uv,
142 unsigned int _setIndex);
143
148 public: void AddNodeAssignment(const unsigned int _vertex,
149 const unsigned int _node,
150 const float _weight);
156 public: gz::math::Vector3d Vertex(const unsigned int _index) const;
157
162 public: const gz::math::Vector3d* VertexPtr() const;
163
167 public: void SetVertex(const unsigned int _index,
168 const gz::math::Vector3d &_v);
169
175 public: gz::math::Vector3d Normal(const unsigned int _index) const;
176
180 public: void SetNormal(const unsigned int _index,
181 const gz::math::Vector3d &_n);
182
189 const unsigned int _index) const;
190
199 unsigned int _index,
200 unsigned int _setIndex) const;
201
208 public: void SetTexCoord(const unsigned int _index,
209 const gz::math::Vector2d &_uv);
210
215 public: void SetTexCoordBySet(unsigned int _index,
216 const gz::math::Vector2d &_uv,
217 unsigned int _setIndex);
218
222 public: int Index(const unsigned int _index) const;
223
228 public: const unsigned int* IndexPtr() const;
229
233 public: void SetIndex(const unsigned int _index,
234 const unsigned int _i);
235
243 const unsigned int _index) const;
244
247 public: gz::math::Vector3d Max() const;
248
251 public: gz::math::Vector3d Min() const;
252
255 public: unsigned int VertexCount() const;
256
259 public: unsigned int NormalCount() const;
260
263 public: unsigned int IndexCount() const;
264
272 public: unsigned int TexCoordCount() const;
273
278 public: unsigned int TexCoordCountBySet(unsigned int _setIndex) const;
279
282 public: unsigned int TexCoordSetCount() const;
283
286 public: unsigned int NodeAssignmentsCount() const;
287
290 public: unsigned int MaxIndex() const;
291
295 public: void SetMaterialIndex(const unsigned int _index);
296
300 public: std::optional<unsigned int> GetMaterialIndex() const;
301
305 public: bool HasVertex(const gz::math::Vector3d &_v) const;
306
312 public: bool HasVertex(const unsigned int _index) const;
313
319 public: bool HasNormal(const unsigned int _index) const;
320
331 public: bool HasTexCoord(const unsigned int _index) const;
332
339 public: bool HasTexCoordBySet(unsigned int _index, unsigned int _setIndex)
340 const;
341
347 public: bool HasNodeAssignment(const unsigned int _index) const;
348
352 public: int IndexOfVertex(const gz::math::Vector3d &_v) const;
353
357 public: void FillArrays(double **_vertArr, int **_indexndArr) const;
358
360 public: void RecalculateNormals();
361
366 const gz::math::Vector3d &_center);
367
373 const gz::math::Vector3d &_center,
374 unsigned int _setIndex);
375
378 public: void Scale(const gz::math::Vector3d &_factor);
379
382 public: void Scale(const double &_factor);
383
387 public: void Center(const gz::math::Vector3d &_center =
389
392 public: void Translate(const gz::math::Vector3d &_vec);
393
405 public: double Volume() const;
406
417
420 public: bool HasValidIndices() const;
421
423 GZ_UTILS_IMPL_PTR(dataPtr)
424 };
425
428 class GZ_COMMON_GRAPHICS_VISIBLE NodeAssignment
429 {
431 public: NodeAssignment();
432
434 public: unsigned int vertexIndex;
435
437 public: unsigned int nodeIndex;
438
441 public: float weight;
442 };
443 }
444}
445
446#endif