Beispiel #1
0
    def skeleton(self):
        m = dmo.model()
        gm = m.agfxmesh()
        tr, nps, nes = self.lsys.topology
        mw = 2.0
        knuckles = []

        def walk(v, l, ml):
            ch = tr.below(v)
            if not ch:
                self.leaf(tr.above(v), v)
                #if not ch:self.branch(tr.above(v),v,l,ml,mw)
            else:
                kn = knuckle(tr.above(v), v, l, ml, mw)
                knuckles.append(kn)
                l += 1.0
                ml = len(tr.allbelow(v))
                for c in ch:
                    #self.branch(v,c,l,ml,mw)
                    kn.digit(c, l, ml, mw)
                    walk(c, l, ml)
                if len(knuckles) == 1: kn.gen(m, gm, True)
                else: kn.gen(m, gm, False)

        walk(tr.root, 0, len(tr.allbelow(tr.root)))
        p, q, s = vec3(0, 0, 0), quat(0, 0, 0, 0), vec3(1, 1, 1)
        sgv = self.amodel(p, q, s, m, None)
        return self

        '''#
        m = dmo.model()
        gm = m.atricube()
        p = vec3(0,0,1)
        q = quat(0,0,0,0).av(numpy.pi/3.0,vec3(0,0,1))
        #q = quat(0,0,0,0).av(0.0,vec3(0,0,1))
        s = vec3(1,2,1)
        self.amodel(p,q,s,m,None)
        '''#

        for v in nps:
            m = dmo.model()
            gm = m.atricube()
            p = v.cp()
            q = quat(0, 0, 0, 0).av(0.0, vec3(0, 0, 1))
            s = vec3(0.1, 0.1, 0.2)
            sgv = self.amodel(p, q, s, m, None)
        for e in nes:
            m = dmo.model()
            gm = m.atricube()
            m.trn(vec3(0, 0, 1))
            p = nps[e[0]].cp()
            tn = nps[e[0]].tov(nps[e[1]])
            q = quat(0, 0, 0, 0).uu(vec3(0, 0, 1), tn)
            s = vec3(0.05, 0.05, 0.5 * tn.mag())
            sgv = self.amodel(p, q, s, m, None)
        return self
Beispiel #2
0
    def skeleton(self):
        m = dmo.model()
        gm = m.agfxmesh()
        tr,nps,nes = self.lsys.topology
        mw = 2.0
        knuckles = []
        def walk(v,l,ml):
            ch = tr.below(v)
            if not ch:self.leaf(tr.above(v),v)
            #if not ch:self.branch(tr.above(v),v,l,ml,mw)
            else:
                kn = knuckle(tr.above(v),v,l,ml,mw)
                knuckles.append(kn)
                l += 1.0
                ml = len(tr.allbelow(v))
                for c in ch:
                    #self.branch(v,c,l,ml,mw)
                    kn.digit(c,l,ml,mw)
                    walk(c,l,ml)
                if len(knuckles) == 1:kn.gen(m,gm,True)
                else:kn.gen(m,gm,False)
        walk(tr.root,0,len(tr.allbelow(tr.root)))
        p,q,s = vec3(0,0,0),quat(0,0,0,0),vec3(1,1,1)
        sgv = self.amodel(p,q,s,m,None)
        return self

        '''#
        m = dmo.model()
        gm = m.atricube()
        p = vec3(0,0,1)
        q = quat(0,0,0,0).av(numpy.pi/3.0,vec3(0,0,1))
        #q = quat(0,0,0,0).av(0.0,vec3(0,0,1))
        s = vec3(1,2,1)
        self.amodel(p,q,s,m,None)
        '''#

        for v in nps:
            m = dmo.model()
            gm = m.atricube()
            p = v.cp()
            q = quat(0,0,0,0).av(0.0,vec3(0,0,1))
            s = vec3(0.1,0.1,0.2)
            sgv = self.amodel(p,q,s,m,None)
        for e in nes:
            m = dmo.model()
            gm = m.atricube()
            m.trn(vec3(0,0,1))
            p = nps[e[0]].cp()
            tn = nps[e[0]].tov(nps[e[1]])
            q = quat(0,0,0,0).uu(vec3(0,0,1),tn)
            s = vec3(0.05,0.05,0.5*tn.mag())
            sgv = self.amodel(p,q,s,m,None)
        return self
