Fixed winding order & simplified example a bit

This commit is contained in:
Chris Hodapp 2019-11-30 06:27:31 +01:00
parent 4e8490d501
commit 78c61ddb22
2 changed files with 12 additions and 14 deletions

View File

@ -53,10 +53,12 @@ class Cage(object):
# Now, every single new boundary has: one vertex of 'bound', an # Now, every single new boundary has: one vertex of 'bound', an
# adjacent midpoint, a centroid, and the other adjacent midpoint. # adjacent midpoint, a centroid, and the other adjacent midpoint.
cages = [ 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) self.splits)
for i in range(4) for i in range(4)
] ]
# TODO: Figure out why I have to have the [::-1,:] above to
# fix the winding order
return cages return cages
def is_fork(self): def is_fork(self):
return False return False
@ -111,8 +113,9 @@ class CageGen(object):
# (e.g. loop with fork) # (e.g. loop with fork)
for gen in cage_cur.gens: for gen in cage_cur.gens:
m = gen.to_mesh(count=count - i, flip_order=flip_order, loop=loop, 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) join_fn=join_fn)
# TODO: How do I handle closing with CageFork?
meshes.append(m) meshes.append(m)
# A fork can be only the final element, so disregard anything # A fork can be only the final element, so disregard anything
# after one and just quit: # after one and just quit:

View File

@ -140,21 +140,14 @@ def ram_horn_branch():
[1, 1, 0], [1, 1, 0],
[0, 1, 0], [0, 1, 0],
]).transform(center) ]).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() \ incr = meshutil.Transform() \
.scale(0.9) \ .scale(0.9) \
.rotate([-1,0,1], 0.3) \ .rotate([-1,0,1], 0.3) \
.translate(0,0,0.8) .translate(0,0,0.8)
def recur(xf, cage0, count): def recur(xf, cage1, count):
for i in range(count): for i in range(count):
if i > 0: if i > 0:
yield cage0.transform(xf) yield cage1.transform(xf)
xf0 = xf xf0 = xf
xf = incr.compose(xf) xf = incr.compose(xf)
# .compose(opening_boundary(i)) # .compose(opening_boundary(i))
@ -177,10 +170,12 @@ def ram_horn_branch():
[cage_sub.transform(xf0)], [cage_sub.transform(xf0)],
recur(xf_sub(i).compose(xf0), cage_sub, 8))) recur(xf_sub(i).compose(xf0), cage_sub, 8)))
for i,cage_sub in for i,cage_sub in
enumerate(cage0.subdivide_deprecated())] enumerate(cage1.subdivide_deprecated())]
yield cage.CageFork(gens) yield cage.CageFork(gens)
gens = [cage.CageGen(recur(opening_boundary(i), cage1, 8)) for i in range(4)] cg = cage.CageGen(itertools.chain(
cg = cage.CageGen(itertools.chain([cage0, cage1, cage.CageFork(gens)])) [cage0],
recur(meshutil.Transform(), cage0, 8),
))
# TODO: if this is just a list it seems silly to require itertools # 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) mesh = cg.to_mesh(count=32, close_first=True, close_last=True)
return mesh return mesh