Gazebo Common

API Reference

5.5.1
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#include <vector>
24
25#include <gz/math/Vector3.hh>
26#include <gz/math/Vector2.hh>
27
28#include <gz/utils/ImplPtr.hh>
29
31#include <gz/common/graphics/Export.hh>
32
33namespace gz
34{
35 namespace common
36 {
37 class Material;
38 class NodeAssignment;
39
41 class GZ_COMMON_GRAPHICS_VISIBLE SubMesh
42 {
64
66 public: SubMesh();
67
70 public: explicit SubMesh(const std::string &_name);
71
73 public: virtual ~SubMesh();
74
77 public: void SetName(const std::string &_name);
78
81 public: std::string Name() const;
82
85 public: void SetPrimitiveType(PrimitiveType _type);
86
90
93 public: void AddIndex(const unsigned int _index);
94
97 public: void AddVertex(const gz::math::Vector3d &_v);
98
103 public: void AddVertex(const double _x, const double _y, const double _z);
104
107 public: void AddNormal(const gz::math::Vector3d &_n);
108
113 public: void AddNormal(const double _x, const double _y, const double _z);
114
122 public: void AddTexCoord(const double _u, const double _v);
123
130 public: void AddTexCoord(const gz::math::Vector2d &_uv);
131
136 public: void AddTexCoordBySet(double _u, double _v,
137 unsigned int _setIndex);
138
143 public: void AddTexCoordBySet(const gz::math::Vector2d &_uv,
144 unsigned int _setIndex);
145
150 public: void AddNodeAssignment(const unsigned int _vertex,
151 const unsigned int _node,
152 const float _weight);
158 public: gz::math::Vector3d Vertex(const unsigned int _index) const;
159
164 public: const gz::math::Vector3d* VertexPtr() const;
165
169 public: void SetVertex(const unsigned int _index,
170 const gz::math::Vector3d &_v);
171
177 public: gz::math::Vector3d Normal(const unsigned int _index) const;
178
182 public: void SetNormal(const unsigned int _index,
183 const gz::math::Vector3d &_n);
184
191 const unsigned int _index) const;
192
201 unsigned int _index,
202 unsigned int _setIndex) const;
203
210 public: void SetTexCoord(const unsigned int _index,
211 const gz::math::Vector2d &_uv);
212
217 public: void SetTexCoordBySet(unsigned int _index,
218 const gz::math::Vector2d &_uv,
219 unsigned int _setIdex);
220
224 public: int Index(const unsigned int _index) const;
225
230 public: const unsigned int* IndexPtr() const;
231
235 public: void SetIndex(const unsigned int _index,
236 const unsigned int _i);
237
245 const unsigned int _index) const;
246
249 public: gz::math::Vector3d Max() const;
250
253 public: gz::math::Vector3d Min() const;
254
257 public: unsigned int VertexCount() const;
258
261 public: unsigned int NormalCount() const;
262
265 public: unsigned int IndexCount() const;
266
274 public: unsigned int TexCoordCount() const;
275
280 public: unsigned int TexCoordCountBySet(unsigned int _setIndex) const;
281
284 public: unsigned int TexCoordSetCount() const;
285
288 public: unsigned int NodeAssignmentsCount() const;
289
292 public: unsigned int MaxIndex() const;
293
297 public: void SetMaterialIndex(const unsigned int _index);
298
303 public: unsigned int GZ_DEPRECATED(5) MaterialIndex() const;
304
308 public: std::optional<unsigned int> GetMaterialIndex() const;
309
313 public: bool HasVertex(const gz::math::Vector3d &_v) const;
314
320 public: bool HasVertex(const unsigned int _index) const;
321
327 public: bool HasNormal(const unsigned int _index) const;
328
339 public: bool HasTexCoord(const unsigned int _index) const;
340
347 public: bool HasTexCoordBySet(unsigned int _index, unsigned int _setIndex)
348 const;
349
355 public: bool HasNodeAssignment(const unsigned int _index) const;
356
360 public: int IndexOfVertex(const gz::math::Vector3d &_v) const;
361
365 public: void FillArrays(double **_vertArr, int **_indexndArr) const;
366
368 public: void RecalculateNormals();
369
373 public: void GenSphericalTexCoord(
374 const gz::math::Vector3d &_center);
375
380 public: void GenSphericalTexCoordBySet(
381 const gz::math::Vector3d &_center,
382 unsigned int _setIndex);
383
386 public: void Scale(const gz::math::Vector3d &_factor);
387
390 public: void Scale(const double &_factor);
391
395 public: void Center(const gz::math::Vector3d &_center =
396 gz::math::Vector3d::Zero);
397
400 public: void Translate(const gz::math::Vector3d &_vec);
401
413 public: double Volume() const;
414
416 GZ_UTILS_IMPL_PTR(dataPtr)
417 };
418
421 class GZ_COMMON_GRAPHICS_VISIBLE NodeAssignment
422 {
424 public: NodeAssignment();
425
427 public: unsigned int vertexIndex;
428
430 public: unsigned int nodeIndex;
431
434 public: float weight;
435 };
436 }
437}
438
439#endif