Collada plugin for
After Effects

More info here
Plugins and Scripts > trueSpace > Development

Materials

material matching

Object scene material guid reader

This script demonstrates how to get the guid for object scene materials which are not available to scripting. Each material inside the scene's material node has a unique id assigned to it that can be read by script. The corresponding id is found inside the meshes "Material List" node. On the node connected to the "Material List Manager". Pass this node to the plugin to get it's id and match it against the "Material Flavor Manager's" "Material ID" connector value.

Select the node connected to the Material List Manager and push the button for the script to display the id in the list view.

By the way the "Material ID" connector on the "Material Flavor Manager" is hidden and can't be seen on the node even though it can be read via script.

Update Feb 2023

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • matid = util.GetMaterialId(MatNode)
    MatNode - the node connected to the Material List Manager
  • System.Trace(matid)

Enhanced Command

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • matNode = util.GetInstancedMaterialNode(MatListNode, index)
    MatListNode - the Material List Manager node
    index - material index of the mesh, connected to Mat Chunk 0, 1, 2 ...
  • System.Trace(matNode)
  • The returned value is the name of the material node inside the scene Materials encapsulator

GetInstancedMaterialNode is really "GetMaterialShortName" - given the Material List encapsulator(or Material List Manager node or the renderable node) and an index value get the short name for the material. Material may be instanced or not.

Use GetMaterialNode to get the full path of the material with the same arguments.

The plugin package is required to use this script. Download the plugin package here.

November 22, 2009

MaterialLookupTable for CSG node, IRdMaterialLookupTable

"Material lookup table data object used for translating material indices"

Can be used when manually setting up booleans in the node editor.

Testing seems to indicate the node name is the short name of the node, not the full path

MergeMaterialLists solves the problems of: What happens when materials repeat? How handle it? Scene instanced materials kindof makes sense but no instancing?
also solves the issue of updating the material index when copying raw material nodes and hooking them up manually.

CreateMaterialLookup:

Creates the MaterialLookupTable in memory. This is the first step to working with the material lookups.

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.CreateMaterialLookup(bszNode, bszConn)
    • bszNode, bszConn are the "Csg operation" node and it's "Material A" or "Material B" connector to use as a starting point for the table
    • set params both to "" to create an empty material lookup table

MaterialLookupAddNode:

Add a node to the materia lookup in memory or just return it's index in the table

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • nodeindex = util.MaterialLookupAddNode(bszNode, getnodeindex)
    • bszNode is the name of the mesh node(short name not full path)
    • getnodeindex = true to only read the index for the node, false to add the node and return the index
    • returns the index of the node in the table

AddMaterialLookup:

set a material index translation for the table in memory for the node from the source node material index to the destination boolean material index

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.MaterialLookupAddNode(nodeindex, sourceindex, destindex)
    • nodeindex is the index of the node in the material lookup table
    • sourceindex, destindex = original node material index and the new csg material index

AssignMaterialLookupTable:

save the material lookup table from memory into the Csg operation node

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.AssignMaterialLookupTable(bszNode, bszConn)
    • bszNode, bszConn are the "Csg operation" node and it's "Material A" or "Material B" connector

GetMaterialLookup:

read material lookup table data from memory

large return numbers indicate invalid values.
when returning the count the values for source and destination index are invalid, otherwise the count is invalid with source and destination containing actual values

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • countsourcedest = util.GetMaterialLookup(nodeindex, lookupindex, getcount)
    • nodeindex is the index of the node in the material lookup table
    • lookupindex is the index of the translation from the source node to csg material index
    • getcount when true will return the count instead of the translation indices
    • returned value is a comma separated list of the number of translation pairs or source index and destination index for the given node index

MergeMaterialLists:

from the IRfMaterialListSet

merge materials together returning a translation list of indices for the second object

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • translations = util.MergeMaterialLists(DestinationNode, NodeToAdd)
    • DestinationNode is the material list encapsulator or the object that contains the material list encapsulator node
    • NodeToAdd is the material list encapsulator or the object that contains the material list encapsulator node to be added to the destination
    • returned value is a comma separated list of translations for the source index and destination index for the node whos materials was added
      format is "original index1, new index1, original index2, new index2..."

This command works with the Material List encapsulator node.
This command will automatically find the node when it's containing node is passed in.
This is true for the node that gets attached to the IRfMaterialListSet and the node whos materials are merged in.

June 26, 2024

MaterialList

IRfMaterialListSet expose some functions to scripting

GetMaterialIndices:

list of material indices given Material List Encapsulator ? maybe also the whole object node?.

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • indicesString = util.GetMaterialIndices(bszNode)
    • bszNode is the Material List Encapsulator ? maybe also the whole object node?
    • indicesString is comma separated list, indicesArr=indicesString.split(",")

GetMaterialNode:

get the material node given the index and the Material List Encapsulator ? maybe also the whole object node?.

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • matNode = util.GetMaterialNode(bszNode, index)
    • bszNode is the Material List Encapsulator ? maybe also the whole object node?
    • index is the material index

works with instanced materials

GetInstancedMaterialNode (really "GetMaterialShortName") :

get the material short name given the index and the Material List Encapsulator or Material List Manager, maybe also the whole object node?.

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • matNode = util.GetInstancedMaterialNode(bszNode, index)
    • bszNode is the Material List Encapsulator or Material List Manager, maybe also the whole object node?
    • index is the material index

SetMaterial:

set material will connect a material to the Material List Manager

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.SetMaterial(bszAttachedNode, bszNode, index)
    • bszAttachedNode is the Material List Encapsulator ? maybe also the whole object node?
    • bszNode is the Material encaps node
    • index is the material index of the material to be added

RemoveMaterial:

delete a material but result will disconnect the last material. should work as "expected" on the last material only?

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.RemoveMaterial(bszNode, index)
    • bszNode is the Material List Encapsulator ? maybe also the whole object node?
    • index is the material index of the material to be removed

MaterialIsEqual:

compare 2 materials to see if they produce the same appearance
not fully tested, is it appearance or conns and conn values?

testing seems to indicate that only inputs that effect the material appearance are used for the comparison

testing shows this command to be unreliable when used with scene instanced materials

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.MaterialIsEqual(byorder, bszNode, index, bszNode2, index2)
    • byorder - true then use GetMaterialGenericByOrder, otherwise GetMaterialGeneric is run
      scene instanced giving a lot of strange results either way, sometimes works sometimes not work
      better to use more direct means to compare scene instanced materials(GetMaterialNode)
    • bszNode is the Material List Encapsulator, maybe can also the whole object node?
    • index is the material index of the material to be compared
    • bszNode2 is the second Material List Encapsulator
    • index2 is the material index of the second material to be compared
July 16, 2024

Material Commands

SetActiveMaterial2

Loads a material directly into the Material Editor.

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.SetActiveMaterial2(MaterialNode, ForceCopy)
    MaterialNode - the node that defines the material
    ForceCopy - if true ignore the "Edit picked material directly" option and make a copy of the material to work on

RemoveUnusedMaterials

RemoveUnusedMaterials will remove orphan materials from the selected node

  • util = System.CreateDO("Clintons3D Package/Utility functions");
  • util.RemoveUnusedMaterials(MaterialNodeEncaps)
    MaterialNodeEncaps - node that contains the materials ex) "/Project/Space 3D/Materials" for scene instanced materials
Jan 19, 2023
June 5, 2013