demoTreeOfSpheres.py

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