Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temporary replace material on MultiMaterialModelNode
#1
Lightbulb 
Hi

I need to apply a new material to a MultiMaterialModelNode and later on come back to the materiales defined in the submeshes

But I see no way I can edit/replace the material array I provide to the constructor

Is this possible?
#2
Here's an example that might be useful.

var subMesh = node.AddSubMesh(0, 3, StandardMaterials.Red);
subMesh.ChangeMaterial(StandardMaterials.Blue);
#3
Thank you @zacfromaustinpowder for providing an example on how to change the material.

For MultiMaterialModelNode it is recommended to create all possible materials when the MultiMaterialModelNode is created (pass them to the constructor). After that you can simply change the material by changing the index of the material, for example:
Code:
subMesh.MaterialIndex = newMaterialIndex;

But as written by @zacfromaustinpowder, you can also use a new material - in this case call the ChangeMaterial and the code in MultiMaterialModelNode will check if this material was already used (assign an existing index) or create a new index for the new material.

See also the test code in this post to see how to change the materials.
zacfromaustinpowder
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)