PDA

View Full Version : looping through blend and multi-/submaterial...


48design
06-23-2006, 02:55 PM
... I need to get all materials of a blend material.
the problem is, the blend material has an multi material as a subMaterial...

I would like to have a function that loops through ALL materials (selected or in scene, chosen by a button).
Every material that has a texture in the diffuse slot is getting selfIllumination set to white.

I tried a recursive function but did not get it. :sad:

anyone a clue?
THX!

P.S.: all the rest of my script works well :)

48design
06-23-2006, 09:12 PM
noone an idea? :sad:

arketip
06-24-2006, 09:47 PM
Hello
It is not complicated to write a recursive function to scan all materials.
Here a small example which will help you to understand the principle of a recursive function.

fn setParam mat = (
case classof mat of
(
blend: (setParam mat.map1; setParam mat.map2)
compositematerial: (for thisMat in mat.materiallist where thisMat!=undefined do setParam thisMat)
multimaterial: (for thisMat in mat.materiallist where thisMat!=undefined do setParam thisMat)
standardmaterial:
(
if mat.diffuseMapEnable and classof mat.diffuseMap == Bitmaptexture do (
mat.selfIllumMapEnable = false
mat.useSelfIllumColor = false
mat.selfIllumAmount = 100.0
)
)
)
)

(
for obj in selection where isKindOf obj GeometryClass do (
local mat = obj.material
setParam mat
)
)

In my example the recursivity operate only on blend, composite and multimaterials.
Obviously you can add other materials if you want.

I hope this help

48design
06-25-2006, 01:36 PM
now it works and I can complete my script! :)
thanks!!!

CGTalk Moderation
06-25-2006, 01:36 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.