[Closed] Assign material MXS equivalent
Hi everyone,
I’m on the hunt for the equivalent to having a material in the MatEditor and assigning a new material type to a material. Say I have a standard material open in the matEdit, and I want to replace it with and ArchDesign mr material. I cannot use a $.material = newmaterial() because that would replace the material if it was a multisub.
Basicly am I loading a materialLibrary file and do a getClassInstances of a certain material, then I want to replace materials in that array with my new material of whatever type. I tried swap mat1 mat2 but that doesn’t work out. I understand you can’t assign a new material to just a material variable. So I’m wondering what happens when you assign a new material via the material editor as that is the exact thing I want to do.
One thing I can think of is to check if a material is assigned to a shell, blend or multisub material if so then change that material there else find the nodes that have that material and assign directly to the nodes. But it feels so convoluted and error prone, so I’m wondering if I’m missing something.
Thanks,
-Johan
I would give denisT xchangeMats function a try and see if that does what you want. All you should need to do is point to an existing scene material reference and what you want to replace it with.
-Eric
don’t understand exaclty, but if you know the object(mat) you wanna change, this might help:
replaceInstances $.material[1] (standard diffusecolor:green)
Thanks both, these are great examples, and maybe the replaceInstances is what I need. I’ll be working on it some more tomorrow.
Thanks,
-Johan
check this thread:
http://forums.cgsociety.org/showthread.php?f=98&t=890727&highlight=replaceInstances