|
Avara3D 0.2.0
C++ API reference
|
Owns renderable geometry elements and their materials. More...
#include <a3d/mesh/Mesh.h>
Public Types | |
| enum class | ImportOptions : uint16_t { None = 0 , ImportMaterials = 1 << 1 , ImportAll = UINT16_MAX } |
| Selects optional resources imported with Mesh::FromFile(). More... | |
Public Member Functions | |
| Mesh (const std::string &name, std::unique_ptr< MeshElement > element, const std::shared_ptr< Material > &material) | |
Creates a named Mesh and takes ownership of element. More... | |
| Mesh (std::unique_ptr< MeshElement > element, const std::shared_ptr< Material > &material) | |
Creates a Mesh and takes ownership of element. More... | |
| Mesh (const std::string &name, std::vector< std::unique_ptr< MeshElement > > &elements, const std::vector< std::shared_ptr< Material > > &materials) | |
Creates a named Mesh by moving the elements in elements into the Mesh. More... | |
| Mesh (std::vector< std::unique_ptr< MeshElement > > &elements, const std::vector< std::shared_ptr< Material > > &materials) | |
Creates a Mesh by moving the elements in elements into the Mesh. More... | |
| std::optional< std::string > | name () const |
| Returns the optional mesh name. More... | |
| void | name (const std::string &name) |
| Sets the mesh name. More... | |
| const std::vector< std::unique_ptr< MeshElement > > & | elements () |
| Returns the MeshElement instances owned by this Mesh. More... | |
| const std::vector< std::shared_ptr< Material > > & | materials () |
| Returns the materials retained by this Mesh. More... | |
| std::shared_ptr< Material > | firstMaterial () const |
| Returns the first material, or nullptr if the material list is empty. More... | |
| std::shared_ptr< Material > | materialNamed (const std::string &name) const |
Returns the first material named name, or nullptr if no material matches. More... | |
| void | addMaterial (const std::shared_ptr< Material > &material) |
Appends material to the material list. More... | |
| void | insertMaterial (const std::shared_ptr< Material > &material, int index) |
Inserts material at index. More... | |
| void | removeMaterial (int index) |
Removes the material at index. More... | |
| void | replaceMaterial (int index, const std::shared_ptr< Material > &replacement) |
Replaces the material at index with replacement. More... | |
Static Public Member Functions | |
| static std::shared_ptr< Mesh > | FromFile (const std::filesystem::path &path, ImportOptions options=ImportOptions::ImportMaterials) |
| Imports the first mesh in a glTF file without applying scene-node transforms. More... | |
Owns renderable geometry elements and their materials.
A Mesh owns its MeshElement instances and shares ownership of its Material instances. When rendered, elements select materials by element index, wrapping through the material list when fewer materials than elements are present. If no material is available for an element, the renderer uses its default material.
|
strong |
Selects optional resources imported with Mesh::FromFile().
| Enumerator | |
|---|---|
| None | Do not import source materials. |
| ImportMaterials | Import materials referenced by the mesh. |
| ImportAll | Enable all supported Mesh import options. |
| a3d::Mesh::Mesh | ( | const std::string & | name, |
| std::unique_ptr< MeshElement > | element, | ||
| const std::shared_ptr< Material > & | material | ||
| ) |
Creates a named Mesh and takes ownership of element.
A non-null material is retained with shared ownership.
| a3d::Mesh::Mesh | ( | std::unique_ptr< MeshElement > | element, |
| const std::shared_ptr< Material > & | material | ||
| ) |
Creates a Mesh and takes ownership of element.
A non-null material is retained with shared ownership.
| a3d::Mesh::Mesh | ( | const std::string & | name, |
| std::vector< std::unique_ptr< MeshElement > > & | elements, | ||
| const std::vector< std::shared_ptr< Material > > & | materials | ||
| ) |
| a3d::Mesh::Mesh | ( | std::vector< std::unique_ptr< MeshElement > > & | elements, |
| const std::vector< std::shared_ptr< Material > > & | materials | ||
| ) |
| void a3d::Mesh::addMaterial | ( | const std::shared_ptr< Material > & | material | ) |
Appends material to the material list.
| const std::vector< std::unique_ptr< MeshElement > > & a3d::Mesh::elements | ( | ) |
Returns the MeshElement instances owned by this Mesh.
| std::shared_ptr< Material > a3d::Mesh::firstMaterial | ( | ) | const |
Returns the first material, or nullptr if the material list is empty.
|
static |
Imports the first mesh in a glTF file without applying scene-node transforms.
Mesh geometry is always imported; options controls optional associated resources.
| path | glTF or GLB file to import. |
| options | optional resources to import with the mesh. |
| std::runtime_error | if path has an unsupported file extension. |
| void a3d::Mesh::insertMaterial | ( | const std::shared_ptr< Material > & | material, |
| int | index | ||
| ) |
Inserts material at index.
| index | insertion position in the range [0, materials().size()]. |
| std::shared_ptr< Material > a3d::Mesh::materialNamed | ( | const std::string & | name | ) | const |
Returns the first material named name, or nullptr if no material matches.
| const std::vector< std::shared_ptr< Material > > & a3d::Mesh::materials | ( | ) |
Returns the materials retained by this Mesh.
| std::optional< std::string > a3d::Mesh::name | ( | ) | const |
Returns the optional mesh name.
| void a3d::Mesh::name | ( | const std::string & | name | ) |
Sets the mesh name.
| void a3d::Mesh::removeMaterial | ( | int | index | ) |
Removes the material at index.
| index | valid zero-based material index. |
| void a3d::Mesh::replaceMaterial | ( | int | index, |
| const std::shared_ptr< Material > & | replacement | ||
| ) |
Replaces the material at index with replacement.
| index | valid zero-based material index. |