2 Demonstrates how to iterate through materials and and apply them to objects.
3 It shows how to open the material editor and put materials in the editor.
9 def GeneratePlugins(sid, cls):
11 if cd.SuperClassId == sid:
12 if (sid == MaxPlus.SuperClassIds.Material
and cd.Category !=
"Arnold"):
15 inst = cls._CastFrom(anim)
20 def CreateMaterials():
21 materials = GeneratePlugins(MaxPlus.SuperClassIds.Material,
MaxPlus.Mtl)
22 materialList = list(materials)
23 numMaterials = len(materialList)
26 print "%d materials" % numMaterials
32 plane.ParameterBlock.Width.Value = 120.0
33 plane.ParameterBlock.Length.Value = 120.0
37 def PrintMaterialProperties(material_instance):
38 print "[%s] %s" % (material_instance.GetClassName(), material_instance.GetName())
39 for p
in material_instance.ParameterBlock.Parameters:
40 print "\t" + p.Name +
" = " + str(p.Value)
43 def CreateText(x, y, quat, message):
45 tex.ParameterBlock.size.Value = 10.0
46 tex.ParameterBlock.text.Value = message
49 node.SetLocalRotation(quat)
53 class MtlDlgMode(object):
54 ''' Enumeration that determines what kind of material dialog to display'''
59 def CreateAndAssignMaterials(materials):
60 numMaterials = len(materials)
61 diff = 360.0 / numMaterials
70 angle_radians = math.radians(i)
71 x = radius * math.cos(angle_radians)
72 y = radius * math.sin(angle_radians)
76 teapot.ParameterBlock.Radius.Value = teapot_radius
78 node.Position = position
79 angle_rotate = 180 - i
81 0, 0, 1, math.radians(angle_rotate))
83 node.SetLocalRotation(quat)
85 x = text_radius * math.cos(angle_radians)
86 y = text_radius * math.sin(angle_radians)
87 CreateText(x, y, quat, m.GetClassName())
97 PrintMaterialProperties(m)
108 materials = CreateMaterials()
109 CreateAndAssignMaterials(materials)