Object Hierarchy | Related C++ Class: Material









The Material object represents the material property of a SceneItem object and can be created with SceneItem.AddMaterial.


AddCustomOp AddICEAttribute AddProperty AddScriptedOp
AddScriptedOpFromFile AddSharedTextureLayer AnimatedParameters2 BelongsTo operator
CreateTextureLayer EvaluateAt FindShaders GetAllShaders
GetICEAttributeFromName GetShaderInputType IsA IsAnimated2
IsClassOf operator IsEqualTo operator IsKindOf IsLocked operator
IsResolved IsSelected operator LockOwners RemoveICEAttribute
RemoveTextureLayer Resolve SetAsSelected operator SetCapabilityFlag operator
SetLock TaggedParameters UnSetLock  


AllImageClips Application Branch operator BranchFlag operator
Capabilities operator Categories CurrentImageClip CurrentTexture
CurrentUV EvaluationID Families operator FullName operator
Help HierarchicalEvaluationID ICEAttributes ImageClips
Library LockLevel operator LockMasters operator LockType operator
Model Name operator NestedObjects OGLMaterial
OGLTexture ObjectID Origin OriginPath
Owners PPGLayout operator Parameters operator Parent
Parent3DObject Properties Selected operator Shaders
Singleton operator TextureLayers Type operator UnresolvedFullname


VBScript Example

'       This example demonstrates how you can recursively 
'       find and print all the material in a scene.
' Set up the scene first with three separate materials on
' the three mesh objects
NewScene , false
dim oThing
set oThing = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" )
oThing.AddMaterial "Phong", , "Wanda" 
set oThing = ActiveSceneRoot.AddGeometry( "Disc", "MeshSurface" )
oThing.AddMaterial "Lambert", , "Stewart" 
set oThing = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" )
oThing.AddMaterial "Blinn", , "Lulu" 
' Start a running tally (as a global index)
dim g_Count
g_Count = 0
' Now call the first routine
' The following information is logged in Softimage:
'INFO : "These (3) materials were found:"
'INFO : "sphere.Material"
'INFO : "disc.Material"
'INFO : "torus.Material"
' This routine just launches the search for the materials by 
' calling the workhorse routine. Notice how the second argument
' uses the byref keyword: that is so we preserve the collection
sub FindAndPrintAllNodeMaterials
        ' Create an empty collection that the worker routine
        ' will fill with found materials
        dim oMats, m
        set oMats = CreateObject ( "XSI.Collection" )
        SIGetAllNodeMaterial ActiveSceneRoot, oMats 
        ' When it's all done we'll have a collection of all
        ' the materials under the root (ie., all)
        Application.LogMessage "These (" & g_Count & ") materials were found:" 
        for each m in oMats
                Application.LogMessage m
end sub
' This routine is the 'workhorse', it crawls down the whole graph, 
' visiting each node to see if it's a material and collects 
' it if it is.
sub SIGetAllNodeMaterial( in_Obj, byref io_materials )
        ' Get the input objects properties and then loop
        ' through them looking for materials
        dim oProps, p
        set oProps = in_Obj.Properties
        for each p in oProps
                if TypeName(p) = "Material" Then
                        ' Only add node materials
                        if Not p.Branch then
                                ' Add them to the collection 
                                ' & increment the counter
                                g_Count = g_Count + 1
                                io_materials.Add p
                        end if
                end if
        ' This is the recursive part: by calling the 
        ' SIGetAllNodeMaterial routine from inside the
        ' SIGetAllNodeMaterial routine, we're basically
        ' drilling down through the children.
        dim oChildren, c
        set oChildren = in_Obj.FindChildren
        for each c in oChildren
                SIGetAllNodeMaterial c, io_materials 
end sub

See Also