Ejemplo n.º 1
0
    def _geo(self):
        self.lnstocenter = self._lanestocenter()
        #m = dtm.meshme(pts,None,None,None,[],tris)
        m = dmo.model()

        lpt1, lpt2 = self._geo_pair(0)
        m._consume(dcu.cube().translate(lpt1).translate_z(0.5))
        m._consume(dcu.cube().translate(lpt2).translate_z(0.5))

        lrow = [lpt1]
        rrow = [lpt2]

        for pdx in range(1, len(self.road.vertices)):
            pt1, pt2 = self._geo_pair(pdx)

            m._quad(pt1, pt2, lpt2, lpt1)

            lpt1, lpt2 = pt1, pt2
            lrow.append(lpt1)
            rrow.append(lpt2)

            m._consume(dcu.cube().translate(pt1).translate_z(0.5))
            m._consume(dcu.cube().translate(pt2).translate_z(0.5))
        self.leftrow = lrow
        self.rightrow = rrow
        return m
Ejemplo n.º 2
0
 def pelt(self):
     s = dmo.model()
     for f in self.fs:
         if f is None:continue
         v1 = self.vs[f[0]]
         v2 = self.vs[f[1]]
         v3 = self.vs[f[2]]
         s._triangle(v1.p,v2.p,v3.p,[v1.n,v2.n,v3.n])
     return s
Ejemplo n.º 3
0
 def skeleton(self):
     s = dmo.model()
     for v in self.vs:
         m = dcu.cube().scale(dpv.one().scale_u(0.1)).translate(v.p)
         s._consume(m)
     for e in self.es:
         cq = dpq.q_from_uu(dpv.zhat,
             dpv.v1_v2(self.vs[e[0]].p,self.vs[e[1]].p))
         c = dcy.cylinder().translate_z(0.5)
         c.scale_x(0.05).scale_y(0.05).rotate(cq)
         c.translate(self.vs[e[0]].p)
         s._consume(c)
     return s
Ejemplo n.º 4
0
 def model(self):
     p = dpv.zero()
     d = dpv.z()
     #ltree(-1)._realize(p,d)
     total = dmo.model()
     #tps = [(x,y) for x in range(3) for y in range(3)]
     tps = [(x, y) for x in range(1) for y in range(1)]
     for i, xy in enumerate(tps):
         x, y = xy
         kws = {'seed': i}
         self.ltree._realize(p, d)
         lmod = self.model
         lmod.translate(dpv.vector(10 * x, 10 * y, 0))
         total._consume(lmod)
     return total
Ejemplo n.º 5
0
 def model(self):
     p = dpv.zero()
     d = dpv.z()
     #ltree(-1)._realize(p,d)
     total = dmo.model()
     #tps = [(x,y) for x in range(3) for y in range(3)]
     tps = [(x,y) for x in range(1) for y in range(1)]
     for i,xy in enumerate(tps):
         x,y = xy
         kws = {'seed':i}
         self.ltree._realize(p,d)
         lmod = self.model
         lmod.translate(dpv.vector(10*x,10*y,0))
         total._consume(lmod)
     return total
Ejemplo n.º 6
0
 def grass(self,model,years):
     growth = dmo.model()
     hitfaces = self.hitdata['hitfaces']
     hitcasts = self.hitdata['hitcasts']
     pfaces = self.hitdata['pfaces']
     #nfaces = self.hitdata['nfaces']
     for hdx in range(len(hitfaces)):
         if random.random() < 0.9:continue
         hf = hitfaces[hdx]
         hc = hitcasts[hdx]
         dtb = dpv.distance_to_border_xy(hc,pfaces[hf])
         rad = dtb
         if rad < 0.4:continue
         clump = dg.grass_clump(width = 0.75,radius = rad)
         growth._consume(clump.translate(hc))
     return growth
Ejemplo n.º 7
0
 def trees(self,model,years):
     growth = dmo.model()
     hitfaces = self.hitdata['hitfaces']
     hitcasts = self.hitdata['hitcasts']
     pfaces = self.hitdata['pfaces']
     #nfaces = self.hitdata['nfaces']
     for hdx in range(len(hitfaces)):
         #if random.random() < 0.99:continue
         hf = hitfaces[hdx]
         hc = hitcasts[hdx]
         #dtb = dpv.distance_to_border_xy(hc,pfaces[hf])
         #rad = dtb
         #if rad < 1:continue
         tree = dcyl.cylinder().translate_z(0.5).scale_z(10)
         #tree = dpi.pipe()
         growth._consume(tree.translate(hc))
     return growth
Ejemplo n.º 8
0
    def ivy(self,model,years):
        growth = dmo.model()
        hitfaces = self.hitdata['hitfaces']
        hitcasts = self.hitdata['hitcasts']
        pfaces = self.hitdata['pfaces']
        nfaces = self.hitdata['nfaces']
        seeds = []
        for hdx in range(len(hitfaces)):
            if random.random() < 0.999:continue
            hf = hitfaces[hdx]
            hc = hitcasts[hdx]
            seeds.append((hf,hc))

        for sd in seeds:
            vine = dv.vine()
            vine.grow(sd,pfaces,nfaces,years)
            growth._consume(vine)

        return growth
Ejemplo n.º 9
0
def test():
    import dilap.construct as dlc
    p = dpv.zero()
    d = dpv.z()

    #pythagoras_tree()._realize(p,d)
    #dragon_curve()._realize(p,d)

    total = dmo.model()

    #for l in range(5):tree(l)._realize(p,d)
    ltree(-1)._realize(p,d)
    tps = [(x,y) for x in range(3) for y in range(3)]
    for i,xy in enumerate(tps):
        x,y = xy
        kws = {'seed':i}
        lmod = ltree(-1,**kws)._realize(p,d).model
        lmod.translate(dpv.vector(10*x,10*y,0))
        total._consume(lmod)
    
    dlc.build(total)
Ejemplo n.º 10
0
 def _geo(self):
     m = dmo.model()
     for l in self.lanes:
         m._consume(l._geo())
     self._consume(m)
Ejemplo n.º 11
0
 def pelt(self):
     s = dmo.model()
     for smp in self.simplices:
         t1,t2,t3 = smp
         s._triangle(t3,t2,t1)
     return s
Ejemplo n.º 12
0
 def wither_model(self, model, years):
     change = dmo.model()
     for w in self.withers:
         wmo = self.__getattribute__(w)(model, years)
         if not wmo is None: change._consume(wmo)
     return change
Ejemplo n.º 13
0
 def generate_switchback(self,level):
     floor = dmo.model()
     pdb.set_trace()
     return self._node_wrap(floor)
Ejemplo n.º 14
0
 def generate_switchback(self, level):
     floor = dmo.model()
     pdb.set_trace()
     return self._node_wrap(floor)
Ejemplo n.º 15
0
 def wither_model(self,model,years):
     change = dmo.model()
     for w in self.withers:
         wmo = self.__getattribute__(w)(model,years)
         if not wmo is None:change._consume(wmo)
     return change