class VertexAccumulator:
# use this class when you can't come up with a good deterministic numbering scheme for your vertices.
def __init__(self):
self.verts_ = []
self.vertIdxs = {}
def keyFor(v):
return "%f,%f,%f"%(v[0], v[1], v[2])
def idxFor(self, v):
key = VertexAccumulator.keyFor(v)
rval = self.vertIdxs.get(key)
if None==rval:
rval = len(self.verts_)
self.vertIdxs[key] = rval
self.verts_.append(v)
return rval
def verts(self):
return self.verts_
|
Blender python API quick-start
Syntax highlighting by Pygments.