demoTreeOfSpheres.py

demoTreeOfSpheres.py
1 '''
2  Creates a hierarchy of sphere objects at different relative locations.
3 '''
4 import MaxPlus
5 
6 
7 def createSphere():
8  obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Sphere)
9  obj.ParameterBlock.Radius.Value = 5.0
10  return MaxPlus.Factory.CreateNode(obj)
11 
12 
13 def treeOfSpheres(parent, width, xinc, depth, maxdepth):
14  if depth == maxdepth:
15  return
16  for i in range(width):
17  n = createSphere()
18  n.Parent = parent
19  n.SetLocalPosition(MaxPlus.Point3(i * xinc, 0, 15))
20  treeOfSpheres(n, width, xinc * width, depth + 1, maxdepth)
21 
22 
23 def main():
24  treeOfSpheres(createSphere(), 2, 10, 0, 4)
25 
26 if __name__ == "__main__":
27  main()