Beispiel #3
0
def cube_stage(p = None,q = None,s = None):
    m = dmo.model()
    cx = dcx.context()
    sgv = cx.amodel(p,q,s,m,cx.sgraph.root)
    gm = m.atricube()
    m.normals(gm)
    return cx
Beispiel #4
0
def cube_stage(p=None, q=None, s=None):
    m = dmo.model()
    cx = dcx.context()
    sgv = cx.amodel(p, q, s, m, cx.sgraph.root)
    gm = m.atricube()
    m.normals(gm)
    return cx
Beispiel #5
0
    def genshell(self):
        m = dmo.model()
        sgv = self.amodel(self.p,self.q,self.s,m,self.sgraph.root)
        tm = m.agfxmesh()
        z,eww,ech,fh = 0,0.2,0.5,self.bgraph.floorheight

        self.rims = []
        for lvx in range(self.floors):
            fp = [p.cp().ztrn(z) for p in self.bgraph.footprint]
            z += self.bgraph.floorheight
            self.rims.append([])
            for fpx in range(len(fp)):
                fp0,fp1,fp2 = fp[fpx-2],fp[fpx-1],fp[fpx]
                wtn1 = fp0.tov(fp1).nrm()
                wtn2 = fp1.tov(fp2).nrm()
                tcrstz = gtl.near(wtn1.crs(wtn2).z,0)
                if tcrstz > 0:
                    wnm1 = vec3(0,0,1).crs(wtn1).nrm().uscl(-eww)
                    wnm2 = vec3(0,0,1).crs(wtn2).nrm().uscl(-eww)
                    crnp1 = fp1.cp().trn(wnm1).ztrn(-ech)
                    crnp2 = fp1.cp().trn(wnm2).ztrn(-ech)
                    wpys,portals = pyg.awall(crnp1,crnp2,fh,[])
                    for wpy in wpys:m.asurf(wpy,tm)
                    self.rims[-1].extend([crnp1.cp().ztrn(fh),crnp2.cp().ztrn(fh)])
                elif tcrstz < 0:
                    wnm1 = vec3(0,0,1).crs(wtn1).nrm().uscl(-eww)
                    wnm2 = vec3(0,0,1).crs(wtn2).nrm().uscl(-eww)
                    crnp0 = fp0.cp().trn(wnm1).ztrn(-ech)
                    crnp1 = fp1.cp().trn(wnm1).ztrn(-ech)
                    crnp2 = fp1.cp().trn(wnm2).ztrn(-ech)
                    crnp3 = fp2.cp().trn(wnm2).ztrn(-ech)
                    ip = pym.sintsxyp(crnp0,crnp1,crnp2,crnp3)
                    self.rims[-1].append(ip.cp().ztrn(fh))
                for v in self.bgraph.vs:
                    if v is None:continue
                    vx,ves,vkw = v
                    vb = vkw['bound']
                    for vbx in range(len(vb)):
                        vb1,vb2 = vb[vbx-1],vb[vbx]
                        ips = pym.sintsxyp(fp1,fp2,vb1,vb2,ie = False,skew = False)
                        if not type(ips) is type(()):continue
                        hs = vkw['wholes'][vbx-1]
                        sh,ch = vkw['skirt'],vkw['crown']
                        wh = self.bgraph.floorheight-sh-ch
                        wtn = vb1.tov(vb2).crs(vec3(0,0,1)).nrm().uscl(eww)
                        wp1,wp2 = vb1.cp().trn(wtn),vb2.cp().trn(wtn)
                        wpys,portals = pyg.awall(wp1,wp2,wh,hs)
                        for wpy in wpys:m.asurf(wpy,tm)
                        for hps in portals:
                            wpys = pyg.aportal(hps,wp1,wp2,eww)
                            for wpy in wpys:m.asurf(wpy,tm)
                        sp1,sp2 = wp1.cp().ztrn(-sh),wp2.cp().ztrn(-sh)
                        cp1,cp2 = wp1.cp().ztrn( wh),wp2.cp().ztrn( wh)
                        wpys,portals = pyg.awall(sp1,sp2,sh,[])
                        for wpy in wpys:m.asurf(wpy,tm)
                        wpys,portals = pyg.awall(cp1,cp2,ch,[])
                        for wpy in wpys:m.asurf(wpy,tm)
