Ignition Common

API Reference

4.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 IGNITION_COMMON_SUBMESH_HH_
18 #define IGNITION_COMMON_SUBMESH_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <ignition/math/Vector3.hh>
25 #include <ignition/math/Vector2.hh>
26 
27 #include <ignition/utils/ImplPtr.hh>
28 
30 #include <ignition/common/graphics/Export.hh>
32 
33 namespace ignition
34 {
35  namespace common
36  {
37  class Material;
38  class NodeAssignment;
39 
41  class IGNITION_COMMON_GRAPHICS_VISIBLE SubMesh
42  {
44  public: enum PrimitiveType
45  {
62  TRISTRIPS
63  };
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 
89  public: PrimitiveType SubMeshPrimitiveType() const;
90 
93  public: void AddIndex(const unsigned int _index);
94 
97  public: void AddVertex(const ignition::math::Vector3d &_v);
98 
103  public: void AddVertex(const double _x, const double _y, const double _z);
104 
107  public: void AddNormal(const ignition::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 ignition::math::Vector2d &_uv);
131 
136  public: void AddTexCoordBySet(double _u, double _v,
137  unsigned int _setIndex);
138 
143  public: void AddTexCoordBySet(const ignition::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: ignition::math::Vector3d Vertex(const unsigned int _index) const;
159 
163  public: void SetVertex(const unsigned int _index,
164  const ignition::math::Vector3d &_v);
165 
171  public: ignition::math::Vector3d Normal(const unsigned int _index) const;
172 
176  public: void SetNormal(const unsigned int _index,
177  const ignition::math::Vector3d &_n);
178 
184  public: ignition::math::Vector2d TexCoord(
185  const unsigned int _index) const;
186 
194  public: ignition::math::Vector2d TexCoordBySet(
195  unsigned int _index,
196  unsigned int _setIndex) const;
197 
204  public: void SetTexCoord(const unsigned int _index,
205  const ignition::math::Vector2d &_uv);
206 
211  public: void SetTexCoordBySet(unsigned int _index,
212  const ignition::math::Vector2d &_uv,
213  unsigned int _setIdex);
214 
218  public: int Index(const unsigned int _index) const;
219 
223  public: void SetIndex(const unsigned int _index,
224  const unsigned int _i);
225 
232  public: NodeAssignment NodeAssignmentByIndex(
233  const unsigned int _index) const;
234 
237  public: ignition::math::Vector3d Max() const;
238 
241  public: ignition::math::Vector3d Min() const;
242 
245  public: unsigned int VertexCount() const;
246 
249  public: unsigned int NormalCount() const;
250 
253  public: unsigned int IndexCount() const;
254 
262  public: unsigned int TexCoordCount() const;
263 
268  public: unsigned int TexCoordCountBySet(unsigned int _setIndex) const;
269 
272  public: unsigned int TexCoordSetCount() const;
273 
276  public: unsigned int NodeAssignmentsCount() const;
277 
280  public: unsigned int MaxIndex() const;
281 
285  public: void SetMaterialIndex(const unsigned int _index);
286 
289  public: unsigned int MaterialIndex() const;
290 
294  public: bool HasVertex(const ignition::math::Vector3d &_v) const;
295 
301  public: bool HasVertex(const unsigned int _index) const;
302 
308  public: bool HasNormal(const unsigned int _index) const;
309 
320  public: bool HasTexCoord(const unsigned int _index) const;
321 
328  public: bool HasTexCoordBySet(unsigned int _index, unsigned int _setIndex)
329  const;
330 
336  public: bool HasNodeAssignment(const unsigned int _index) const;
337 
341  public: int IndexOfVertex(const ignition::math::Vector3d &_v) const;
342 
346  public: void FillArrays(double **_vertArr, int **_indexndArr) const;
347 
349  public: void RecalculateNormals();
350 
354  public: void GenSphericalTexCoord(
355  const ignition::math::Vector3d &_center);
356 
361  public: void GenSphericalTexCoordBySet(
362  const ignition::math::Vector3d &_center,
363  unsigned int _setIndex);
364 
367  public: void Scale(const ignition::math::Vector3d &_factor);
368 
371  public: void Scale(const double &_factor);
372 
376  public: void Center(const ignition::math::Vector3d &_center =
378 
381  public: void Translate(const ignition::math::Vector3d &_vec);
382 
394  public: double Volume() const;
395 
397  IGN_UTILS_IMPL_PTR(dataPtr)
398  };
399 
402  class IGNITION_COMMON_GRAPHICS_VISIBLE NodeAssignment
403  {
405  public: NodeAssignment();
406 
408  public: unsigned int vertexIndex;
409 
411  public: unsigned int nodeIndex;
412 
415  public: float weight;
416  };
417  }
418 }
419 
420 #endif
unsigned int nodeIndex
Node (or bone) index.
Definition: SubMesh.hh:411
Connected lines. 2 vertices for the first line and every vertex specified afterwards creates a new li...
Definition: SubMesh.hh:52
STL class.
Line. 2 vertices per line.
Definition: SubMesh.hh:49
float weight
The weight (between 0 and 1). This determines how much the node (bone) affects the vertex in animatio...
Definition: SubMesh.hh:415
Point. 1 vertex per point.
Definition: SubMesh.hh:47
PrimitiveType
An enumeration of the geometric mesh primitives.
Definition: SubMesh.hh:44
A child mesh.
Definition: SubMesh.hh:41
unsigned int vertexIndex
Index of the vertex.
Definition: SubMesh.hh:408
Connected triangle in fan shape. 3 vertices for the first triangle and every vertex specified afterwa...
Definition: SubMesh.hh:58
static const Vector3 Zero
Forward declarations for the common classes.
Vertex to node weighted assignement for skeleton animation visualization.
Definition: SubMesh.hh:402
Triangle type. 3 vertices per triangle.
Definition: SubMesh.hh:54