PDA

View Full Version : Replacing Materials in An Array.


DaveWortley
12-21-2009, 01:23 PM
I've created collected an Array of a bunch of materials. I want to then change the material say from a VrayMtl to a StandardMaterial.

If you say $.material = StandardMaterial() then the material changes for all references to that material, but if you say have an array of

my_array = #(VrayMtl:Material1, StandardMaterial:Materrial2) for example...

If you try my_array[1] = StandardMaterial()

then as exepected your material in the array changes to....
my_array = #(StandardMaterial:Standard, StandardMaterial:Materrial2)

But this "standardmaterial:Standard" is no longer associated with the objects the VrayMtl was assigned to.

Is there a way to convert a material from one type to another whilst keeping all it's assignments?

MarcoBrunetta
12-21-2009, 02:43 PM
The problem here is that when you do "$.material = StandardMaterial()" you are not actually CHANGING the material, but REPLACING it with another one. The same thing happens on the array, but you are not affecting a material inside a scene object, you are doing it inside an array.

A solution would be to store the objects in the array, instead of only the materials, and then changing all their "material" property. Or maybe use getClassInstances to retrieve the instances of the material in the array?

DaveWortley
12-21-2009, 02:58 PM
Yeah that was the approach I was taking but I reverted to a material orientated system to avoid some other issues so might have to review object based method to avoid this issue...

CGTalk Moderation
12-21-2009, 02:58 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.