Beispiel #6
0
 def branch(self,s,e,l,ml,mw):
     m = dmo.model()
     gm = m.atricube('generic')
     m.trn(vec3(0,0,1))
     p = s.MARK[1].cp()
     tn = s.MARK[1].tov(e.MARK[1])
     q = quat(0,0,0,0).uu(vec3(0,0,1),tn)
     w = 0.1*max((mw-(l/ml)**(0.25)),0.2)
     s = vec3(w,w,0.5*tn.mag())
     sgv = self.amodel(p,q,s,m,None)
Beispiel #7
0
 def branch(self, s, e, l, ml, mw):
     m = dmo.model()
     gm = m.atricube('generic')
     m.trn(vec3(0, 0, 1))
     p = s.MARK[1].cp()
     tn = s.MARK[1].tov(e.MARK[1])
     q = quat(0, 0, 0, 0).uu(vec3(0, 0, 1), tn)
     w = 0.1 * max((mw - (l / ml)**(0.25)), 0.2)
     s = vec3(w, w, 0.5 * tn.mag())
     sgv = self.amodel(p, q, s, m, None)
Beispiel #8
0
 def leaf(self, s, e):
     m = dmo.model()
     gm = m.atricube('generic')
     p = s.MARK[1].cp()
     tn = s.MARK[1].tov(e.MARK[1])
     q = quat(0, 0, 0, 0).uu(vec3(0, 0, 1), tn)
     #w = 0.1*max((mw-(l/ml)**(0.25)),0.2)
     #s = vec3(w,w,0.5*tn.mag())
     #q = quat(0,0,0,0).av(0.0,vec3(0,0,1))
     s = vec3(0.2, 0.2, 0.5 * tn.mag())
     m.trn(vec3(0, 0, 1))
     sgv = self.amodel(p, q, s, m, None)
Beispiel #9
0
 def leaf(self,s,e):
     m = dmo.model()
     gm = m.atricube('generic')
     p = s.MARK[1].cp()
     tn = s.MARK[1].tov(e.MARK[1])
     q = quat(0,0,0,0).uu(vec3(0,0,1),tn)
     #w = 0.1*max((mw-(l/ml)**(0.25)),0.2)
     #s = vec3(w,w,0.5*tn.mag())
     #q = quat(0,0,0,0).av(0.0,vec3(0,0,1))
     s = vec3(0.2,0.2,0.5*tn.mag())
     m.trn(vec3(0,0,1))
     sgv = self.amodel(p,q,s,m,None)
Beispiel #10
0
    def vgen_infrastructure(self, w, v, t, pg):
        print('infrastructure vertex', v.style, len(v.loop), len(v.holes))
        m = dmo.model()
        sgv = w.amodel(None, None, None, m, w.sgraph.root)
        tm = m.agfxmesh()

        rh = 0.0
        vb = [b.cp().ztrn(rh) for b in v.loop]
        vibs = [[b.cp().ztrn(rh) for b in h] for h in v.holes]
        vb = self.vstitch(vb, v, pg)
        vibs = [self.vstitch(vib, v, pg) for vib in v.holes]
        v.loop = vb
        v.holes = vibs

        ngvs = m.asurf((vb, vibs),
                       tm,
                       fm='concrete1',
                       ref=True,
                       hmin=100,
                       zfunc=t,
                       uvstacked=None,
                       autoconnect=True)
        lockf = lambda p: p.onpxy((v.loop, v.holes))
        m.subdiv(tm, False, True, lockf)

        return m

        rh = 0.0
        vb = [b.cp().ztrn(rh) for b in v[1]['b'][0]]
        vibs = [[b.cp().ztrn(rh) for b in v[1]['b'][1][x]]
                for x in range(len(v[1]['b'][1]))]
        vb = self.vstitch(vb, v, pg)
        vibs = [self.vstitch(vib, v, pg) for vib in v[1]['b'][1]]
        v[1]['b'] = vb, vibs

        ngvs = m.asurf((vb, vibs),
                       tm,
                       fm='concrete1',
                       ref=True,
                       hmin=100,
                       zfunc=v[1]['tmesh'],
                       uvstacked=None,
                       autoconnect=True)
        lockf = lambda p: p.onpxy(v[1]['b'])
        m.subdiv(tm, False, True, lockf)
        #m.subdiv(tm,False,True,lockf)
        #m.subdiv(tm,False,True,lockf)
        #m.uvs(tm)
        print('generated infrastructure')
        return m
