コード例 #1
0
    def vertex(self,commande,Nb_Param):
        if (Nb_Param==4):
            x,y,z = float(commande[1]),float(commande[2]),float(commande[3])
            if (self.poly != None):
                #Creating a new vertex with coords :
                v = EggVertex()
                v.setPos(Point3D(x,y,z))

                #Adding the new Vertex to the polygon :
                self.poly.addVertex(self.vertexPool.addVertex(v))
コード例 #2
0
    def make_vertex(self,
                    parent_obj_matrix,
                    obj_matrix,
                    polygon,
                    vertex,
                    use_smooth=False,
                    can_merge=False):
        egg_vertex = EggVertex()
        egg_vertex.set_color((1, 1, 1, 1))

        if can_merge:
            co = obj_matrix @ vertex.co
        else:
            co = vertex.co

        egg_vertex.set_pos(tuple(co))

        if use_smooth:
            normal = parent_obj_matrix @ vertex.normal
        else:
            normal = parent_obj_matrix @ polygon.normal

        egg_vertex.set_normal(tuple(normal))

        return egg_vertex
コード例 #3
0
    def make_circle(self, num_steps):
        data = EggData()

        vertex_pool = EggVertexPool('fan')
        data.addChild(vertex_pool)

        poly = EggPolygon()
        data.addChild(poly)

        for i in range(num_steps + 1):
            angle = 2 * math.pi * i / num_steps
            y = math.sin(angle) * config.minimap.size / 2
            x = math.cos(angle) * config.minimap.size / 2

            vertex = EggVertex()
            vertex.setPos(Point3D(x, 0, y))
            poly.addVertex(vertex_pool.addVertex(vertex))

        node = loadEggData(data)
        return node
コード例 #4
0
ファイル: util.py プロジェクト: pennomi/launchpad-ai-war
def make_fov(sweep=90, steps=16, scale=100):
    z = 1 + random.uniform(-0.01, 0.01)

    data = EggData()

    vp = EggVertexPool('fan')
    data.addChild(vp)

    poly = EggPolygon()
    data.addChild(poly)

    v = EggVertex()
    v.setPos(Point3D(0, 0, z))
    poly.addVertex(vp.addVertex(v))

    rads = deg2Rad(sweep)

    for i in range(steps + 1):
        a = rads * i / steps
        y = math.sin(a)
        x = math.cos(a)

        v = EggVertex()
        v.setPos(Point3D(x*scale, y*scale, z))
        poly.addVertex(vp.addVertex(v))

    node = loadEggData(data)
    np = NodePath(node)
    np.setH(sweep/2)
    return np
コード例 #5
0
ファイル: geometry.py プロジェクト: tarsbase/cosmonium
def DisplacementUVSphere(radius,
                         heightmap,
                         scale,
                         rings=5,
                         sectors=5,
                         inv_texture_u=False,
                         inv_texture_v=True):
    data = EggData()
    pool = EggVertexPool('pool')
    vertices = []
    data.addChild(pool)
    R = 1. / (rings)
    S = 1. / (sectors)
    for r in range(0, rings + 1):
        for s in range(0, sectors + 1):
            cos_s = cos(2 * pi * s * S + pi)
            sin_s = sin(2 * pi * s * S + pi)
            sin_r = sin(pi * r * R)
            cos_r = cos(pi * r * R)
            x = cos_s * sin_r
            y = sin_s * sin_r
            z = cos_r
            vertex = EggVertex()
            u = s * S
            v = r * R
            height = radius + heightmap.get_height_uv(u, v) * scale
            vertex.setPos(LPoint3d(x * height, y * height, z * height))
            if inv_texture_v:
                v = 1.0 - v
            if inv_texture_u:
                u = 1.0 - u
            vertex.setUv(LPoint2d(u, v))
            pool.addVertex(vertex)
            vertices.append(vertex)

    index = 0
    for r in range(0, rings):
        for s in range(0, sectors):
            poly = EggPolygon()
            data.addChild(poly)
            poly.addVertex(vertices[index + sectors + 1])
            poly.addVertex(vertices[index])
            poly.addVertex(vertices[index + sectors])

            poly = EggPolygon()
            data.addChild(poly)
            poly.addVertex(vertices[index + sectors + 1])
            poly.addVertex(vertices[index + 1])
            poly.addVertex(vertices[index])
            index += 1
    data.removeUnusedVertices(True)
    data.recomputeVertexNormals(45)
    data.recomputeTangentBinormal(GlobPattern(""))
    node = loadEggData(data)
    path = NodePath(node)
    path.flattenStrong()
    return path
