Ignition Common

API Reference

3.6.1
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 
28 #include <ignition/common/graphics/Export.hh>
30 
31 namespace ignition
32 {
33  namespace common
34  {
35  class SubMeshPrivate;
36  class Material;
37  class NodeAssignment;
38 
40  class IGNITION_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 
73  public: SubMesh(const SubMesh &_other);
74 
76  public: virtual ~SubMesh();
77 
80  public: void SetName(const std::string &_name);
81 
84  public: std::string Name() const;
85 
88  public: void SetPrimitiveType(PrimitiveType _type);
89 
92  public: PrimitiveType SubMeshPrimitiveType() const;
93 
96  public: void AddIndex(const unsigned int _index);
97 
100  public: void AddVertex(const ignition::math::Vector3d &_v);
101 
106  public: void AddVertex(const double _x, const double _y, const double _z);
107 
110  public: void AddNormal(const ignition::math::Vector3d &_n);
111 
116  public: void AddNormal(const double _x, const double _y, const double _z);
117 
121  public: void AddTexCoord(const double _u, const double _v);
122 
125  public: void AddTexCoord(const ignition::math::Vector2d &_uv);
126 
131  public: void AddNodeAssignment(const unsigned int _vertex,
132  const unsigned int _node,
133  const float _weight);
139  public: ignition::math::Vector3d Vertex(const unsigned int _index) const;
140 
144  public: void SetVertex(const unsigned int _index,
145  const ignition::math::Vector3d &_v);
146 
152  public: ignition::math::Vector3d Normal(const unsigned int _index) const;
153 
157  public: void SetNormal(const unsigned int _index,
158  const ignition::math::Vector3d &_n);
159 
165  public: ignition::math::Vector2d TexCoord(
166  const unsigned int _index) const;
167 
171  public: void SetTexCoord(const unsigned int _index,
172  const ignition::math::Vector2d &_uv);
173 
177  public: int Index(const unsigned int _index) const;
178 
182  public: void SetIndex(const unsigned int _index,
183  const unsigned int _i);
184 
191  public: NodeAssignment NodeAssignmentByIndex(
192  const unsigned int _index) const;
193 
196  public: ignition::math::Vector3d Max() const;
197 
200  public: ignition::math::Vector3d Min() const;
201 
204  public: unsigned int VertexCount() const;
205 
208  public: unsigned int NormalCount() const;
209 
212  public: unsigned int IndexCount() const;
213 
216  public: unsigned int TexCoordCount() const;
217 
220  public: unsigned int NodeAssignmentsCount() const;
221 
224  public: unsigned int MaxIndex() const;
225 
229  public: void SetMaterialIndex(const unsigned int _index);
230 
233  public: unsigned int MaterialIndex() const;
234 
238  public: bool HasVertex(const ignition::math::Vector3d &_v) const;
239 
245  public: bool HasVertex(const unsigned int _index) const;
246 
252  public: bool HasNormal(const unsigned int _index) const;
253 
259  public: bool HasTexCoord(const unsigned int _index) const;
260 
266  public: bool HasNodeAssignment(const unsigned int _index) const;
267 
271  public: int IndexOfVertex(const ignition::math::Vector3d &_v) const;
272 
276  public: void FillArrays(double **_vertArr, int **_indexndArr) const;
277 
279  public: void RecalculateNormals();
280 
284  public: void GenSphericalTexCoord(
285  const ignition::math::Vector3d &_center);
286 
289  public: void Scale(const ignition::math::Vector3d &_factor);
290 
293  public: void Scale(const double &_factor);
294 
298  public: void Center(const ignition::math::Vector3d &_center =
300 
303  public: void Translate(const ignition::math::Vector3d &_vec);
304 
316  public: double Volume() const;
317 
320  private: std::unique_ptr<SubMeshPrivate> dataPtr;
322  };
323 
326  class IGNITION_COMMON_GRAPHICS_VISIBLE NodeAssignment
327  {
329  public: NodeAssignment();
330 
332  public: unsigned int vertexIndex;
333 
335  public: unsigned int nodeIndex;
336 
339  public: float weight;
340  };
341  }
342 }
343 
344 #endif
unsigned int nodeIndex
Node (or bone) index.
Definition: SubMesh.hh:335
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
Connected lines. 2 vertices for the first line and every vertex specified afterwards creates a new li...
Definition: SubMesh.hh:51
STL class.
Line. 2 vertices per line.
Definition: SubMesh.hh:48
float weight
The weight (between 0 and 1). This determines how much the node (bone) affects the vertex in animatio...
Definition: SubMesh.hh:339
Point. 1 vertex per point.
Definition: SubMesh.hh:46
PrimitiveType
An enumeration of the geometric mesh primitives.
Definition: SubMesh.hh:43
A child mesh.
Definition: SubMesh.hh:40
unsigned int vertexIndex
Index of the vertex.
Definition: SubMesh.hh:332
Connected triangle in fan shape. 3 vertices for the first triangle and every vertex specified afterwa...
Definition: SubMesh.hh:57
static const Vector3 Zero
Forward declarations for the common classes.
Vertex to node weighted assignement for skeleton animation visualization.
Definition: SubMesh.hh:326
Triangle type. 3 vertices per triangle.
Definition: SubMesh.hh:53
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64