Beispiel #11
0
    def genrooms(self):
        for v in self.bgraph.vs:
            if v is None: continue
            vx, ves, vkw = v

            # insert doors based on topology
            self.holes(vx)

            # dont build the room here if it contains a shaft
            if vkw['shaft']: continue

            # add a new trimesh to the model
            m = dmo.model()
            sgv = self.amodel(self.p, self.q, self.s, m, self.sgraph.root)
            tm = m.agfxmesh()

            # create the floor and ceiling surfaces
            #fbnd = pym.contract(vkw['bound'],max(vkw['wwidths']))
            fbnd = pym.contract(vkw['bound'], vkw['wwidths'])
            # need to place fbnd based on differing wwidths!!

            floor, ceiling = vkw['floor'], vkw['ceiling']
            if floor is None:
                floor = (tuple([p.cp() for p in fbnd]),
                         tuple(tuple(fh) for fh in vkw['fholes']))
            if floor: m.asurf(floor, tm)
            if ceiling is None:
                wh = min(vkw['wheights'])
                ceiling = (tuple([p.cp().ztrn(wh) for p in fbnd]),
                           tuple(tuple(ch) for ch in vkw['choles']))
            if ceiling: m.asurf(ceiling, tm, rv=True)

            # create the wall surfaces and portal surfaces
            for x in range(len(vkw['bound'])):
                b2, b1 = vkw['bound'][x - 1], vkw['bound'][x]
                w2, w1 = fbnd[x - 1], fbnd[x]
                hs, wt = vkw['wholes'][x - 1], vkw['wmetas'][x - 1]['type']
                wh, ww = vkw['wheights'][x - 1], vkw['wwidths'][x - 1]

                # create wall surfaces
                wpys, portals = pyg.awall(w1, w2, wh, hs, b1.cp(), b2.cp())
                for wpy in wpys:
                    m.asurf(wpy, tm)

                # create portal surfaces
                for hps in portals:
                    wpys = pyg.aportal(hps, w1, w2, ww)
                    for wpy in wpys:
                        m.asurf(wpy, tm)
Beispiel #12
0
def teststage(**kwargs):
    mod = dmo.model()

    #mod = tridome(mod)
    mod = house(mod)

    ax = dtl.plot_axes()
    for gmesh in mod.gfxmeshes:
        for f in gmesh.faces:
            ps = mod.gvps(gmesh,f)
            ax = dtl.plot_polygon(ps,ax)
    plt.show()

    print('build2 cube now')
    build2(mod,**kwargs)
Beispiel #13
0
def teststage(**kwargs):
    mod = dmo.model()

    #mod = tridome(mod)
    mod = house(mod)

    ax = dtl.plot_axes()
    for gmesh in mod.gfxmeshes:
        for f in gmesh.faces:
            ps = mod.gvps(gmesh, f)
            ax = dtl.plot_polygon(ps, ax)
    plt.show()

    print('build2 cube now')
    build2(mod, **kwargs)
Beispiel #14
0
 def vgen_ocean(self, w, v, pg, depth=2, bleed=5):
     print('ocean vertex', v[0])
     ### create an unrefined flat surface for the bottom of the ocean
     ###  and an unrefined flat surface with contracted holes for the
     ###  surface of the ocean
     m = dmo.model()
     sgv = w.amodel(None, None, None, m, w.sgraph.root)
     tm = m.agfxmesh()
     gb = v[1]['b']
     #lhs = [pym.contract([p.cp().ztrn(depth) for p in ib],bleed,5) for ib in gb[1]]
     lhs = [pym.contract([p.cp() for p in ib], bleed, 5) for ib in gb[1]]
     gb = [[p.cp() for p in gb[0]], lhs]
     wb = [[p.cp().ztrn(depth) for p in gb[0]],
           [[p.cp().ztrn(depth) for p in lh] for lh in lhs]]
     ngvs = m.asurf(gb, tm, fm='concrete1', ref=False, hmin=100, zfunc=None)
     ngvs = m.asurf(wb, tm, fm='concrete1', ref=False, hmin=100, zfunc=None)
