Nice
I wrote one for blender for a comp a while back
http://blenderartists.org/forum/showpos ... ostcount=3
Heres the code if anyone wants it, makes a range of different level gaskets.
Code: Select all
import Blender
from Blender import Mesh,Scene
scn=Scene.GetCurrent()
def generate(location, scale, level, currentVerts,currentFaces):
height=2.
x,y,z=location
newVerts,newFaces=[],[]
if level:
scale/=2.0
generate(location,scale,level-1,currentVerts,currentFaces)
generate([x-scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x-scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
else:
start=len(currentVerts)
currentVerts.extend([[x,y,z],\
[x-scale,y-scale,z-scale*height],\
[x+scale,y-scale,z-scale*height],\
[x+scale,y+scale,z-scale*height],\
[x-scale,y+scale,z-scale*height]])
currentFaces.extend([[start,start+1,start+2],\
[start,start+2,start+3],\
[start,start+3,start+4],\
[start,start+1,start+4],\
[start+1,start+2,start+3,start+4]])
return [currentVerts,currentFaces]
for i in range(6):
v,f=generate([0,0,2],1,i,[],[])
level=Mesh.New(str(i)+'level')
level.verts.extend(v)
level.faces.extend(f)
ob=scn.objects.new(level,'gasket'+str(i))
Modified to just make one
Code: Select all
import Blender
from Blender import Mesh,Scene
################
# Level of gasket wanted
i=6
# warning: try 5/6 first, it's quite dense already.
################
scn=Scene.GetCurrent()
def generate(location, scale, level, currentVerts,currentFaces):
height=2.
x,y,z=location
newVerts,newFaces=[],[]
if level:
scale/=2.0
generate(location,scale,level-1,currentVerts,currentFaces)
generate([x-scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y-scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x-scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
generate([x+scale,y+scale,z-scale*height],scale,level-1,currentVerts,currentFaces)
else:
start=len(currentVerts)
currentVerts.extend([[x,y,z],\
[x-scale,y-scale,z-scale*height],\
[x+scale,y-scale,z-scale*height],\
[x+scale,y+scale,z-scale*height],\
[x-scale,y+scale,z-scale*height]])
currentFaces.extend([[start,start+1,start+2],\
[start,start+2,start+3],\
[start,start+3,start+4],\
[start,start+1,start+4],\
[start+1,start+2,start+3,start+4]])
return [currentVerts,currentFaces]
v,f=generate([0,0,2],1,i,[],[])
level=Mesh.New(str(i)+'level')
level.verts.extend(v)
level.faces.extend(f)
ob=scn.objects.new(level,'gasket'+str(i))
Kram, it's not too heavy, Takes under a second for a level 6, a few seconds for a level 7 (level 7 = 390k faces). (amd64 3000)