Urho3D Wiki
Register
Advertisement

Normally you assign materials like this:

StaticModel* boxObject=boxNode_->CreateComponent<StaticModel>();
boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));

You can also load materials, copy them, and/or change parameters:

Material* mat1=cache->GetResource<Material>("Materials/Stone.xml");
Material* mat2=mat1->Clone();    // copy material
// change the ciffuse color
mat2->SetShaderParameter("MatDiffColor",Color(0.1,0.4,0.9));
boxObject->SetMaterial(mat2);

You can use this to make every model unique by randomizing colors or color models in a team color. You can also pass custom parameters to control things like current weather or different (localized) lighting scenes.

An example of 400 uniquely colored cubes:

Copy material
Advertisement