Beispiel #15
0
    def genrooms(self):
        for v in self.bgraph.vs:
            if v is None:continue
            vx,ves,vkw = v

            # insert doors based on topology
            self.holes(vx)

            # dont build the room here if it contains a shaft
            if vkw['shaft']:continue

            # add a new trimesh to the model
            m = dmo.model()
            sgv = self.amodel(self.p,self.q,self.s,m,self.sgraph.root)
            tm = m.agfxmesh()

            # create the floor and ceiling surfaces
            #fbnd = pym.contract(vkw['bound'],max(vkw['wwidths']))
            fbnd = pym.contract(vkw['bound'],vkw['wwidths'])
            # need to place fbnd based on differing wwidths!!

            floor,ceiling = vkw['floor'],vkw['ceiling']
            if floor is None:
                floor = (tuple([p.cp() for p in fbnd]),
                    tuple(tuple(fh) for fh in vkw['fholes']))
            if floor:m.asurf(floor,tm)
            if ceiling is None:
                wh = min(vkw['wheights'])
                ceiling = (tuple([p.cp().ztrn(wh) for p in fbnd]),
                    tuple(tuple(ch) for ch in vkw['choles']))
            if ceiling:m.asurf(ceiling,tm,rv = True)

            # create the wall surfaces and portal surfaces
            for x in range(len(vkw['bound'])):
                b2,b1 = vkw['bound'][x-1],vkw['bound'][x]
                w2,w1 = fbnd[x-1],fbnd[x]
                hs,wt = vkw['wholes'][x-1],vkw['wmetas'][x-1]['type']
                wh,ww = vkw['wheights'][x-1],vkw['wwidths'][x-1]

                # create wall surfaces
                wpys,portals = pyg.awall(w1,w2,wh,hs,b1.cp(),b2.cp())
                for wpy in wpys:m.asurf(wpy,tm)

                # create portal surfaces
                for hps in portals:
                    wpys = pyg.aportal(hps,w1,w2,ww)
                    for wpy in wpys:m.asurf(wpy,tm)
Beispiel #16
0
    def vgen_terrain(self, w, v, t, r, a):
        m = dmo.model()
        sgv = w.amodel(None, None, None, m, w.sgraph.root)
        tm = m.agfxmesh()
        #vstitch isnt being used!!!
        #vstitch isnt being used!!!
        #vstitch isnt being used!!!
        # need to enforce that refinement is no problem for stitching!!!
        # need to enforce that refinement is no problem for stitching!!!
        # need to enforce that refinement is no problem for stitching!!!
        #  need to stitch from holes to interior regions!!!
        #  need to stitch from holes to interior regions!!!
        #  need to stitch from holes to interior regions!!!

        #vb = [b.cp() for b in v[1]['b'][0]]
        vb = [b.cp() for b in v.loop]
        vibs = [[b.cp() for b in h] for h in v.holes]
        #vibs = []
        vb = self.vstitch(vb, v, a)
        vibs = [self.vstitch(h, v, a) for h in v.holes]
        #v[1]['b'] = vb,vibs
        v.loop = vb
        v.holes = vibs

        print('generating terrain')
        ngvs = m.asurf((vb, vibs),
                       tm,
                       fm='grass2',
                       ref=True,
                       hmin=16,
                       zfunc=t,
                       rv=pym.bnrm(vb).z < 0,
                       uvstacked=None,
                       autoconnect=True)
        lockf = lambda p: p.onpxy((vb, vibs))
        m.subdiv(tm, False, True, lockf)
        #m.subdiv(tm,False,True,lockf)
        #m.subdiv(tm,False,True,lockf)
        m.uvs(tm)
        print('generated terrain')
        return m
