|
Visual Computing Library
devel
|
A component that manages materials and textures for a mesh. More...
#include <vclib/mesh/components/materials.h>

Public Types | |
| using | ConstMaterialIterator = std::vector< Material >::const_iterator |
| Const iterator for the vector of materials. | |
| using | ConstTextureImageIterator = std::map< std::string, Image >::const_iterator |
| Const iterator for the map of texture images. | |
| using | MaterialIterator = std::vector< Material >::iterator |
| Iterator for the vector of materials. | |
| using | MaterialType = Material |
| Exposes the Material type used by this component. | |
| using | TextureImageIterator = std::map< std::string, Image >::iterator |
| Iterator for the map of texture images. | |
Public Member Functions | |
| void | clearMaterials () |
| Clears the vector of materials. | |
| Material & | material (uint i) |
| Returns a mutable reference to the material at the specified index. | |
| const Material & | material (uint i) const |
| Returns the material at the specified index. | |
| MaterialIterator | materialBegin () |
| Returns an iterator to the beginning of the vector of materials. | |
| ConstMaterialIterator | materialBegin () const |
| Returns a const iterator to the beginning of the vector of materials. | |
| MaterialIterator | materialEnd () |
| Returns an iterator to the end of the vector of materials. | |
| ConstMaterialIterator | materialEnd () const |
| Returns a const iterator to the end of the vector of materials. | |
| View< MaterialIterator > | materials () |
Returns a lightweight view object that stores the begin and end iterators of the vector of materials. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops: | |
| View< ConstMaterialIterator > | materials () const |
Returns a lightweight const view object that stores the begin and end iterators of the vector of materials. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops: | |
| Materials ()=default | |
| Default constructor for the Materials component. | |
| uint | materialsNumber () const |
| Returns the number of materials of the mesh. | |
| std::string & | meshBasePath () |
| Returns a reference to the mesh base path. | |
| const std::string & | meshBasePath () const |
| Returns the mesh base path. | |
| void | pushMaterial (const Material &mat) |
| Adds a material to the vector of materials. | |
| void | pushTextureImage (const std::string &texturePath, const Image &img) |
| Adds a texture image to the map of texture images. | |
| void | pushTextureImage (const std::string &texturePath, Image &&img) |
| Adds a texture image to the map of texture images (move version). | |
| const Image & | textureImage (const std::string &texturePath) const |
| Returns the texture image associated to the given texture path. | |
| TextureImageIterator | textureImageBegin () |
| Returns an iterator to the beginning of the map of texture images. | |
| ConstTextureImageIterator | textureImageBegin () const |
| Returns a const iterator to the beginning of the map of texture images. | |
| TextureImageIterator | textureImageEnd () |
| Returns an iterator to the end of the map of texture images. | |
| ConstTextureImageIterator | textureImageEnd () const |
| Returns a const iterator to the end of the map of texture images. | |
| View< TextureImageIterator > | textureImages () |
Returns a lightweight view object that stores the begin and end iterators of the map of texture images. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops: | |
| View< ConstTextureImageIterator > | textureImages () const |
Returns a lightweight const view object that stores the begin and end iterators of the map of texture images. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops: | |
| uint | textureImagesNumber () const |
| Returns the number of texture images stored in the component. | |
Protected Member Functions | |
| void | deserialize (std::istream &is) |
| template<typename Element > | |
| void | importFrom (const Element &e, bool=true) |
| void | serialize (std::ostream &os) const |
Private Types | |
| using | Base = Component< Materials, CompId::MATERIALS, detail::MData, void, false, false > |
Private Member Functions | |
| std::vector< Material > & | mats () |
| const std::vector< Material > & | mats () const |
| std::map< std::string, Image > & | txtImgs () |
| const std::map< std::string, Image > & | txtImgs () const |
Static Private Attributes | |
| static const Image | EMPTY_IMAGE |
A component that manages materials and textures for a mesh.
The Materials component stores a collection of materials and their associated texture images. It also keeps track of the base path of the mesh, which is used to resolve relative paths for texture files.
This component provides functionalities to:
|
inline |
Clears the vector of materials.
This function clears the vector of materials and the map of texture images, resetting the component to an empty state.
Returns a mutable reference to the material at the specified index.
| [in] | i | The index of the material. |
Returns the material at the specified index.
| [in] | i | The index of the material. |
|
inline |
Returns an iterator to the beginning of the vector of materials.
|
inline |
Returns a const iterator to the beginning of the vector of materials.
|
inline |
Returns an iterator to the end of the vector of materials.
|
inline |
Returns a const iterator to the end of the vector of materials.
|
inline |
Returns a lightweight view object that stores the begin and end iterators of the vector of materials. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops:
|
inline |
Returns a lightweight const view object that stores the begin and end iterators of the vector of materials. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops:
|
inline |
Returns the number of materials of the mesh.
|
inline |
Returns a reference to the mesh base path.
|
inline |
Returns the mesh base path.
This path is typically used to resolve relative paths of texture files.
Adds a material to the vector of materials.
| [in] | mat | The material to add. |
|
inline |
Adds a texture image to the map of texture images.
If an image with the same texture path already exists, it is overwritten.
| [in] | texturePath | The path of the texture. |
| [in] | img | The image to add. |
|
inline |
Adds a texture image to the map of texture images (move version).
If an image with the same texture path already exists, it is overwritten.
| [in] | texturePath | The path of the texture. |
| [in] | img | The image to add. |
Returns the texture image associated to the given texture path.
If no image is found for the given texture path, an empty image is returned.
| [in] | texturePath | The path of the texture. |
|
inline |
Returns an iterator to the beginning of the map of texture images.
|
inline |
Returns a const iterator to the beginning of the map of texture images.
|
inline |
Returns an iterator to the end of the map of texture images.
|
inline |
Returns a const iterator to the end of the map of texture images.
|
inline |
Returns a lightweight view object that stores the begin and end iterators of the map of texture images. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops:
|
inline |
Returns a lightweight const view object that stores the begin and end iterators of the map of texture images. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops:
|
inline |
Returns the number of texture images stored in the component.