In this section we're going to modify a material at runtime.
Similar to IStatObj
, we can also clone our material to avoid making changes to all of the objects using it currently. To do so, call IMaterialManager::CloneMaterial
, which is accessible via gEnv->p3DEngine->GetMaterialManager()
.
The first thing we need to do is obtain an instance of the material we want to edit. If we have an entity nearby, we can use IEntity::GetMaterial
as shown:
IMaterial *pMaterial = pEntity->GetMaterial();
Note that IEntity::GetMaterial
returns null if no custom material has been set. If this is the case, you might want to rely on a function such as IStatObj::GetMaterial
.
Note that IMaterial
instances can be used ...
No credit card required