Beispiel #17
0
 def genroof(self):
     m = dmo.model()
     sgv = self.amodel(self.p,self.q,self.s,m,self.sgraph.root)
     tm = m.agfxmesh()
     m.asurf((tuple(self.rims[-1]),()),tm)
Beispiel #18
0
 def genroof(self):
     m = dmo.model()
     sgv = self.amodel(self.p, self.q, self.s, m, self.sgraph.root)
     tm = m.agfxmesh()
     m.asurf((tuple(self.rims[-1]), ()), tm)
Beispiel #19
0
    def genshell(self):
        m = dmo.model()
        sgv = self.amodel(self.p, self.q, self.s, m, self.sgraph.root)
        tm = m.agfxmesh()
        z, eww, ech, fh = 0, 0.2, 0.5, self.bgraph.floorheight

        self.rims = []
        for lvx in range(self.floors):
            fp = [p.cp().ztrn(z) for p in self.bgraph.footprint]
            z += self.bgraph.floorheight
            self.rims.append([])
            for fpx in range(len(fp)):
                fp0, fp1, fp2 = fp[fpx - 2], fp[fpx - 1], fp[fpx]
                wtn1 = fp0.tov(fp1).nrm()
                wtn2 = fp1.tov(fp2).nrm()
                tcrstz = gtl.near(wtn1.crs(wtn2).z, 0)
                if tcrstz > 0:
                    wnm1 = vec3(0, 0, 1).crs(wtn1).nrm().uscl(-eww)
                    wnm2 = vec3(0, 0, 1).crs(wtn2).nrm().uscl(-eww)
                    crnp1 = fp1.cp().trn(wnm1).ztrn(-ech)
                    crnp2 = fp1.cp().trn(wnm2).ztrn(-ech)
                    wpys, portals = pyg.awall(crnp1, crnp2, fh, [])
                    for wpy in wpys:
                        m.asurf(wpy, tm)
                    self.rims[-1].extend(
                        [crnp1.cp().ztrn(fh),
                         crnp2.cp().ztrn(fh)])
                elif tcrstz < 0:
                    wnm1 = vec3(0, 0, 1).crs(wtn1).nrm().uscl(-eww)
                    wnm2 = vec3(0, 0, 1).crs(wtn2).nrm().uscl(-eww)
                    crnp0 = fp0.cp().trn(wnm1).ztrn(-ech)
                    crnp1 = fp1.cp().trn(wnm1).ztrn(-ech)
                    crnp2 = fp1.cp().trn(wnm2).ztrn(-ech)
                    crnp3 = fp2.cp().trn(wnm2).ztrn(-ech)
                    ip = pym.sintsxyp(crnp0, crnp1, crnp2, crnp3)
                    self.rims[-1].append(ip.cp().ztrn(fh))
                for v in self.bgraph.vs:
                    if v is None: continue
                    vx, ves, vkw = v
                    vb = vkw['bound']
                    for vbx in range(len(vb)):
                        vb1, vb2 = vb[vbx - 1], vb[vbx]
                        ips = pym.sintsxyp(fp1,
                                           fp2,
                                           vb1,
                                           vb2,
                                           ie=False,
                                           skew=False)
                        if not type(ips) is type(()): continue
                        hs = vkw['wholes'][vbx - 1]
                        sh, ch = vkw['skirt'], vkw['crown']
                        wh = self.bgraph.floorheight - sh - ch
                        wtn = vb1.tov(vb2).crs(vec3(0, 0, 1)).nrm().uscl(eww)
                        wp1, wp2 = vb1.cp().trn(wtn), vb2.cp().trn(wtn)
                        wpys, portals = pyg.awall(wp1, wp2, wh, hs)
                        for wpy in wpys:
                            m.asurf(wpy, tm)
                        for hps in portals:
                            wpys = pyg.aportal(hps, wp1, wp2, eww)
                            for wpy in wpys:
                                m.asurf(wpy, tm)
                        sp1, sp2 = wp1.cp().ztrn(-sh), wp2.cp().ztrn(-sh)
                        cp1, cp2 = wp1.cp().ztrn(wh), wp2.cp().ztrn(wh)
                        wpys, portals = pyg.awall(sp1, sp2, sh, [])
                        for wpy in wpys:
                            m.asurf(wpy, tm)
                        wpys, portals = pyg.awall(cp1, cp2, ch, [])
                        for wpy in wpys:
                            m.asurf(wpy, tm)
