## # Sierpinski Pyramid # p01 2009 # Maya python script ## from maya.cmds import * from math import * def sierpinskiPyramid(x, y, z, sz, it, lvl=0): if lvl==it: polyPyramid(w=sz) move(x, y, z) rotate(0, '45deg', 0) else: r = sz / 4.0 h = sz / 2.84 childs = [[0,h/2,0],[r,-h/2,r],[r,-h/2,-r],[-r,-h/2,r],[-r,-h/2,-r]] for c in childs: sierpinskiPyramid(x+c[0],y+c[1],z+c[2],sz/2.0,it,lvl+1) def run(it=0, sz=50.0): if objExists('pPyramid1'): select(all=True) delete() sierpinskiPyramid(0, 0, 0, sz, it) select(cl=True) viewFit() def win(): window(t='Sierpinski Pyramid') columnLayout(rs=20) intSliderGrp(l='Iteration', field=1, min=0, max=4, v=0, cc=lambda x:run(int(x))) showWindow() run() win()