Fixed winding order & simplified example a bit
This commit is contained in:
parent
4e8490d501
commit
78c61ddb22
7
cage.py
7
cage.py
@ -53,10 +53,12 @@ class Cage(object):
|
||||
# Now, every single new boundary has: one vertex of 'bound', an
|
||||
# adjacent midpoint, a centroid, and the other adjacent midpoint.
|
||||
cages = [
|
||||
Cage(numpy.array([self.verts[i,:], mids[i,:], centroid, mids_adj[i,:]]),
|
||||
Cage(numpy.array([self.verts[i,:], mids[i,:], centroid, mids_adj[i,:]])[::-1,:],
|
||||
self.splits)
|
||||
for i in range(4)
|
||||
]
|
||||
# TODO: Figure out why I have to have the [::-1,:] above to
|
||||
# fix the winding order
|
||||
return cages
|
||||
def is_fork(self):
|
||||
return False
|
||||
@ -111,8 +113,9 @@ class CageGen(object):
|
||||
# (e.g. loop with fork)
|
||||
for gen in cage_cur.gens:
|
||||
m = gen.to_mesh(count=count - i, flip_order=flip_order, loop=loop,
|
||||
close_first=close_first, close_last=close_last,
|
||||
close_first=False, close_last=False,
|
||||
join_fn=join_fn)
|
||||
# TODO: How do I handle closing with CageFork?
|
||||
meshes.append(m)
|
||||
# A fork can be only the final element, so disregard anything
|
||||
# after one and just quit:
|
||||
|
||||
19
examples.py
19
examples.py
@ -140,21 +140,14 @@ def ram_horn_branch():
|
||||
[1, 1, 0],
|
||||
[0, 1, 0],
|
||||
]).transform(center)
|
||||
xf0_to_1 = meshutil.Transform().translate(0, 0, 1)
|
||||
cage1 = cage0.transform(xf0_to_1)
|
||||
opening_boundary = lambda i: meshutil.Transform() \
|
||||
.translate(0,0,-1) \
|
||||
.scale(0.5) \
|
||||
.translate(0.25,0.25,1) \
|
||||
.rotate([0,0,1], i*numpy.pi/2)
|
||||
incr = meshutil.Transform() \
|
||||
.scale(0.9) \
|
||||
.rotate([-1,0,1], 0.3) \
|
||||
.translate(0,0,0.8)
|
||||
def recur(xf, cage0, count):
|
||||
def recur(xf, cage1, count):
|
||||
for i in range(count):
|
||||
if i > 0:
|
||||
yield cage0.transform(xf)
|
||||
yield cage1.transform(xf)
|
||||
xf0 = xf
|
||||
xf = incr.compose(xf)
|
||||
# .compose(opening_boundary(i))
|
||||
@ -177,10 +170,12 @@ def ram_horn_branch():
|
||||
[cage_sub.transform(xf0)],
|
||||
recur(xf_sub(i).compose(xf0), cage_sub, 8)))
|
||||
for i,cage_sub in
|
||||
enumerate(cage0.subdivide_deprecated())]
|
||||
enumerate(cage1.subdivide_deprecated())]
|
||||
yield cage.CageFork(gens)
|
||||
gens = [cage.CageGen(recur(opening_boundary(i), cage1, 8)) for i in range(4)]
|
||||
cg = cage.CageGen(itertools.chain([cage0, cage1, cage.CageFork(gens)]))
|
||||
cg = cage.CageGen(itertools.chain(
|
||||
[cage0],
|
||||
recur(meshutil.Transform(), cage0, 8),
|
||||
))
|
||||
# TODO: if this is just a list it seems silly to require itertools
|
||||
mesh = cg.to_mesh(count=32, close_first=True, close_last=True)
|
||||
return mesh
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user