Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
aiMaterial Struct Reference

Data structure for a material. More...

#include <material.h>

Public Member Functions

aiReturn AddBinaryProperty (const void *pInput, unsigned int pSizeInBytes, const char *pKey, unsigned int type, unsigned int index, aiPropertyTypeInfo pType)
 Add a property with a given key and type info to the material structure. More...
 
aiReturn AddProperty (const aiColor3D *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
aiReturn AddProperty (const aiColor4D *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
aiReturn AddProperty (const aiString *pInput, const char *pKey, unsigned int type=0, unsigned int index=0)
 Add a string property with a given key and type info to the material structure. More...
 
aiReturn AddProperty (const aiUVTransform *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
aiReturn AddProperty (const aiVector3D *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
aiReturn AddProperty (const double *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
aiReturn AddProperty (const float *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
aiReturn AddProperty (const int *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 
template<class TYPE >
aiReturn AddProperty (const TYPE *pInput, unsigned int pNumValues, const char *pKey, unsigned int type=0, unsigned int index=0)
 Add a property with a given key to the material structure. More...
 
 aiMaterial ()
 
void Clear ()
 Removes all properties from the material. More...
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, ai_real &pOut) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, ai_real *pOut, unsigned int *pMax) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, aiColor3D &pOut) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, aiColor4D &pOut) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, aiString &pOut) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, aiUVTransform &pOut) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, int &pOut) const
 
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, int *pOut, unsigned int *pMax) const
 
template<typename Type >
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, Type &pOut) const
 Retrieve a Type value with a specific key from the material. More...
 
template<typename Type >
aiReturn Get (const char *pKey, unsigned int type, unsigned int idx, Type *pOut, unsigned int *pMax) const
 Retrieve an array of Type values with a specific key from the material. More...
 
aiString GetName () const
 Returns the name of the material. More...
 
aiReturn GetTexture (aiTextureType type, unsigned int index, C_STRUCT aiString *path, aiTextureMapping *mapping=NULL, unsigned int *uvindex=NULL, ai_real *blend=NULL, aiTextureOp *op=NULL, aiTextureMapMode *mapmode=NULL) const
 Helper function to get all parameters pertaining to a particular texture slot from a material. More...
 
unsigned int GetTextureCount (aiTextureType type) const
 Get the number of textures for a particular texture type. More...
 
aiReturn RemoveProperty (const char *pKey, unsigned int type=0, unsigned int index=0)
 Remove a given key from the list. More...
 
 ~aiMaterial ()
 

Static Public Member Functions

static void CopyPropertyList (aiMaterial *pcDest, const aiMaterial *pcSrc)
 Copy the property list of a material. More...
 

Public Attributes

unsigned int mNumAllocated
 Storage allocated. More...
 
unsigned int mNumProperties
 Number of properties in the data base. More...
 
C_STRUCT aiMaterialProperty ** mProperties
 List of all material properties loaded. More...
 

Detailed Description

Data structure for a material.

Material data is stored using a key-value structure. A single key-value pair is called a 'material property'. C++ users should use the provided member functions of aiMaterial to process material properties, C users have to stick with the aiMaterialGetXXX family of unbound functions. The library defines a set of standard keys (AI_MATKEY_XXX).

Constructor & Destructor Documentation

◆ aiMaterial()

aiMaterial::aiMaterial ( )

◆ ~aiMaterial()

aiMaterial::~aiMaterial ( )

Member Function Documentation

◆ AddBinaryProperty()

aiReturn aiMaterial::AddBinaryProperty ( const void *  pInput,
unsigned int  pSizeInBytes,
const char *  pKey,
unsigned int  type,
unsigned int  index,
aiPropertyTypeInfo  pType 
)

Add a property with a given key and type info to the material structure.

Parameters
pInputPointer to input data
pSizeInBytesSize of input data
pKeyKey/Usage of the property (AI_MATKEY_XXX)
typeSet by the AI_MATKEY_XXX macro
indexSet by the AI_MATKEY_XXX macro
pTypeType information hint

◆ AddProperty() [1/9]

