Using RootNode to store material

Using RootNode to store material

Anonymous
Not applicable
299 Views
2 Replies
Message 1 of 3

Using RootNode to store material

Anonymous
Not applicable
Hi , i've been reading trough some post here and I realized i could store material in the scene rootnode. In fact , I am trying to make a list of persistent global materials that are NOT assigned to any objects in the scene. I need them to stay in the background if the user needs it.
I don't want to load the Material editor slots neither.

Somebody talked about a way to store the material data into the rootnode but i've been looking in the maxscript help and around the net , there is not much informations about it.
Can anyone help? thank you!
0 Likes
300 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
0 Likes
Message 3 of 3

Anonymous
Not applicable
Maybe there is another way to do that, but this worked fine for me:

First you have to define a custom attribute to store the material, something like:
 myMatCA = attributes _mat
attribID:#(0x3b86c5cc, 0x336784d7)
(
parameters main rollout:params
(
_material type: #material ui:btn_material
)

rollout params "pick Material" width:162 height:258
(
materialButton btn_material "Pick Material" pos: width:119 height:25 material:undefined
on btn_material picked newMat do
(
btn_material.caption = newMat.name
)
)

fn getRollout = params
)


the attribID can be generated with the genClassID() function.

Then, you can add a new node:
newTrackViewNode "yourCustomName"

This will just add a new track (you can check that on the trackview), named "yourCustomName" that will serve as a container for your custom attribute. You should then add the custom attribute to that node:
 
mCA = myMatCA
custAttributes.add (trackviewnodes ) mca


Now everything is set up to start writing your code. To read or set the material, use
trackviewnodes._mat._material


and if you need an interface for your scripts, you can get the rollout with
trackviewnodes._mat.getRollout()


This is a very simple and basic setup, from there you can play around, like creating multiple material properties (or any other kind of properties) for your custom attributes, or adding multiple tracks to store different materials, or maybe keep just one global track, and add different controllers with the custom attribute on each one, etc. There are multiple possibilities from there.

I hope it helps,
0 Likes