A 3D mesh. More...
#include <gz/common/Mesh.hh>
Public Member Functions | |
Mesh () | |
Constructor. More... | |
virtual | ~Mesh () |
Destructor. More... | |
void | AABB (gz::math::Vector3d &_center, gz::math::Vector3d &_minXYZ, gz::math::Vector3d &_maxXYZ) const |
Get axis-aligned bounding box in the mesh frame. More... | |
int | AddMaterial (const MaterialPtr &_mat) |
Add a material to the mesh. More... | |
std::weak_ptr< SubMesh > | AddSubMesh (const SubMesh &_child) |
Add a submesh mesh. This can be an expensive since _child is copied into this mesh. More... | |
std::weak_ptr< SubMesh > | AddSubMesh (std::unique_ptr< SubMesh > _child) |
Add a submesh mesh. This transfers ownership of _child to this mesh. The value of _child after this call is nullptr. More... | |
void | Center (const gz::math::Vector3d &_center=gz::math::Vector3d::Zero) |
Move the center of the mesh to the given coordinate in the mesh frame. This will move all the vertices in all submeshes. More... | |
void | FillArrays (double **_vertArr, int **_indArr) const |
Put all the data into flat arrays. More... | |
void | GenSphericalTexCoord (const gz::math::Vector3d &_center) |
Generate texture coordinates using spherical projection from center. More... | |
bool | HasSkeleton () const |
Check if mesh is attached to a skeleton. More... | |
unsigned int | IndexCount () const |
Get the number of indices. More... | |
int | IndexOfMaterial (const Material *_mat) const |
Get the index of material. More... | |
MaterialPtr | MaterialByIndex (const unsigned int _index) const |
Get a material by index. More... | |
unsigned int | MaterialCount () const |
Get the number of materials. More... | |
gz::math::Vector3d | Max () const |
Get the maximun X, Y, Z values. More... | |
SkeletonPtr | MeshSkeleton () const |
Get the skeleton to which this mesh is attached. More... | |
gz::math::Vector3d | Min () const |
Get the minimum X, Y, Z values. More... | |
std::string | Name () const |
Get the name of this mesh. More... | |
unsigned int | NormalCount () const |
Get the number of normals. More... | |
std::string | Path () const |
Get the path which contains the mesh resource. More... | |
void | RecalculateNormals () |
Recalculate all the normals of each face defined by three indices. More... | |
void | Scale (const gz::math::Vector3d &_factor) |
Scale all vertices by _factor. More... | |
void | SetName (const std::string &_name) |
Set the name of this mesh. More... | |
void | SetPath (const std::string &_path) |
Set the path which contains the mesh resource. More... | |
void | SetScale (const gz::math::Vector3d &_factor) |
Set the scale all vertices. More... | |
void | SetSkeleton (const SkeletonPtr &_skel) |
Set the mesh skeleton. More... | |
std::weak_ptr< SubMesh > | SubMeshByIndex (const unsigned int _index) const |
Get a child submesh by index. More... | |
std::weak_ptr< SubMesh > | SubMeshByName (const std::string &_name) const |
Get a child submesh by name. More... | |
unsigned int | SubMeshCount () const |
Get the number of child submeshes. More... | |
unsigned int | TexCoordCount () const |
Get the number of texture coordinates. More... | |
void | Translate (const gz::math::Vector3d &_vec) |
Move all vertices in all submeshes by _vec. More... | |
unsigned int | VertexCount () const |
Get the number of vertices. More... | |
double | Volume () const |
Compute the volume of this mesh. The primitive type must be TRIANGLES. More... | |
Detailed Description
A 3D mesh.
Constructor & Destructor Documentation
◆ Mesh()
Mesh | ( | ) |
Constructor.
◆ ~Mesh()
|
virtual |
Destructor.
Member Function Documentation
◆ AABB()
void AABB | ( | gz::math::Vector3d & | _center, |
gz::math::Vector3d & | _minXYZ, | ||
gz::math::Vector3d & | _maxXYZ | ||
) | const |
Get axis-aligned bounding box in the mesh frame.
- Parameters
-
[out] _center Center of the bounding box [out] _minXYZ Bounding box minimum values [out] _maxXYZ Bounding box maximum values
◆ AddMaterial()
int AddMaterial | ( | const MaterialPtr & | _mat | ) |
Add a material to the mesh.
- Parameters
-
[in] _mat The material to add.
- Returns
- Index of this material
◆ AddSubMesh() [1/2]
std::weak_ptr<SubMesh> AddSubMesh | ( | const SubMesh & | _child | ) |
Add a submesh mesh. This can be an expensive since _child is copied into this mesh.
- Parameters
-
[in] _child the submesh
- Returns
- Weak pointer to the added submesh
◆ AddSubMesh() [2/2]
std::weak_ptr<SubMesh> AddSubMesh | ( | std::unique_ptr< SubMesh > | _child | ) |
Add a submesh mesh. This transfers ownership of _child to this mesh. The value of _child after this call is nullptr.
- Parameters
-
[in] _child the submesh
- Returns
- Weak pointer to the added submesh
◆ Center()
void Center | ( | const gz::math::Vector3d & | _center = gz::math::Vector3d::Zero | ) |
Move the center of the mesh to the given coordinate in the mesh frame. This will move all the vertices in all submeshes.
- Parameters
-
[in] _center Location of the mesh center.
◆ FillArrays()
void FillArrays | ( | double ** | _vertArr, |
int ** | _indArr | ||
) | const |
Put all the data into flat arrays.
- Parameters
-
[out] _vertArr the vertex array [out] _indArr the index array
◆ GenSphericalTexCoord()
void GenSphericalTexCoord | ( | const gz::math::Vector3d & | _center | ) |
Generate texture coordinates using spherical projection from center.
- Parameters
-
[in] _center Center of the projection
◆ HasSkeleton()
bool HasSkeleton | ( | ) | const |
Check if mesh is attached to a skeleton.
- Returns
- True if mesh is attached to a skeleton.
◆ IndexCount()
unsigned int IndexCount | ( | ) | const |
Get the number of indices.
- Returns
- The number of indices
◆ IndexOfMaterial()
int IndexOfMaterial | ( | const Material * | _mat | ) | const |
Get the index of material.
- Parameters
-
[in] _mat The material
- Returns
- The index of the material or -1 if not found, or _mat is null.
◆ MaterialByIndex()
MaterialPtr MaterialByIndex | ( | const unsigned int | _index | ) | const |
Get a material by index.
- Parameters
-
[in] _index The index of the material.
- Returns
- The material or NULL if the index is out of bounds
◆ MaterialCount()
unsigned int MaterialCount | ( | ) | const |
Get the number of materials.
- Returns
- The number of materials
◆ Max()
gz::math::Vector3d Max | ( | ) | const |
Get the maximun X, Y, Z values.
- Returns
- The upper bounds of the bounding box
◆ MeshSkeleton()
SkeletonPtr MeshSkeleton | ( | ) | const |
Get the skeleton to which this mesh is attached.
- Returns
- Pointer to skeleton or nullptr if none is present.
◆ Min()
gz::math::Vector3d Min | ( | ) | const |
Get the minimum X, Y, Z values.
- Returns
- The lower bounds of the bounding box
◆ Name()
std::string Name | ( | ) | const |
Get the name of this mesh.
- Returns
- Name of the mesh.
◆ NormalCount()
unsigned int NormalCount | ( | ) | const |
Get the number of normals.
- Returns
- The number of normals
◆ Path()
std::string Path | ( | ) | const |
Get the path which contains the mesh resource.
- Returns
- The path to the mesh resource
◆ RecalculateNormals()
void RecalculateNormals | ( | ) |
Recalculate all the normals of each face defined by three indices.
◆ Scale()
void Scale | ( | const gz::math::Vector3d & | _factor | ) |
Scale all vertices by _factor.
- Parameters
-
_factor Scaling factor
◆ SetName()
void SetName | ( | const std::string & | _name | ) |
Set the name of this mesh.
- Parameters
-
[in] _name The name to set
◆ SetPath()
void SetPath | ( | const std::string & | _path | ) |
Set the path which contains the mesh resource.
- Parameters
-
[in] _path The file path
◆ SetScale()
void SetScale | ( | const gz::math::Vector3d & | _factor | ) |
Set the scale all vertices.
- Parameters
-
[in] _factor Scaling vector
◆ SetSkeleton()
void SetSkeleton | ( | const SkeletonPtr & | _skel | ) |
Set the mesh skeleton.
- Parameters
-
[in] _skel Skeleton to attach to the mesh.
◆ SubMeshByIndex()
std::weak_ptr<SubMesh> SubMeshByIndex | ( | const unsigned int | _index | ) | const |
Get a child submesh by index.
- Parameters
-
[in] _index Index of the submesh
- Returns
- The submesh or nullptr if the index is out of bounds.
◆ SubMeshByName()
std::weak_ptr<SubMesh> SubMeshByName | ( | const std::string & | _name | ) | const |
Get a child submesh by name.
- Parameters
-
[in] _name Name of the submesh.
- Returns
- The submesh or nullptr if the _name is not found.
◆ SubMeshCount()
unsigned int SubMeshCount | ( | ) | const |
Get the number of child submeshes.
- Returns
- The number of submeshes.
◆ TexCoordCount()
unsigned int TexCoordCount | ( | ) | const |
Get the number of texture coordinates.
- Returns
- The number of texture coordinates
◆ Translate()
void Translate | ( | const gz::math::Vector3d & | _vec | ) |
Move all vertices in all submeshes by _vec.
- Parameters
-
[in] _vec Amount to translate vertices.
◆ VertexCount()
unsigned int VertexCount | ( | ) | const |
Get the number of vertices.
- Returns
- The number of vertices
◆ Volume()
double Volume | ( | ) | const |
Compute the volume of this mesh. The primitive type must be TRIANGLES.
This function utilizes the mesh volume formula from "Efficient feature extraction for 2d/3d objects in mesh representation" by Cha Zhang and Tsuhan Chen. Link: http://chenlab.ece.cornell.edu/Publication/Cha/icip01_Cha.pdf. The formula does not check for a closed (water tight) mesh.
- Returns
- The mesh's volume. The volume can be zero if the primitive type of the submeshes is not TRIANGLES, or there are no submeshes.
The documentation for this class was generated from the following file: