View Full Version : Material/Map Navigator Tree
04-25-2009, 10:58 AM
For a script I working on, I need to write a material Map Navigator
similar to the Material/Map Navigator in the Material Editor.
Using a recursive funcion, I can collect all maps in a material, but I don't know how to
order them in a tree (hierarchy).
Could anyone give hints, infos, reference ?
Thanks in advance
04-25-2009, 12:07 PM
use a .NET treeview - see...
1. Paul Neale's page: http://paulneale.com/tutorials/dotNet/treeView/dotNetTreeView.htm
2. The MaxScript Help file
3. MSDN: http://msdn.microsoft.com/en-us/library/default.aspx
04-25-2009, 02:10 PM
Thx for the pointers.
Maybe i wasn't clear enough.
I know how to build and populate a treeview.
My question was more on the material side than the treeview.
Using getsubtexmap() in a recursive function, I can list all maps and submaps of a given material,
but i just get a list of maps.. no relationships...
How can I collect a material tree, with hierachy ?
04-25-2009, 05:43 PM
Well it's not as easy as one would think initially.
What I did for MatManager (http://scriptspot.com/3ds-max/matmanager-v0-6) is create my own objects (structs in Maxscript terms) for library, material and maps. Then I read the desired material and create the appropriate objects, wich in turn are used to populate the treeview
The point of this is that, for example, the material object, has a MAPS property that holds an array of the maps used by that material. So once the materials have been loaded the actions designated by the users take place on my own object structure, which does have clear relationships.
Is that clear enough? I didn't sleep much last night...
04-25-2009, 10:39 PM
To get the info -for- that struct, though, you'll probably just have to walk over the material/map's properties yourself and check if they are of material/map type
If you need generic info, you'd need to use showProperties and parse the output, as calling 'getProperty' on a material/map property that has no material/map assigned returns "undefined"; which could be anything.
Otherwise, 'classOf (getProperty <mat/map> #propertyname)' will help you out.
From there, do as MarcoBrunetta did.. make a struct that holds a material and/or map with child-materials/maps as well as a parent material/map, so you can always tell which material/map you originally got it from (materials/maps can be instanced, so they can technically have multiple parents).
04-26-2009, 12:46 AM
Yes, you are clear, but the part i'm interested in is :
'Then I read the desired material '
say I have a checker in the diffuse slot
then i Have a noise in the Color 1 of the checker
then i have a dent in the map1 of the noise
Noise (in map1)
dent (in map1)
How would you go about that ?
how can I collect in a parent/child way all maps of a diffuse map, for exemple ?
04-26-2009, 05:38 AM
the attached might be of some assistance; old test script, so prone to have bugs
evaluate the script, enter e.g. 'meditmaterials' in the field in the bottom-left, click 'Add', and it will try to get the given maxwrapper's hierarchy in the treeview.
( any maxscript that evaluates to a maxwrapper of some sort should work.. e.g. '$', or 'renderers.current', etc. )
the code deals with all sorts of types - obviously you would only need to deal with texture maps and materials; the basic premise is the same.. build a recursive function in which you get the sub-materials/maps of a given material/map, call that same function on those retrieved materials/maps. That way you build up a hierarchy with child/parent type relationships easily determined.
04-26-2009, 09:47 AM
Thx Richard, your script is a killer ;)
Very impressive !
This will definitevely get me going (now to understand how it works ...)
Thank you very much for this brilliant piece of code
Will keep you updated and will post when i have something ready.
04-26-2009, 09:47 AM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.