Beispiel #20
0
    def genshafts(self):
        def genwrap(shb, shx, skirt=True, crown=True):
            vkw = self.bgraph.vs[shvx][2]
            fbnd = pym.contract(shb, wwi)
            for x in range(len(shb)):
                b2, b1, w2, w1 = shb[x - 1], shb[x], fbnd[x - 1], fbnd[x]
                #hs,wt = vkw['wholes'][x-1],vkw['wtypes'][x-1]
                hs, wt = vkw['wholes'][x - 1], vkw['wmetas'][x - 1]['type']
                wh, ww = vkw['wheights'][x - 1], vkw['wwidths'][x - 1]
                sh, ch = vkw['skirt'], vkw['crown']
                wpys, portals = pyg.awall(w1, w2, wh, hs, b1.cp(), b2.cp())
                for wpy in wpys:
                    m.asurf(wpy, tm)
                for hps in portals:
                    wpys = pyg.aportal(hps, w1, w2, ww)
                    for wpy in wpys:
                        m.asurf(wpy, tm)
                if skirt:
                    sp1, sp2 = w1.cp().ztrn(-sh), w2.cp().ztrn(-sh)
                    wpys, portals = pyg.awall(sp1, sp2, sh, [])
                    for wpy in wpys:
                        m.asurf(wpy, tm)
                if crown:
                    cp1, cp2 = w1.cp().ztrn(wh), w2.cp().ztrn(wh)
                    wpys, portals = pyg.awall(cp1, cp2, ch, [])
                    for wpy in wpys:
                        m.asurf(wpy, tm)

        def genplatform(shb, shx):
            buff, rw = 6, 6
            fbnd = pym.contract(shb, wwi)
            platform = [p.cp() for p in fbnd]
            r1, r2 = platform[2].cp(), platform[3].cp()
            rtn = r1.tov(r2).nrm().uscl(buff)
            #rnm = vec3(0,0,1).crs(rtn).nrm().uscl(rw)
            rnm = pym.bnrm(fbnd).crs(rtn).nrm().uscl(rw)
            r2, r1 = r2.trn(rtn.flp()), r1.trn(rtn.flp())
            r3, r4 = r2.cp().trn(rnm), r1.cp().trn(rnm)

            belv = self.bgraph.vs[sh[shx - 1]][2]
            rh = max(belv['wheights']) + belv['skirt'] + belv['crown']
            ramp = [r4, r1, r2, r3]

            platform = pym.ebdxy(platform, ramp)
            #print(len(platform))
            platform = platform[len(platform) //
                                2]  # HACK TO GET CORRECT POLYGON...

            ramp[0].ztrn(-rh)
            ramp[1].ztrn(-rh)

            m.asurf((ramp, ()), tm)
            m.asurf((platform, ()), tm)

        def genbottom(shb):
            shaftfloor = pym.contract(shb, wwi)
            m.asurf((shaftfloor, ()), tm)
            genwrap(shb, shx - 1, skirt=False, crown=shcnt > 1)

        def gentop(shb):
            shaftceiling = [p.cp().ztrn(wht) for p in pym.contract(shb, wwi)]
            m.asurf((shaftceiling, ()), tm, rv=True)
            genplatform(shb, shx)
            genwrap(shb, shx + 1, crown=False)

        def genlink(shb, shx):
            genplatform(shb, shx)
            genwrap(shb, shx)

        for sh in self.bgraph.shafts:
            m = dmo.model()
            sgv = self.amodel(self.p, self.q, self.s, m, self.sgraph.root)
            tm = m.agfxmesh()

            shcnt = len(sh)
            for shx in range(shcnt):
                shvx = sh[shx]
                shv = self.bgraph.vs[shvx]
                shb = shv[2]['bound']
                wht = max(shv[2]['wheights'])
                wwi = min(shv[2]['wwidths'])

                if shx == 0: genbottom(shb)
                elif shx == shcnt - 1: gentop(shb)
                else: genlink(shb, shx)
