[Closed] Materials in arrays
Is it possible to create an array containing materials, but without them being just references (or instances) of the main material?
I have an array of say 5 elements, and each of these elements is a copy of a base material with one it’s texturemaps properties altered, to differ slightly one from the other.
Is that possible? I’ve tried, but what I got was the base material’s texturemap property was changed, changing all the other ones also, as if they were instances or references…
I hope that explantion is clear, thanks in advance.
That’s happening because you are referencing the material and not copying. To append the copy of a material to an array just do something like this:
append matsArray (copy mEditMaterials[1])
Hope that helps.
Great… Worked just fine…
Thanks a lot… =)
And now… Well, I need to know which texturemaps the material has… If I do mEditMaterials[1].maps[1] (or any other number) it gives me “undefined”, thus I’m using the alias (.bumpMap), for example… Is there any way I can find the name without using the alias? (Example, identify via the .maps[] which is which and apply the modification I need to the correct property, without using alias)
You can get the map using its index. Just as you’ve said, using the maps array.
An for the maps names, this function returns the name for each map ID:
fn getMapIDName matID = (
case matID of (
1: return "Ambient Color"
2: return "Diffuse Color"
3: return "Specular Color"
4: return "Specular Level"
5: return "Glossiness"
6: return "Self-Illumination"
7: return "Opacity"
8: return "Filter Color"
9: return "Bump"
10: return "Reflection"
11: return "Refraction"
12: return "Displacement"
default: return "Unknown"
)
)
But that’s for standard material… If, for example, I create a VRay… It’ll tell me I’m treating “bump” while it’s some other texturemap… Right?
Thanks