[Closed] [MaxScript] MultiMaterial-like scripted plugin
It is a 3000 lines code, not to digest in a few minutes.
But if I had to guess, since you can only see a maximum of 10 materials at the time, I think it only uses 10 buttons and store the materials in a tab that is not linked to the controls. Instead it could reassign the materials to each control when you scroll.
That way you can have a resizable materials tab and you would only need to create controls for 10 materials. If you have less than 10 then simply hide them or move off-screen.
With MultiMaterial, you’re not limited to just 10 materials. You can pretty much set whatever number you want and it will display all the materials. I’m trying to have a look today on the C++ code today as you suggested but my first 3-4 minutes were scary! hahahah
I did just found that the “Set Number” button, triggers this function SetNumMats in the “multi.cpp” file.
I meant the 10 material buttons you see in the properties rollout, not the knobs in the Slate Editor.
The UI controls associated with a property do not seem to have any effect in the amount of knobs you see in the Slate Editor. Instead, they seem to be linked to the initial size of the materialTab.
Check this two simple examples. Unfortunately they don’t seem to update when you resize the tab.
plugin material TestMtl1 name:"Test Material 1" classID:#(111111,111111) extends:Standard replaceUI:true version:1
(
parameters main rollout:properties_ro
(
Mtls type:#materialTab tabSize:5 tabSizeVariable:true
)
rollout properties_ro "Properties"
(
)
)
plugin material TestMtl2 name:"Test Material 2" classID:#(222222,222222) extends:Standard replaceUI:true version:1
(
parameters main rollout:properties_ro
(
Mtls type:#materialTab tabSize:15 tabSizeVariable:true
)
rollout properties_ro "Properties"
(
)
)
yeah, that’s the main issue I noticed, plus the fact that when you change the tabsize, let’s say from 5 to 10, if you dynamically update the UI from 5 to 10 buttons, there doesn’t seem to be a way to link the buttons with “UI” property in the parameter block.
Here’s an example below:
plugin material TestMtl2 name:"Test Material 2" classID:#(222222,222222) extends:Standard replaceUI:true version:1
(
local properties_ro
parameters main rollout:properties_ro
(
Mtls type:#materialTab tabSize:2 tabSizeVariable:true ui:(mtl1, mtl2)
)
fn generateRollout count = (
removeRollout properties_ro;
local str = "rollout properties2_ro \"Configurable materials\" (\n"
for i=1 to count do ( str += "\tmaterialbutton mtl" + i as string + " \"\" width:260\n" )
str += ")"
properties_ro = execute str
addRollout properties_ro
for i=1 to count do (
properties_ro.controls[i].material = this.Mtls[i]
)
)
rollout main_ro "Set" (
spinner mtslCount "Count.........................................." width:260 fieldWidth:48 type:#integer range:[1,20,2] align:#center
button setMtls "Set" width:260
on setMtls pressed do (
generateRollout mtslCount.value
)
)
rollout properties_ro "Properties" (
materialButton mtl1 width:260
materialButton mtl2 width:260
)
)
And here’s a screen recording