Beispiel #21
0
    def genshafts(self):

        def genwrap(shb,shx,skirt = True,crown = True):
            vkw = self.bgraph.vs[shvx][2]
            fbnd = pym.contract(shb,wwi)
            for x in range(len(shb)):
                b2,b1,w2,w1 = shb[x-1],shb[x],fbnd[x-1],fbnd[x]
                #hs,wt = vkw['wholes'][x-1],vkw['wtypes'][x-1]
                hs,wt = vkw['wholes'][x-1],vkw['wmetas'][x-1]['type']
                wh,ww = vkw['wheights'][x-1],vkw['wwidths'][x-1]
                sh,ch = vkw['skirt'],vkw['crown']
                wpys,portals = pyg.awall(w1,w2,wh,hs,b1.cp(),b2.cp())
                for wpy in wpys:m.asurf(wpy,tm)
                for hps in portals:
                    wpys = pyg.aportal(hps,w1,w2,ww)
                    for wpy in wpys:m.asurf(wpy,tm)
                if skirt:
                    sp1,sp2 = w1.cp().ztrn(-sh),w2.cp().ztrn(-sh)
                    wpys,portals = pyg.awall(sp1,sp2,sh,[])
                    for wpy in wpys:m.asurf(wpy,tm)
                if crown:
                    cp1,cp2 = w1.cp().ztrn(wh),w2.cp().ztrn(wh)
                    wpys,portals = pyg.awall(cp1,cp2,ch,[])
                    for wpy in wpys:m.asurf(wpy,tm)

        def genplatform(shb,shx):
            buff,rw = 6,6
            fbnd = pym.contract(shb,wwi)
            platform = [p.cp() for p in fbnd]
            r1,r2 = platform[2].cp(),platform[3].cp()
            rtn = r1.tov(r2).nrm().uscl(buff)
            #rnm = vec3(0,0,1).crs(rtn).nrm().uscl(rw)
            rnm = pym.bnrm(fbnd).crs(rtn).nrm().uscl(rw)
            r2,r1 = r2.trn(rtn.flp()),r1.trn(rtn.flp())
            r3,r4 = r2.cp().trn(rnm),r1.cp().trn(rnm)

            belv = self.bgraph.vs[sh[shx-1]][2]
            rh = max(belv['wheights'])+belv['skirt']+belv['crown']
            ramp = [r4,r1,r2,r3]

            platform = pym.ebdxy(platform,ramp)
            #print(len(platform))
            platform = platform[len(platform)//2] # HACK TO GET CORRECT POLYGON...

            ramp[0].ztrn(-rh)
            ramp[1].ztrn(-rh)

            m.asurf((ramp,()),tm)
            m.asurf((platform,()),tm)

        def genbottom(shb):
            shaftfloor = pym.contract(shb,wwi)
            m.asurf((shaftfloor,()),tm)
            genwrap(shb,shx-1,skirt = False,crown = shcnt > 1)

        def gentop(shb):
            shaftceiling = [p.cp().ztrn(wht) for p in pym.contract(shb,wwi)]
            m.asurf((shaftceiling,()),tm,rv = True)
            genplatform(shb,shx)
            genwrap(shb,shx+1,crown = False)

        def genlink(shb,shx):
            genplatform(shb,shx)
            genwrap(shb,shx)

        for sh in self.bgraph.shafts:
            m = dmo.model()
            sgv = self.amodel(self.p,self.q,self.s,m,self.sgraph.root)
            tm = m.agfxmesh()

            shcnt = len(sh)
            for shx in range(shcnt):
                shvx = sh[shx]
                shv = self.bgraph.vs[shvx]
                shb = shv[2]['bound']
                wht = max(shv[2]['wheights'])
                wwi = min(shv[2]['wwidths'])

                if shx == 0:genbottom(shb)
                elif shx == shcnt-1:gentop(shb)
                else:genlink(shb,shx)
Beispiel #22
0
 def setUp(self):
     self.mod = dmo.model()
Beispiel #23
0
 def setUp(self):
     self.mod = dmo.model()