コード例 #6
0
 def __eggifyverts(self, eprim, evpool, vlist):
     for vertex in vlist:
         ixyz = vertex['v']
         vinfo = self.points[ixyz - 1]
         vxyz, _ = vinfo
         ev = EggVertex()
         ev.setPos(Point3D(vxyz[0], vxyz[1], vxyz[2]))
         iuv = vertex['vt']
         if iuv is not None:
             vuv = self.uvs[iuv - 1]
             ev.setUv(Point2D(vuv[0], vuv[1]))
         inormal = vertex['vn']
         if inormal is not None:
             vn = self.normals[inormal - 1]
             ev.setNormal(Vec3D(vn[0], vn[1], vn[2]))
         evpool.addVertex(ev)
         eprim.addVertex(ev)
     return self
コード例 #7
0
 def readVecteur(self, data):
     v = EggVertex()
     x,y,z = struct.unpack('fff', data)        
     v.setPos(Point3D(x,y,z))
     return v 
コード例 #8
0
ファイル: torus.py プロジェクト: Changuito/juan_example
def makeVertex(vp, x, y, z):
  v = EggVertex()
  v.setPos(Point3D(x, y, z))
  vp.addVertex(v)
  return v
コード例 #9
0
    def createGizmo(self, angleDegrees=360, numSteps=16, axis=0, scale=10):
        data = EggData()

        vp = EggVertexPool('fan')
        data.addChild(vp)

        poly = EggPolygon()
        data.addChild(poly)

        v = EggVertex()
        v.setPos(Point3D(0, 0, 0))
        poly.addVertex(vp.addVertex(v))

        angleRadians = deg2Rad(angleDegrees)

        for i in range(numSteps + 1):
            a = angleRadians * i / numSteps
            y = math.sin(a) * scale
            x = math.cos(a) * scale
            v = EggVertex()
            if axis is 0:
                v.setPos(Point3D(x, 0, y))
            elif axis is 1:
                v.setPos(Point3D(x, y, 0))
            else:
                v.setPos(Point3D(0, x, y))
            poly.addVertex(vp.addVertex(v))
        node = loadEggData(data)
        return NodePath(node)
コード例 #10
0
    def createCuttingPlanes(self):
        self.planes = self.render.attachNewNode("planes")
        pl = self.planes.attachNewNode("pl")
        data = EggData()
        self.planedata = []

        vp = EggVertexPool('plane')
        data.addChild(vp)

        fac = 1.0
        expanse = 10.0
        rng = 4
        for i in range(-rng, rng):
            poly = EggPolygon()
            data.addChild(poly)

            self.planedata.append(i * fac)

            v = EggVertex()
            v.setPos(Point3D(i * fac, -expanse, -expanse))
            poly.addVertex(vp.addVertex(v))
            v = EggVertex()
            v.setPos(Point3D(i * fac, -expanse, +expanse))
            poly.addVertex(vp.addVertex(v))
            v = EggVertex()
            v.setPos(Point3D(i * fac, +expanse, +expanse))
            poly.addVertex(vp.addVertex(v))
            v = EggVertex()
            v.setPos(Point3D(i * fac, +expanse, -expanse))
            poly.addVertex(vp.addVertex(v))

        node = loadEggData(data)
        np = NodePath(node)
        np.reparentTo(pl)
        np.setColor(0, 1, 0, 1)
        np.setTwoSided(True)
        np.setTransparency(TransparencyAttrib.MAlpha)
        np.setAlphaScale(0.1)
        np.setCollideMask(BitMask32(0x0))
        return self.planes
コード例 #11
0
def makeVertex(vp, x, y, z):
    v = EggVertex()
    v.setPos(Point3D(x, y, z))
    vp.addVertex(v)
    return v
コード例 #12
0
ファイル: panda.py プロジェクト: Kwentar/SECR
 def addPoint(self, pos):
     eggVtx = EggVertex()
     eggVtx.setPos(Point3D(pos[0], pos[1], pos[2]))
     self.myverts.append(eggVtx)
     self.vtxPool.addVertex(eggVtx)