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)
18 def CreateMaterials():
19 materials = GeneratePlugins(MaxPlus.SuperClassIds.Material,
MaxPlus.Mtl)
20 materialList = list(materials)
21 numMaterials = len(materialList)
24 print "%d materials" % numMaterials
29 plane.ParameterBlock.Width.Value = 120.0
30 plane.ParameterBlock.Length.Value = 120.0
33 def PrintMaterialProperties(material_instance):
34 print "[%s] %s" % (material_instance.GetClassName(), material_instance.GetName())
35 for p
in material_instance.ParameterBlock.Parameters:
36 print "\t" + p.Name +
" = " + str(p.Value)
38 def CreateText(x,y, quat, message):
40 tex.ParameterBlock.size.Value = 10.0
41 tex.ParameterBlock.text.Value = message
44 node.SetLocalRotation( quat )
47 class MtlDlgMode(object):
48 ''' Enumeration that determines what kind of material dialog to display'''
52 def CreateAndAssignMaterials(materials):
53 numMaterials = len(materials)
54 diff = 360.0 / numMaterials
64 angle_radians = math.radians(i)
65 x = radius * math.cos(angle_radians)
66 y = radius * math.sin(angle_radians)
70 teapot.ParameterBlock.Radius.Value = teapot_radius
72 node.Position = position
74 angle_axis_rotation =
MaxPlus.AngAxis(0,0,1, math.radians(angle_rotate))
76 node.SetLocalRotation( quat )
78 x = text_radius * math.cos(angle_radians)
79 y = text_radius * math.sin(angle_radians)
80 CreateText(x,y, quat, m.GetClassName())
90 PrintMaterialProperties(m)
100 materials = CreateMaterials()
101 CreateAndAssignMaterials(materials)