Home Technical Talk

3dsmax - Collapse Materials to Multi-Sub

polycounter lvl 9
Offline / Send Message
olivierth polycounter lvl 9
Hi,

I've got a character made with about 20 different materials. I know that if I merge all the meshes into one, it will create a multi-Sub material with all the materials. The problem is I want to keep the meshes separate.

I used to manually change the polygons'material ID of each individual meshes to fit with the multi-sub but I would like to know if it can be done by a script.

Thank you!

Replies

  • Pathologist
    Options
    Offline / Send Message
    Pathologist polycounter lvl 4
    index = 0
    
    matArr =#()
    for m in scenematerials do append matArr m 
    matArr
    
    sceneMatCount = scenematerials.count
    newMatt = Multimaterial numsubs:sceneMatCount
    for i = 1 to sceneMatCount do
    (
    	newMatt[i] = matArr[i]
    )
    medit.PutMtlToMtlEditor newMatt 1
    
    fn setMatID o index =
    (
    	o.editablepoly.setSelection #Face #{1..(o.numfaces)}
    	o.editablePoly.setMaterialIndex index 0
    )
    
    for o in geometry where classof o == Editable_Poly do
    (
    	index = index + 1
    	setMatID o index
    )
    

    This will collect all materials and put them in the first material editor slot as a Multi/Sub-Object material. It then goes through all editable_poly objects and sets their material ID accordingly... not sure if it works for you but it did in my test.

    Tested in 2010

    This currently only works if all objects have a unique material, will get working on this more when I have time (tomorrow?)
  • olivierth
    Options
    Offline / Send Message
    olivierth polycounter lvl 9
    Looks promising! Will it work if I have different modifier on a lot of them? Anyways, I'll try it out to see.

    Don't work on it just for me! I can always do it by hand. I don't want to waste your valuable time.

    Thanks !
Sign In or Register to comment.