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;
231 public:
void SetName(
const std::string &_n);
235 public: std::string GetName()
const;
239 public:
void SetPrimitiveType(PrimitiveType _type);
243 public: PrimitiveType GetPrimitiveType()
const;
247 public:
void CopyVertices(
248 const std::vector<ignition::math::Vector3d> &_verts);
252 public:
void CopyNormals(
253 const std::vector<ignition::math::Vector3d> &_norms);
257 public:
void SetVertexCount(
unsigned int _count);
261 public:
void SetIndexCount(
unsigned int _count);
265 public:
void SetNormalCount(
unsigned int _count);
269 public:
void SetTexCoordCount(
unsigned int _count);
273 public:
void AddIndex(
unsigned int _i);
277 public:
void AddVertex(
const ignition::math::Vector3d &_v);
283 public:
void AddVertex(
double _x,
double _y,
double _z);
287 public:
void AddNormal(
const ignition::math::Vector3d &_n);
293 public:
void AddNormal(
double _x,
double _y,
double _z);
298 public:
void AddTexCoord(
double _u,
double _v);
304 public:
void AddNodeAssignment(
unsigned int _vertex,
unsigned int _node,
310 public: ignition::math::Vector3d Vertex(
unsigned int _i)
const;
315 public:
void SetVertex(
unsigned int _i,
316 const ignition::math::Vector3d &_v);
321 public: ignition::math::Vector3d Normal(
unsigned int _i)
const;
326 public:
void SetNormal(
unsigned int _i,
327 const ignition::math::Vector3d &_n);
332 public: ignition::math::Vector2d TexCoord(
unsigned int _i)
const;
341 public:
void SetTexCoord(
unsigned int _i,
342 const ignition::math::Vector2d &_t);
346 public:
unsigned int GetIndex(
unsigned int _i)
const;
350 public: ignition::math::Vector3d Max()
const;
354 public: ignition::math::Vector3d Min()
const;
357 public:
unsigned int GetVertexCount()
const;
360 public:
unsigned int GetNormalCount()
const;
363 public:
unsigned int GetIndexCount()
const;
366 public:
unsigned int GetTexCoordCount()
const;
369 public:
unsigned int GetNodeAssignmentsCount()
const;
372 public:
unsigned int GetMaxIndex()
const;
377 public:
void SetMaterialIndex(
unsigned int _index);
380 public:
unsigned int GetMaterialIndex()
const;
385 public:
bool HasVertex(
const ignition::math::Vector3d &_v)
const;
390 public:
unsigned int GetVertexIndex(
391 const ignition::math::Vector3d &_v)
const;
396 public:
void FillArrays(
float **_vertArr,
int **_indArr)
const;
399 public:
void RecalculateNormals();
404 public:
void GenSphericalTexCoord(
405 const ignition::math::Vector3d &_center);
409 public:
void Scale(
double _factor);
414 public:
void Center(
const ignition::math::Vector3d &_center =
415 ignition::math::Vector3d::Zero);
419 public:
void Translate(
const ignition::math::Vector3d &_vec);
423 public:
void SetScale(
const ignition::math::Vector3d &_factor);
426 private: std::vector<ignition::math::Vector3d> vertices;
429 private: std::vector<ignition::math::Vector3d> normals;
432 private: std::vector<ignition::math::Vector2d> texCoords;
435 private: std::vector<unsigned int> indices;
438 private: std::vector<NodeAssignment> nodeAssignments;
441 private: PrimitiveType primitiveType;
445 private:
int materialIndex;
448 private: std::string name;
A 3D mesh.
Definition: Mesh.hh:42
PrimitiveType
An enumeration of the geometric mesh primitives.
Definition: Mesh.hh:217
A skeleton.
Definition: Skeleton.hh:52
Encapsulates description of a material.
Definition: common/Material.hh:34
A child mesh.
Definition: Mesh.hh:214
float weight
the weight (between 0 and 1)
Definition: Mesh.hh:210
unsigned int nodeIndex
node (or bone) index
Definition: Mesh.hh:207
Vertex to node weighted assignement for skeleton animation visualization.
Definition: Mesh.hh:198
unsigned int vertexIndex
index of the vertex
Definition: Mesh.hh:204