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
52 public:
void SetPath(
const std::string &_path);
60 public:
void SetName(
const std::string &_n);
68 public: ignition::math::Vector3d
Max()
const;
72 public: ignition::math::Vector3d
Min()
const;
132 public:
void FillArrays(
float **_vertArr,
int **_indArr)
const;
142 public:
void GetAABB(ignition::math::Vector3d &_center,
143 ignition::math::Vector3d &_minXYZ,
144 ignition::math::Vector3d &_maxXYZ)
const;
150 const ignition::math::Vector3d &_center);
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;
249 const std::vector<ignition::math::Vector3d> &_verts);
254 const std::vector<ignition::math::Vector3d> &_norms);
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);
311 public: ignition::math::Vector3d
Vertex(
unsigned int _i)
const;
317 const ignition::math::Vector3d &_v);
322 public: ignition::math::Vector3d
Normal(
unsigned int _i)
const;
328 const ignition::math::Vector3d &_n);
333 public: ignition::math::Vector2d
TexCoord(
unsigned int _i)
const;
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;
386 public:
bool HasVertex(
const ignition::math::Vector3d &_v)
const;
392 const ignition::math::Vector3d &_v)
const;
397 public:
void FillArrays(
float **_vertArr,
int **_indArr)
const;
406 const ignition::math::Vector3d &_center);
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;
446 private:
int materialIndex;
449 private: std::string name;
common
Definition FuelModelDatabase.hh:37
Encapsulates description of a material.
Definition common/Material.hh:35
A 3D mesh.
Definition Mesh.hh:43
unsigned int GetSubMeshCount() const
Get the number of children.
void Translate(const ignition::math::Vector3d &_vec)
Move all vertices in all submeshes by _vec.
void Center(const ignition::math::Vector3d &_center=ignition::math::Vector3d::Zero)
Move the center of the mesh to the given coordinate.
unsigned int GetTexCoordCount() const
Return the number of texture coordinates.
std::string GetPath() const
Get the path which contains the mesh resource.
int GetMaterialIndex(const Material *_mat) const
Get the index of material.
const SubMesh * GetSubMesh(unsigned int _i) const
Get a child mesh.
void FillArrays(float **_vertArr, int **_indArr) const
Put all the data into flat arrays.
void RecalculateNormals()
Recalculate all the normals of each face defined by three indices.
unsigned int GetIndexCount() const
Return the number of indices.
void SetSkeleton(Skeleton *_skel)
Set the mesh skeleton.
void SetPath(const std::string &_path)
Set the path which contains the mesh resource.
void SetName(const std::string &_n)
Set the name of this mesh.
Skeleton * GetSkeleton() const
Get the skeleton to which this mesh is attached.
int AddMaterial(Material *_mat)
Add a material to the mesh.
unsigned int GetNormalCount() const
Return the number of normals.
virtual ~Mesh()
Destructor.
ignition::math::Vector3d Min() const
Get the minimum X, Y, Z values.
ignition::math::Vector3d Max() const
Get the maximun X, Y, Z values.
std::string GetName() const
Get the name of this mesh.
unsigned int GetVertexCount() const
Return the number of vertices.
unsigned int GetMaterialCount() const
Get the number of materials.
void GetAABB(ignition::math::Vector3d &_center, ignition::math::Vector3d &_minXYZ, ignition::math::Vector3d &_maxXYZ) const
Get AABB coordinate.
const SubMesh * GetSubMesh(const std::string &_name) const
Get a child mesh by name.
void AddSubMesh(SubMesh *_child)
Add a submesh mesh.
bool HasSkeleton() const
Return true if mesh is attached to a skeleton.
void SetScale(const ignition::math::Vector3d &_factor)
Scale all vertices by the _factor vector.
void GenSphericalTexCoord(const ignition::math::Vector3d &_center)
Generate texture coordinates using spherical projection from center.
void Scale(double _factor)
Scale all vertices by _factor.
const Material * GetMaterial(int _index) const
Get a material.
Vertex to node weighted assignement for skeleton animation visualization.
Definition Mesh.hh:199
unsigned int nodeIndex
node (or bone) index
Definition Mesh.hh:207
NodeAssignment()
Constructor.
float weight
the weight (between 0 and 1)
Definition Mesh.hh:210
unsigned int vertexIndex
index of the vertex
Definition Mesh.hh:204
A skeleton.
Definition Skeleton.hh:53
A child mesh.
Definition Mesh.hh:215
void SetPrimitiveType(PrimitiveType _type)
Set the primitive type.
void Translate(const ignition::math::Vector3d &_vec)
Move all vertices by _vec.
void AddNormal(double _x, double _y, double _z)
Add a normal to the mesh.
ignition::math::Vector3d Vertex(unsigned int _i) const
Get a vertex.
void AddVertex(const ignition::math::Vector3d &_v)
Add a vertex to the mesh.
void SetVertexCount(unsigned int _count)
Resize the vertex array.
void Center(const ignition::math::Vector3d &_center=ignition::math::Vector3d::Zero)
Move the center of the submesh to the given coordinate.
void CopyNormals(const std::vector< ignition::math::Vector3d > &_norms)
Copy normals from a vector.
NodeAssignment GetNodeAssignment(unsigned int _i) const
Get a vertex - skeleton node assignment.
PrimitiveType
An enumeration of the geometric mesh primitives.
Definition Mesh.hh:217
@ LINES
Definition Mesh.hh:217
@ LINESTRIPS
Definition Mesh.hh:217
@ TRIFANS
Definition Mesh.hh:218
@ TRIANGLES
Definition Mesh.hh:217
@ TRISTRIPS
Definition Mesh.hh:218
@ POINTS
Definition Mesh.hh:217
unsigned int GetTexCoordCount() const
Return the number of texture coordinates.
void AddTexCoord(double _u, double _v)
Add a texture coord to the mesh.
void SetTexCoord(unsigned int _i, const ignition::math::Vector2d &_t)
Set a tex coord.
void SetNormal(unsigned int _i, const ignition::math::Vector3d &_n)
Set a normal.
void SetVertex(unsigned int _i, const ignition::math::Vector3d &_v)
Set a vertex.
bool HasVertex(const ignition::math::Vector3d &_v) const
Return true if this submesh has the vertex.
void AddVertex(double _x, double _y, double _z)
Add a vertex to the mesh.
unsigned int GetNodeAssignmentsCount() const
Return the number of vertex - skeleton node assignments.
void SetMaterialIndex(unsigned int _index)
Set the material index.
ignition::math::Vector3d Normal(unsigned int _i) const
Get a normal.
void AddNodeAssignment(unsigned int _vertex, unsigned int _node, float _weight)
Add a vertex - skeleton node assignment.
void FillArrays(float **_vertArr, int **_indArr) const
Put all the data into flat arrays.
void AddIndex(unsigned int _i)
Add an index to the mesh.
void RecalculateNormals()
Recalculate all the normals.
unsigned int GetIndexCount() const
Return the number of indicies.
void SetNormalCount(unsigned int _count)
Resize the normal array.
unsigned int GetMaterialIndex() const
Get the material index.
void SetName(const std::string &_n)
Set the name of this mesh.
unsigned int GetNormalCount() const
Return the number of normals.
ignition::math::Vector3d Min() const
Get the minimum X, Y, Z values from all the vertices.
ignition::math::Vector3d Max() const
Get the maximum X, Y, Z values from all the vertices.
std::string GetName() const
Get the name of this mesh.
void SetTexCoordCount(unsigned int _count)
Resize the texture coordinate array.
unsigned int GetVertexCount() const
Return the number of vertices.
virtual ~SubMesh()
Destructor.
unsigned int GetIndex(unsigned int _i) const
Get an index.
unsigned int GetMaxIndex() const
Get the highest index value.
unsigned int GetVertexIndex(const ignition::math::Vector3d &_v) const
Get the index of the vertex.
SubMesh(const SubMesh *_mesh)
Copy Constructor.
ignition::math::Vector2d TexCoord(unsigned int _i) const
Get a tex coord.
void SetScale(const ignition::math::Vector3d &_factor)
Scale all vertices by the _factor vector.
void GenSphericalTexCoord(const ignition::math::Vector3d &_center)
Generate texture coordinates using spherical projection from center.
void Scale(double _factor)
Scale all vertices by _factor.
void AddNormal(const ignition::math::Vector3d &_n)
Add a normal to the mesh.
PrimitiveType GetPrimitiveType() const
Get the primitive type.
void CopyVertices(const std::vector< ignition::math::Vector3d > &_verts)
Copy vertices from a vector.
void SetIndexCount(unsigned int _count)
Resize the index array.
Forward declarations for the common classes.
Definition Animation.hh:27