C4 Engine
C4 Engine API Documentation


Defined in:  C4Geometries.h
Sets a material object.

void SetMaterialObject(int32 index, MaterialObject *object);

index The index of the material slot to which a material object is to be assigned.
object The new material object. This can be nullptr.
The SetMaterialObject function assigns the material object specified by the object parameter to a geometry node in the material slot specified by the index parameter. If object is nullptr, then the geometry node does not have a material in the specified material slot after this function is called. Otherwise, the reference count of the material object is incremented, and the new material object is assigned to the geometry node. The reference count of any material object previously assigned to the geometry node in the same slot is decremented, and the old material object is deleted if its reference count reaches zero.

The number of material slots can be determined using the Geometry::GetMaterialCount function.
See Also