Go to the documentation of this file.
17 #ifndef _GAZEBO_MESH_HH_
18 #define _GAZEBO_MESH_HH_
23 #include <ignition/math/Vector3.hh>
24 #include <ignition/math/Vector2.hh>
42 class GZ_COMMON_VISIBLE
Mesh
48 public:
virtual ~
Mesh();
52 public:
void SetPath(
const std::string &_path);
56 public: std::string GetPath()
const;
60 public:
void SetName(
const std::string &_n);
64 public: std::string GetName()
const;
68 public: ignition::math::Vector3d Max()
const;
72 public: ignition::math::Vector3d Min()
const;
76 public:
unsigned int GetVertexCount()
const;
80 public:
unsigned int GetNormalCount()
const;
84 public:
unsigned int GetIndexCount()
const;
88 public:
unsigned int GetTexCoordCount()
const;
93 public:
void AddSubMesh(
SubMesh *_child);
97 public:
unsigned int GetSubMeshCount()
const;
102 public:
int AddMaterial(
Material *_mat);
106 public:
unsigned int GetMaterialCount()
const;
111 public:
const Material *GetMaterial(
int _index)
const;
116 public:
int GetMaterialIndex(
const Material *_mat)
const;
122 public:
const SubMesh *GetSubMesh(
unsigned int _i)
const;
127 public:
const SubMesh *GetSubMesh(
const std::string &_name)
const;
132 public:
void FillArrays(
float **_vertArr,
int **_indArr)
const;
136 public:
void RecalculateNormals();
142 public:
void GetAABB(ignition::math::Vector3d &_center,
143 ignition::math::Vector3d &_minXYZ,
144 ignition::math::Vector3d &_maxXYZ)
const;
149 public:
void GenSphericalTexCoord(
150 const ignition::math::Vector3d &_center);
154 public:
Skeleton* GetSkeleton()
const;
157 public:
void SetSkeleton(
Skeleton *_skel);
160 public:
bool HasSkeleton()
const;
164 public:
void Scale(
double _factor);
168 public:
void SetScale(
const ignition::math::Vector3d &_factor);
173 public:
void Center(
const ignition::math::Vector3d &_center =
174 ignition::math::Vector3d::Zero);
178 public:
void Translate(
const ignition::math::Vector3d &_vec);
181 private: std::string name;
184 private: std::string path;
187 private: std::vector<SubMesh *> submeshes;
190 private: std::vector<Material *> materials;
232 public:
void SetName(
const std::string &_n);
236 public: std::string GetName()
const;
240 public:
void SetPrimitiveType(PrimitiveType _type);
244 public: PrimitiveType GetPrimitiveType()
const;
248 public:
void CopyVertices(
249 const std::vector<ignition::math::Vector3d> &_verts);
253 public:
void CopyNormals(
254 const std::vector<ignition::math::Vector3d> &_norms);
258 public:
void SetVertexCount(
unsigned int _count);
262 public:
void SetIndexCount(
unsigned int _count);
266 public:
void SetNormalCount(
unsigned int _count);
270 public:
void SetTexCoordCount(
unsigned int _count);
274 public:
void AddIndex(
unsigned int _i);
278 public:
void AddVertex(
const ignition::math::Vector3d &_v);
284 public:
void AddVertex(
double _x,
double _y,
double _z);
288 public:
void AddNormal(
const ignition::math::Vector3d &_n);
294 public:
void AddNormal(
double _x,
double _y,
double _z);
299 public:
void AddTexCoord(
double _u,
double _v);
305 public:
void AddNodeAssignment(
unsigned int _vertex,
unsigned int _node,
311 public: ignition::math::Vector3d Vertex(
unsigned int _i)
const;
316 public:
void SetVertex(
unsigned int _i,
317 const ignition::math::Vector3d &_v);
322 public: ignition::math::Vector3d Normal(
unsigned int _i)
const;
327 public:
void SetNormal(
unsigned int _i,
328 const ignition::math::Vector3d &_n);
333 public: ignition::math::Vector2d TexCoord(
unsigned int _i)
const;
342 public:
void SetTexCoord(
unsigned int _i,
343 const ignition::math::Vector2d &_t);
347 public:
unsigned int GetIndex(
unsigned int _i)
const;
351 public: ignition::math::Vector3d Max()
const;
355 public: ignition::math::Vector3d Min()
const;
358 public:
unsigned int GetVertexCount()
const;
361 public:
unsigned int GetNormalCount()
const;
364 public:
unsigned int GetIndexCount()
const;
367 public:
unsigned int GetTexCoordCount()
const;
370 public:
unsigned int GetNodeAssignmentsCount()
const;
373 public:
unsigned int GetMaxIndex()
const;
378 public:
void SetMaterialIndex(
unsigned int _index);
381 public:
unsigned int GetMaterialIndex()
const;
386 public:
bool HasVertex(
const ignition::math::Vector3d &_v)
const;
391 public:
unsigned int GetVertexIndex(
392 const ignition::math::Vector3d &_v)
const;
397 public:
void FillArrays(
float **_vertArr,
int **_indArr)
const;
400 public:
void RecalculateNormals();
405 public:
void GenSphericalTexCoord(
406 const ignition::math::Vector3d &_center);
410 public:
void Scale(
double _factor);
415 public:
void Center(
const ignition::math::Vector3d &_center =
416 ignition::math::Vector3d::Zero);
420 public:
void Translate(
const ignition::math::Vector3d &_vec);
424 public:
void SetScale(
const ignition::math::Vector3d &_factor);
427 private: std::vector<ignition::math::Vector3d> vertices;
430 private: std::vector<ignition::math::Vector3d> normals;
433 private: std::vector<ignition::math::Vector2d> texCoords;
436 private: std::vector<unsigned int> indices;
439 private: std::vector<NodeAssignment> nodeAssignments;
442 private: PrimitiveType primitiveType;
446 private:
int materialIndex;
449 private: std::string name;
void FillArrays(float **_vertArr, int **_indArr) const
Put all the data into flat arrays.
unsigned int GetMaterialCount() const
Get the number of materials.
void Center(const ignition::math::Vector3d &_center=ignition::math::Vector3d::Zero)
Move the center of the submesh to the given coordinate.
unsigned int GetSubMeshCount() const
Get the number of children.
void SetTexCoordCount(unsigned int _count)
Resize the texture coordinate array.
void Center(const ignition::math::Vector3d &_center=ignition::math::Vector3d::Zero)
Move the center of the mesh to the given coordinate.
void RecalculateNormals()
Recalculate all the normals.
void Scale(double _factor)
Scale all vertices by _factor.
void SetVertex(unsigned int _i, const ignition::math::Vector3d &_v)
Set a vertex.
Forward declarations for the common classes.
Definition: Animation.hh:26
unsigned int GetIndex(unsigned int _i) const
Get an index.
int AddMaterial(Material *_mat)
Add a material to the mesh.
ignition::math::Vector3d Min() const
Get the minimum X, Y, Z values.
float weight
the weight (between 0 and 1)
Definition: Mesh.hh:210
ignition::math::Vector3d Min() const
Get the minimum X, Y, Z values from all the vertices.
void SetMaterialIndex(unsigned int _index)
Set the material index.
common
Definition: FuelModelDatabase.hh:37
unsigned int GetMaterialIndex() const
Get the material index.
virtual ~SubMesh()
Destructor.
Vertex to node weighted assignement for skeleton animation visualization.
Definition: Mesh.hh:198
void SetVertexCount(unsigned int _count)
Resize the vertex array.
void GetAABB(ignition::math::Vector3d &_center, ignition::math::Vector3d &_minXYZ, ignition::math::Vector3d &_maxXYZ) const
Get AABB coordinate.
void AddSubMesh(SubMesh *_child)
Add a submesh mesh.
ignition::math::Vector2d TexCoord(unsigned int _i) const
Get a tex coord.
void CopyVertices(const std::vector< ignition::math::Vector3d > &_verts)
Copy vertices from a vector.
void AddNormal(const ignition::math::Vector3d &_n)
Add a normal to the mesh.
void SetPath(const std::string &_path)
Set the path which contains the mesh resource.
void Scale(double _factor)
Scale all vertices by _factor.
std::string GetName() const
Get the name of this mesh.
A child mesh.
Definition: Mesh.hh:214
void SetIndexCount(unsigned int _count)
Resize the index array.
void AddNodeAssignment(unsigned int _vertex, unsigned int _node, float _weight)
Add a vertex - skeleton node assignment.
void GenSphericalTexCoord(const ignition::math::Vector3d &_center)
Generate texture coordinates using spherical projection from center.
std::string GetPath() const
Get the path which contains the mesh resource.
void SetNormalCount(unsigned int _count)
Resize the normal array.
int GetMaterialIndex(const Material *_mat) const
Get the index of material.
ignition::math::Vector3d Normal(unsigned int _i) const
Get a normal.
bool HasSkeleton() const
Return true if mesh is attached to a skeleton.
ignition::math::Vector3d Max() const
Get the maximun X, Y, Z values.
unsigned int GetVertexIndex(const ignition::math::Vector3d &_v) const
Get the index of the vertex.
unsigned int GetNormalCount() const
Return the number of normals.
unsigned int GetMaxIndex() const
Get the highest index value.
void AddIndex(unsigned int _i)
Add an index to the mesh.
bool HasVertex(const ignition::math::Vector3d &_v) const
Return true if this submesh has the vertex.
PrimitiveType
An enumeration of the geometric mesh primitives.
Definition: Mesh.hh:217
unsigned int GetIndexCount() const
Return the number of indices.
void SetScale(const ignition::math::Vector3d &_factor)
Scale all vertices by the _factor vector.
void SetScale(const ignition::math::Vector3d &_factor)
Scale all vertices by the _factor vector.
A skeleton.
Definition: Skeleton.hh:52
void SetTexCoord(unsigned int _i, const ignition::math::Vector2d &_t)
Set a tex coord.
void AddVertex(const ignition::math::Vector3d &_v)
Add a vertex to the mesh.
const SubMesh * GetSubMesh(unsigned int _i) const
Get a child mesh.
void SetName(const std::string &_n)
Set the name of this mesh.
NodeAssignment GetNodeAssignment(unsigned int _i) const
Get a vertex - skeleton node assignment.
PrimitiveType GetPrimitiveType() const
Get the primitive type.
unsigned int GetVertexCount() const
Return the number of vertices.
unsigned int GetNodeAssignmentsCount() const
Return the number of vertex - skeleton node assignments.
Encapsulates description of a material.
Definition: common/Material.hh:34
void FillArrays(float **_vertArr, int **_indArr) const
Put all the data into flat arrays.
unsigned int nodeIndex
node (or bone) index
Definition: Mesh.hh:207
Skeleton * GetSkeleton() const
Get the skeleton to which this mesh is attached.
NodeAssignment()
Constructor.
unsigned int GetNormalCount() const
Return the number of normals.
unsigned int GetIndexCount() const
Return the number of indicies.
void SetNormal(unsigned int _i, const ignition::math::Vector3d &_n)
Set a normal.
void SetPrimitiveType(PrimitiveType _type)
Set the primitive type.
ignition::math::Vector3d Max() const
Get the maximum X, Y, Z values from all the vertices.
void CopyNormals(const std::vector< ignition::math::Vector3d > &_norms)
Copy normals from a vector.
A 3D mesh.
Definition: Mesh.hh:42
void Translate(const ignition::math::Vector3d &_vec)
Move all vertices in all submeshes by _vec.
void Translate(const ignition::math::Vector3d &_vec)
Move all vertices by _vec.
void SetName(const std::string &_n)
Set the name of this mesh.
ignition::math::Vector3d Vertex(unsigned int _i) const
Get a vertex.
unsigned int GetTexCoordCount() const
Return the number of texture coordinates.
void GenSphericalTexCoord(const ignition::math::Vector3d &_center)
Generate texture coordinates using spherical projection from center.
virtual ~Mesh()
Destructor.
void SetSkeleton(Skeleton *_skel)
Set the mesh skeleton.
unsigned int GetTexCoordCount() const
Return the number of texture coordinates.
unsigned int GetVertexCount() const
Return the number of vertices.
std::string GetName() const
Get the name of this mesh.
void RecalculateNormals()
Recalculate all the normals of each face defined by three indices.
void AddTexCoord(double _u, double _v)
Add a texture coord to the mesh.
unsigned int vertexIndex
index of the vertex
Definition: Mesh.hh:204
const Material * GetMaterial(int _index) const
Get a material.