def stick_mesh(width, height, depth):
x = max(width,height,depth) * unit + unit
step = unit/20
stick = cube([x,step,step])
b = cube([x,step,step])
b += translate([0,x,0])( cube([x,step,step]) )
b += cube([step,x,step])
b += translate([x,0,0])( cube([step,x,step]) )
b = b + translate([0,0,x])(b)
b += cube([step,step,x])
b += translate([0,x,0])(cube([step,step,x]))
b += translate([x,0,0])(cube([step,step,x]))
b += translate([x,x,0])(cube([step,step,x]))
sticks = []
for i in range(2000):
trans = [randint(int(-100 * x*2/3),int(x*100*2/3))/100.0 for i in range(3)]
rot = [randint(0,3600)/10. for i in range(3)]
sticks.append(translate([x/2,x/2,x/2])(
translate(trans)(rotate(rot)(stick))
))
b = b + union()(*sticks)
b = b * cube(x+step)
return b
评论列表
文章目录