PDA

View Full Version : Subanims material Type


displaced
02-04-2009, 02:00 PM
I've been using a script to collect material filename via subanims like below



fn getSubAnims theParent = (
for i = 1 to theParent.numsubs do (
append theMats theParent[i]
try(getSubAnims theParent[i].object)catch(getSubAnims theParent[i])
)
)

theMats = for o in selection where o.material != undefined collect o.material
for m in theMats do getSubAnims m
global theTextures = #()
for o in theMats where
hasProperty o "filename" and findItem theTextures o.filename == 0 do
append theTextures o.filename




but i want a little more control over it now. I would like to be able to select what map types to collect, so i could select Diffuse maps or bump maps etc.

Ive come up with this


for o in themats where hasproperty o "filename" do print o.name


but cant work out how to use the information provided to seperate the different mat types into different arrays.

any help would be great cheers

LoneRobot
02-04-2009, 02:22 PM
one possible method would be to have an array for each material type, and use a case expression to filter the properties you wanted -

bitmapmaparray = #()
gradientramparray = #()
checkermaparray = #()
anythingelse = #()

for o in themats do
(
case of
(
(hasproperty o.diffusemap "filename") : append bitmapmaparray o
(hasproperty o.diffusemap "gradient_type") : append gradientramparray o
(hasproperty o.diffusemap "soften") : append checkermaparray o
default : append anythingelse o
)
)

you would need to have a fair bit of error checking in this though, in case you encountered any different types of material.

displaced
02-04-2009, 02:42 PM
im not sure if thats exactly what i want....


for o in themats where hasproperty o "filename" do print o.name


when i do the above i get the following results..

"Diffuse Color: Map #1 (Dif_RIGHT.jpg)"
"Opacity: Map #2 (Op_RIGHT.jpg)"

so in this instance i would want the map Dif_RIGHT.jpg to be put in the diffuse_array and the Op_RIGHT.jpg in the opacity_array

so then at a later time i could have some radios buttons to select which maps to use etc..

hope that makes more sense..

Cheers

LoneRobot
02-04-2009, 03:05 PM
hi colin,

i was sure it wasn't exactly what you wanted, but it was meant to give you something to get started. If you are using the filename property to distunguish between diffuse and opacity maps, yuo will have the problem that they both have filename properties if you are using a bitmaptexture in the map slot. Better check the diffuse and opacity parts of the mat and use the case expression to filter them into their individual arrays.

CGTalk Moderation
02-04-2009, 03:05 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.