[Closed] Accessing a sub-material from its texture node
Hi everyone
This might be a simple problem, but I lose my head on it.
Let’s say I have a multi/sub material in the material editor, called “theMulti”. I set a standard material “myMat”in slot 1 for example. Then I set a bitmap texture in the diffuse slot. So now, the material editor display the texture node (something like” Map #1“).
I want to access the name of the material that handle this texture map (yeah I know, it’s “myMat”, but it’s important for me to access the material from the texture node). I tried medit.GetTopMtlSlot but it returns the multimaterial.
medit.GetCurMtl() and getMeditMaterial return the texture node. I need something like “go to parent”, or anyway to access this material node.
Hope I’m clear enough.
Thanks
A multimaterial is only an array.
So, theMulti[1] should return your first standard material. (Or whatever you put in the first multi slot)
From now it’s like accessing any normal diffuse slot.
I hope I understood your problem…
well, no, it’s the opposite.
I’m not suppose to know that my material is in the first slot of the multi. I just have a texture node, I want to find the slot of the material that handle it in the multi. In fact, I want to rename my material with the name of the texture even if the medit display the texture node (and not the material node). It’s easy with a standard material, but I ‘m unable to do this with the multi.
Anyway, thanks for reply
from what i understand, U.S.S. Speed has already given you the answer you need, you just need to take it a tiny step further and use a for loop to get your result eg.
--assuming your texture map is held in the variable 'myTextureMap'
for m in theMulti where hasProperty m #diffusemap AND m.diffusemap == myTextureMap do m.name = myTextureMap.name
Oh man, that was so simple, I’m just confused.
Just parsing the materials and test which handle the good diffuseMap.
Well I’m a pathetic scripter
Thanks to both of you.