aiReturn aiMaterial::AddProperty ( const aiColor3D pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [2/9]

aiReturn aiMaterial::AddProperty ( const aiColor4D pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [3/9]

aiReturn aiMaterial::AddProperty ( const aiString pInput,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

Add a string property with a given key and type info to the material structure.

Parameters
pInputInput string
pKeyKey/Usage of the property (AI_MATKEY_XXX)
typeSet by the AI_MATKEY_XXX macro
indexSet by the AI_MATKEY_XXX macro

◆ AddProperty() [4/9]

aiReturn aiMaterial::AddProperty ( const aiUVTransform pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [5/9]

aiReturn aiMaterial::AddProperty ( const aiVector3D pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [6/9]

aiReturn aiMaterial::AddProperty ( const double *  pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [7/9]

aiReturn aiMaterial::AddProperty ( const float *  pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [8/9]

aiReturn aiMaterial::AddProperty ( const int *  pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

◆ AddProperty() [9/9]

template<class TYPE >
aiReturn aiMaterial::AddProperty ( const TYPE *  pInput,
unsigned int  pNumValues,
const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

Add a property with a given key to the material structure.

Parameters
pInputPointer to the input data
pNumValuesNumber of values in the array
pKeyKey/Usage of the property (AI_MATKEY_XXX)
typeSet by the AI_MATKEY_XXX macro
indexSet by the AI_MATKEY_XXX macro

◆ Clear()

void aiMaterial::Clear ( )

Removes all properties from the material.

The data array remains allocated so adding new properties is quite fast.

◆ CopyPropertyList()

static void aiMaterial::CopyPropertyList ( aiMaterial pcDest,
const aiMaterial pcSrc 
)
static

Copy the property list of a material.

Parameters
pcDestDestination material
pcSrcSource material

◆ Get() [1/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
ai_real pOut 
) const

◆ Get() [2/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
ai_real pOut,
unsigned int *  pMax 
) const

◆ Get() [3/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
aiColor3D pOut 
) const

◆ Get() [4/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
aiColor4D pOut 
) const

◆ Get() [5/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
aiString pOut 
) const

◆ Get() [6/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
aiUVTransform pOut 
) const

◆ Get() [7/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
int &  pOut 
) const

◆ Get() [8/10]

aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
int *  pOut,
unsigned int *  pMax 
) const

◆ Get() [9/10]

template<typename Type >
aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
Type &  pOut 
) const

Retrieve a Type value with a specific key from the material.

Parameters
pKeyKey to search for. One of the AI_MATKEY_XXX constants.
typeSpecifies the type of the texture to be retrieved ( e.g. diffuse, specular, height map ...)
idxIndex of the texture to be retrieved.
pOutReference to receive the output value

◆ Get() [10/10]

template<typename Type >
aiReturn aiMaterial::Get ( const char *  pKey,
unsigned int  type,
unsigned int  idx,
Type *  pOut,
unsigned int *  pMax 
) const

Retrieve an array of Type values with a specific key from the material.

Parameters
pKeyKey to search for. One of the AI_MATKEY_XXX constants.
type.. set by AI_MATKEY_XXX
idx.. set by AI_MATKEY_XXX
pOutPointer to a buffer to receive the result.
pMaxSpecifies the size of the given buffer, in Type's. Receives the number of values (not bytes!) read. NULL is a valid value for this parameter.

◆ GetName()

aiString aiMaterial::GetName ( ) const

Returns the name of the material.

Returns
The name of the material.

◆ GetTexture()

aiReturn aiMaterial::GetTexture ( aiTextureType  type,
unsigned int  index,
C_STRUCT aiString path,
aiTextureMapping mapping = NULL,
unsigned int *  uvindex = NULL,
ai_real blend = NULL,
aiTextureOp op = NULL,
aiTextureMapMode mapmode = NULL 
) const

Helper function to get all parameters pertaining to a particular texture slot from a material.

This function is provided just for convenience, you could also read the single material properties manually.

Parameters
typeSpecifies the type of the texture to be retrieved ( e.g. diffuse, specular, height map ...)
indexIndex of the texture to be retrieved. The function fails if there is no texture of that type with this index. GetTextureCount() can be used to determine the number of textures per texture type.
pathReceives the path to the texture. Use aiScene::GetEmbeddedTexture() method to determine if returned path is an image file to be opened or a string key of embedded texture stored in the corresponding scene (could be a '*' followed by the id of the texture in case of no name) NULL is a valid value.
mappingThe texture mapping. NULL is allowed as value.
uvindexReceives the UV index of the texture. NULL is a valid value.
blendReceives the blend factor for the texture NULL is a valid value.
opReceives the texture operation to be performed between this texture and the previous texture. NULL is allowed as value.
mapmodeReceives the mapping modes to be used for the texture. The parameter may be NULL but if it is a valid pointer it MUST point to an array of 3 aiTextureMapMode's (one for each axis: UVW order (=XYZ)).

◆ GetTextureCount()

unsigned int aiMaterial::GetTextureCount ( aiTextureType  type) const

Get the number of textures for a particular texture type.

Parameters
typeTexture type to check for
Returns
Number of textures for this type.
Note
A texture can be easily queried using GetTexture()

◆ RemoveProperty()

aiReturn aiMaterial::RemoveProperty ( const char *  pKey,
unsigned int  type = 0,
unsigned int  index = 0 
)

Remove a given key from the list.

The function fails if the key isn't found

Parameters
pKeyKey to be deleted
typeSet by the AI_MATKEY_XXX macro
indexSet by the AI_MATKEY_XXX macro

Member Data Documentation

◆ mNumAllocated

unsigned int aiMaterial::mNumAllocated

Storage allocated.

◆ mNumProperties

unsigned int aiMaterial::mNumProperties

Number of properties in the data base.

◆ mProperties

C_STRUCT aiMaterialProperty** aiMaterial::mProperties

List of all material properties loaded.


The documentation for this struct was generated from the following file: