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:
14 inst = cls._CastFrom(anim)
19 def CreateMaterials():
20 materials = GeneratePlugins(MaxPlus.SuperClassIds.Material,
MaxPlus.Mtl)
21 materialList = list(materials)
22 numMaterials = len(materialList)
25 print "%d materials" % numMaterials
31 plane.ParameterBlock.Width.Value = 120.0
32 plane.ParameterBlock.Length.Value = 120.0
36 def PrintMaterialProperties(material_instance):
37 print "[%s] %s" % (material_instance.GetClassName(), material_instance.GetName())
38 for p
in material_instance.ParameterBlock.Parameters:
39 print "\t" + p.Name +
" = " + str(p.Value)
42 def CreateText(x, y, quat, message):
44 tex.ParameterBlock.size.Value = 10.0
45 tex.ParameterBlock.text.Value = message
48 node.SetLocalRotation(quat)
52 class MtlDlgMode(object):
53 ''' Enumeration that determines what kind of material dialog to display'''
58 def CreateAndAssignMaterials(materials):
59 numMaterials = len(materials)
60 diff = 360.0 / numMaterials
69 angle_radians = math.radians(i)
70 x = radius * math.cos(angle_radians)
71 y = radius * math.sin(angle_radians)
75 teapot.ParameterBlock.Radius.Value = teapot_radius
77 node.Position = position
78 angle_rotate = 180 - i
80 0, 0, 1, math.radians(angle_rotate))
82 node.SetLocalRotation(quat)
84 x = text_radius * math.cos(angle_radians)
85 y = text_radius * math.sin(angle_radians)
86 CreateText(x, y, quat, m.GetClassName())
96 PrintMaterialProperties(m)
107 materials = CreateMaterials()
108 CreateAndAssignMaterials(materials)