当前位置: 首页>>代码示例>>Python>>正文


Python GeomNode.addGeom方法代码示例

本文整理汇总了Python中pandac.PandaModules.GeomNode.addGeom方法的典型用法代码示例。如果您正苦于以下问题:Python GeomNode.addGeom方法的具体用法?Python GeomNode.addGeom怎么用?Python GeomNode.addGeom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandac.PandaModules.GeomNode的用法示例。


在下文中一共展示了GeomNode.addGeom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
 def draw(self):
     format=GeomVertexFormat.getV3n3cpt2()
     vdata=GeomVertexData('square', format, Geom.UHDynamic)
     vertex=GeomVertexWriter(vdata, 'vertex')
     normal=GeomVertexWriter(vdata, 'normal')
     color=GeomVertexWriter(vdata, 'color')
     circle=Geom(vdata)
     # Create vertices
     vertex.addData3f(self.pos)
     color.addData4f(self.color)
     for v in range(self._EDGES):
         x = self.pos.getX() + (self.size * math.cos((2*math.pi/self._EDGES)*v))
         y = self.pos.getY() + (self.size * math.sin((2*math.pi/self._EDGES)*v))
         z = self.pos.getZ()
         vertex.addData3f(x, y, z)
         color.addData4f(self.color)
     
     # Create triangles
     for t in range(self._EDGES):
         tri = GeomTriangles(Geom.UHDynamic)
         tri.addVertex(0)
         tri.addVertex(t+1)
         if (t+2) > self._EDGES:
             tri.addVertex(1)
         else:
             tri.addVertex(t+2)
         tri.closePrimitive()
         circle.addPrimitive(tri)
     
     gn = GeomNode('Circle')
     gn.addGeom(circle)
     np = NodePath(gn)
     np.setHpr(0, 90, 0)
     return np
开发者ID:crempp,项目名称:Fire-Water,代码行数:36,代码来源:GeomObjects.py

示例2: create_hexagon

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
def create_hexagon(radius):
    """ Creates a hexagon shape that is centered at (0,0,0) with the corners having a distance of radius to the center and
    the normals pointing in direction (0,-1,0). 
    Returns the tuple (PandaNode, GeomVertexData). """
    format = GeomVertexFormat.getV3n3c4t2()
    vdata=GeomVertexData('hexagon', format, Geom.UHStatic)
    vertex=GeomVertexWriter(vdata, 'vertex')
    normal=GeomVertexWriter(vdata, 'normal')
    # create the vertices
    vertex.addData3f(0,0,0)
    normal.addData3f(0,-1,0)
    # add the other vertices
    for phi in range(0,360,60):
        # right-hand-rule (with middle finger pointing upwards): the y-axis points towards the screen,
        # therefore the hexagon will be created in the x,z plane, with x-axis pointing to the right
        # and the z-axis pointing up
        # get the next vertex coordinates by rotating the point (0,0,radius) in the x,z plane
        x,z = rotate_phi_degrees_counter_clockwise(phi, (0,radius))
        #print (x,z)
        vertex.addData3f(x,0,z) 
        normal.addData3f(0,-1,0) # the normal vector points away from the screen
    # add the vertices to a geometry primitives
    prim = GeomTrifans(Geom.UHStatic)
    for i in range(7):
        prim.addVertex(i)
    prim.addVertex(1)
    prim.closePrimitive()
    geom = Geom(vdata)
    geom.addPrimitive(prim)
    hex_node = GeomNode('')
    hex_node.addGeom(geom)
    return hex_node, vdata
开发者ID:JingLu92,项目名称:pyff,代码行数:34,代码来源:GraphicComponentUtils.py

示例3: __init__

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
    def __init__(self, width=1, depth=1, height=1, origin=Point3(0, 0, 0)):

        # Create vetex data format
        gvf = GeomVertexFormat.getV3n3()
        gvd = GeomVertexData("vertexData", gvf, Geom.UHStatic)

        # Create vetex writers for each type of data we are going to store
        gvwV = GeomVertexWriter(gvd, "vertex")
        gvwN = GeomVertexWriter(gvd, "normal")

        # Write out all points
        for p in GetPointsForBox(width, depth, height):
            gvwV.addData3f(Point3(p) - origin)

        # Write out all the normals
        for n in ((-1, 0, 0), (1, 0, 0), (0, -1, 0), (0, 1, 0), (0, 0, -1), (0, 0, 1)):
            for i in range(4):
                gvwN.addData3f(n)

        geom = Geom(gvd)
        for i in range(0, gvwV.getWriteRow(), 4):

            # Create and add both triangles
            geom.addPrimitive(GetGeomTriangle(i, i + 1, i + 2))
            geom.addPrimitive(GetGeomTriangle(i, i + 2, i + 3))

        # Init the node path, wrapping the box
        geomNode = GeomNode("box")
        geomNode.addGeom(geom)
        NodePath.__init__(self, geomNode)
开发者ID:LBdN,项目名称:labs,代码行数:32,代码来源:geometry.py

示例4: create_triangle

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
def create_triangle(x_z_left, x_z_top, x_z_right, static=True):
    x1,z1 = x_z_left
    x2,z2 = x_z_top
    x3,z3 = x_z_right
    format = GeomVertexFormat.getV3n3c4t2()
    vdata=GeomVertexData('', format, Geom.UHStatic)
    vertex=GeomVertexWriter(vdata, 'vertex')
    normal=GeomVertexWriter(vdata, 'normal')
    vertex.addData3f(x1, 0, z1) # left
    vertex.addData3f(x2, 0, z2) # top
    vertex.addData3f(x3, 0, z3) # right
    for _i in range(3):
        normal.addData3f(0,-1,0)
    if static:
        prim_hint = Geom.UHStatic
    else:
        prim_hint = Geom.UHDynamic
    prim = GeomTriangles(prim_hint)
    prim.addVertices(0,2,1)
    prim.closePrimitive()
    geom = Geom(vdata)
    geom.addPrimitive(prim)
    node = GeomNode('')
    node.addGeom(geom)
    return node
开发者ID:JingLu92,项目名称:pyff,代码行数:27,代码来源:GraphicComponentUtils.py

示例5: create_side

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
def create_side(x_z_top_left, x_z_bottom_right, static=True):
    x1, z1 = x_z_top_left
    x2, z2 = x_z_bottom_right
    format = GeomVertexFormat.getV3n3c4t2()
    vdata = GeomVertexData('', format, Geom.UHStatic)
    vertex = GeomVertexWriter(vdata, 'vertex')
    normal = GeomVertexWriter(vdata, 'normal')
    vertex.addData3f(x1, 0, z1) # top left
    vertex.addData3f(x2, 0, z1) # top right
    vertex.addData3f(x2, 0, z2) # bottom right
    vertex.addData3f(x1, 0, z2) # bottom left
    for _i in range(4):
        normal.addData3f(0, - 1, 0)
    if static:
        prim_hint = Geom.UHStatic
    else:
        prim_hint = Geom.UHDynamic
    prim = GeomTristrips(prim_hint)
    prim.addVertices(1, 0, 2, 3)
    prim.closePrimitive()
    geom = Geom(vdata)
    geom.addPrimitive(prim)
    node = GeomNode('')
    node.addGeom(geom)
    return (node, vdata)
开发者ID:JingLu92,项目名称:pyff,代码行数:27,代码来源:GraphicComponentUtils.py

示例6: createPitchLineOld

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
    def createPitchLineOld(self,points=[0.5,0.25,-0.25,-0.5],
                            tick=0.00,colour=None):
        """ create a line to hint at the pitch of the aircraft on the hud """
        if colour is None:
            colour = self.colour

        l = LineNodePath(aspect2d,'pitchline',4,Vec4(colour[0],colour[1],
                                                       colour[2],colour[3]))

        plist = []
        for p in points:
            plist.append((p,0.0,0.0))
        plist.insert(0,(points[0],0.0,tick))
        plist.append((points[3],0.0,tick))

        linelist = []
        linelist = [[plist[p],plist[p+1]] for p in range(len(plist)-1)]
        linelist.pop(2)
        l.drawLines(linelist)
        l.create()

        # These lines are drawn from scratch rather than using a graphic file

        format = GeomVertexFormat.getV3()
        vdata = GeomVertexData("vertices",format,Geom.UHStatic)

        # create vertices to add to use in creating lines
        vertexWriter=GeomVertexWriter(vdata,"vertex")
        # here we define enough positions to create two separated lines
        for p in points:
            vertexWriter.addData3f(p,0.0,0.0)
        # and another two positions for the 'ticks' at the line ends
        vertexWriter.addData3f(points[0],0.0,tick)
        vertexWriter.addData3f(points[3],0.0,tick)

        # create the primitives
        line = GeomLines(Geom.UHStatic)
        line.addVertices(4,0) # the tick part
        line.addVertices(0,1) # part of the horizontal line
        line.closePrimitive()
        line2 = GeomLines(Geom.UHStatic)
        line2.addVertices(2,3) # other part of the horizontal line
        line2.addVertices(3,5) # second tick
        line2.closePrimitive()

        # add the lines to a geom object
        lineGeom = Geom(vdata)
        lineGeom.addPrimitive(line)
        lineGeom.addPrimitive(line2)

        # create the node..
        lineGN=GeomNode("splitline")
        lineGN.addGeom(lineGeom)

        # and parent the node to aspect2d
        lineNP = aspect2d.attachNewNode(lineGN)
        return lineNP
开发者ID:GunioRobot,项目名称:Azure--Infinite-Skies,代码行数:59,代码来源:gui.py

示例7: createCentreMarkOld

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
    def createCentreMarkOld(self,colour=None):
        """ create a line to hint at the pitch of the aircraft on the hud """
        if colour is None:
            colour = self.colour

        # These lines are drawn from scratch rather than using a graphic file

        format = GeomVertexFormat.getV3()
        vdata = GeomVertexData("vertices",format,Geom.UHStatic)

        # create vertices to add to use in creating lines
        vertexWriter=GeomVertexWriter(vdata,"vertex")
        # essentially I am trying to create a line that gives an idea of
        #       where the forward vector of the plane is pointing which
        #       helps indicate the pitch
        # the bends in the line could be used to indicate a few angles but
        #       I am not sure how useful this really is.
        vertexWriter.addData3f(0.15,0.0,0.0)
        vertexWriter.addData3f(0.10,0.0,0.0)
        vertexWriter.addData3f(0.05,0.0,-0.025)
        vertexWriter.addData3f(0.00,0.0,0.025)
        vertexWriter.addData3f(-0.05,0.0,-0.025)
        vertexWriter.addData3f(-0.10,0.0,0.0)
        vertexWriter.addData3f(-0.15,0.0,0.0)

        # create the primitives
        line = GeomLines(Geom.UHStatic)
        line.addVertices(0,1)
        line.addVertices(1,2)
        line.addVertices(2,3)
        line.addVertices(3,4)
        line.addVertices(4,5)
        line.addVertices(5,6)
        line.closePrimitive()

        # add the lines to a geom object
        lineGeom = Geom(vdata)
        lineGeom.addPrimitive(line)

        # create the node..
        lineGN=GeomNode("centremark")
        lineGN.addGeom(lineGeom)

        # and parent the node to aspect2d
        lineNP = aspect2d.attachNewNode(lineGN)
        return lineNP
开发者ID:GunioRobot,项目名称:Azure--Infinite-Skies,代码行数:48,代码来源:gui.py

示例8: create_line

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
def create_line(x1, z1, x2, z2):
    format = GeomVertexFormat.getV3n3c4t2()
    vdata = GeomVertexData('', format, Geom.UHStatic)
    vertex = GeomVertexWriter(vdata, 'vertex')
    normal = GeomVertexWriter(vdata, 'normal')
    vertex.addData3f(x1, 0, z1)
    vertex.addData3f(x2, 0, z2) 
    for _i in range(2):
        normal.addData3f(0, - 1, 0)
    prim_hint = Geom.UHStatic
    prim = GeomLines(prim_hint)
    prim.addVertices(0, 1)
    prim.closePrimitive()
    geom = Geom(vdata)
    geom.addPrimitive(prim)
    node = GeomNode('')
    node.addGeom(geom)
    return (node, vdata)
开发者ID:JingLu92,项目名称:pyff,代码行数:20,代码来源:GraphicComponentUtils.py

示例9: generate

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
    def generate(self):
        format = GeomVertexFormat.getV3()
        data = GeomVertexData("Data", format, Geom.UHStatic)
        vertices = GeomVertexWriter(data, "vertex")

        size = self.size
        vertices.addData3f(-size, -size, -size)
        vertices.addData3f(+size, -size, -size)
        vertices.addData3f(-size, +size, -size)
        vertices.addData3f(+size, +size, -size)
        vertices.addData3f(-size, -size, +size)
        vertices.addData3f(+size, -size, +size)
        vertices.addData3f(-size, +size, +size)
        vertices.addData3f(+size, +size, +size)

        triangles = GeomTriangles(Geom.UHStatic)

        def addQuad(v0, v1, v2, v3):
            triangles.addVertices(v0, v1, v2)
            triangles.addVertices(v0, v2, v3)
            triangles.closePrimitive()

        addQuad(4, 5, 7, 6) # Z+
        addQuad(0, 2, 3, 1) # Z-
        addQuad(3, 7, 5, 1) # X+
        addQuad(4, 6, 2, 0) # X-
        addQuad(2, 6, 7, 3) # Y+
        addQuad(0, 1, 5, 4) # Y+

        geom = Geom(data)
        geom.addPrimitive(triangles)

        node = GeomNode("CubeMaker")
        node.addGeom(geom)

        path = NodePath(node)
        path.setColor(1.0, 0.0, 1.0)

        return NodePath(node)
开发者ID:scottjrodgers,项目名称:RobotLab,代码行数:41,代码来源:cubemaker.py

示例10: make_layer

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]

#.........这里部分代码省略.........
        t2 = data[x+1][y]['texnum']
        v3 = Vec3(x+1, y+1, data[x+1][y+1]['h'])
        c3 = data[x+1][y+1]['c']
        t3 = data[x+1][y+1]['texnum']
        v4 = Vec3(x, y+1, data[x][y+1]['h'])
        c4 = data[x][y+1]['c']
        t4 = data[x][y+1]['texnum']
        n=(0, 0, 1) # normal

        # assign vertex colors + alpha
        a1, a2, a3, a4 = ap(t1), ap(t2), ap(t3), ap(t4)
        t1, t2, t3, t4 = tp(t1), tp(t2), tp(t3), tp(t4)

        if v1[2]==0:
          t1 = [data[x][y]['c'][0], data[x][y]['c'][1], data[x][y]['c'][2],
                a1]
        if v2[2]==0:
          t2 = [data[x+1][y]['c'][0], data[x+1][y]['c'][1],
                data[x+1][y]['c'][2], a2]
        if v3[2]==0:
          t3 = [data[x+1][y+1]['c'][0], data[x+1][y+1]['c'][1],
                data[x+1][y+1]['c'][2], a3]
        if v4[2]==0:
          t4 = [data[x][y+1]['c'][0], data[x][y+1]['c'][1],
                data[x][y+1]['c'][2], a4]

        if a1 == 0 and a2 == 0 and a3 == 0 and a4 == 0:
          continue

        # add vertices
        vertex.addData3f(v1)
        normal.addData3f(*n)
        color.addData4f(*t1)
        uv.addData2f(0,0)

        vertex.addData3f(v2)
        normal.addData3f(*n)
        color.addData4f(*t2)
        uv.addData2f(1,0)

        vertex.addData3f(v3)
        normal.addData3f(*n)
        color.addData4f(*t3)
        uv.addData2f(1,1)

        vertex.addData3f(v1)
        normal.addData3f(*n)
        color.addData4f(*t1)
        uv.addData2f(0,0)

        vertex.addData3f(v3)
        normal.addData3f(*n)
        color.addData4f(*t3)
        uv.addData2f(1,1)

        vertex.addData3f(v4)
        normal.addData3f(*n)
        color.addData4f(*t4)
        uv.addData2f(0,1)

        number = number + 2

    # add triangles
    prim = GeomTriangles(Geom.UHStatic)
    for n in range(number):
      prim.addVertices((n * 3) + 2, (n * 3) + 0, (n * 3) + 1)
    prim.closePrimitive()

    # make geom
    geom = Geom(vdata)
    geom.addPrimitive(prim)

    # make geom node
    node = GeomNode("layer" + str(i) + "_" + str(a) + "_" + str(b))
    node.addGeom(geom)

    # make mesh nodePath
    mesh = NodePath(node)

    # load and assign texture
    txfile = self.tiles[i]['tex']
    tx = base.loader.loadTexture(txfile)
    tx.setMinfilter(Texture.FTLinearMipmapLinear)
    mesh.setDepthTest(DepthTestAttrib.MLessEqual)
    mesh.setDepthWrite(False)
    mesh.setTransparency(True)
    mesh.setTexture(tx)

    # set render order
    mesh.setBin("", 1)

    # locate mesh
    mesh.setPos(self.divsep * (a * int(len(self.data[a]) / self.div)),
                self.divsep * (b * int(len(self.data[b]) / self.div)), 0.001)

    # reparent mesh
    mesh.reparentTo(self.root)

    # return mesh
    return mesh
开发者ID:asceth,项目名称:devsyn,代码行数:104,代码来源:terrain.py

示例11: make_base

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]

#.........这里部分代码省略.........
        # option2: color vertices
        if option == 2:
          alpha = 1.0
          c1 = [data[x][y]['c'][0], data[x][y]['c'][1],
                data[x][y]['c'][2], alpha]
          c2 = [data[x+1][y]['c'][0], data[x+1][y]['c'][1],
                data[x+1][y]['c'][2], alpha]
          c3 = [data[x+1][y+1]['c'][0], data[x+1][y+1]['c'][1],
                data[x+1][y+1]['c'][2], alpha]
          c4 = [data[x][y+1]['c'][0], data[x][y+1]['c'][1],
                data[x][y+1]['c'][2], alpha]

        if option == 3:
          c1 = self.color_vertex(v1)
          c2 = self.color_vertex(v2)
          c3 = self.color_vertex(v3)
          c4 = self.color_vertex(v4)

        vertex.addData3f(v1)
        normal.addData3f(*n)
        color.addData4f(*c1)
        uv.addData2f(0,0)

        vertex.addData3f(v2)
        normal.addData3f(*n)
        color.addData4f(*c2)
        uv.addData2f(1,0)

        vertex.addData3f(v3)
        normal.addData3f(*n)
        color.addData4f(*c3)
        uv.addData2f(1,1)

        vertex.addData3f(v1)
        normal.addData3f(*n)
        color.addData4f(*c1)
        uv.addData2f(0,0)

        vertex.addData3f(v3)
        normal.addData3f(*n)
        color.addData4f(*c3)
        uv.addData2f(1,1)

        vertex.addData3f(v4)
        normal.addData3f(*n)
        color.addData4f(*c4)
        uv.addData2f(0,1)

#         # add vertex h
#         vertex.addData3f(v1)
#         # normal.addData3f(*n)
#         vertex.addData3f(v2)
#         # normal.addData3f(*n)
#         vertex.addData3f(v3)
#         # normal.addData3f(*n)
#         vertex.addData3f(v1)
#         # normal.addData3f(*n)
#         vertex.addData3f(v3)
#         # normal.addData3f(*n)
#         vertex.addData3f(v4)
#         # normal.addData3f(*n)
#         # add vertex color
#         color.addData4f(*c1)
#         color.addData4f(*c2)
#         color.addData4f(*c3)
#         color.addData4f(*c1)
#         color.addData4f(*c3)
#         color.addData4f(*c4)

        # iterate
        number = number + 2

    # add triangles
    prim = GeomTriangles(Geom.UHStatic)
    for n in range(number):
      prim.addVertices((n * 3) + 2, (n * 3) + 0, (n * 3) + 1)
    prim.closePrimitive()

    # make geom
    geom = Geom(vdata)
    geom.addPrimitive(prim)

    # make geom node
    node = GeomNode("base" + "_" + str(a) + "_" + str(b))
    node.addGeom(geom)

    # make mesh nodePath
    mesh = NodePath(node)
    # set render order
    mesh.setBin("", 1)

    # locate mesh
    mesh.setPos(self.divsep * (a * int(len(self.data[a]) / self.div)),
                self.divsep * (b * int(len(self.data[b]) / self.div)), 0)

    # reparent mesh
    mesh.reparentTo(self.root)

    # return mesh
    return mesh
开发者ID:asceth,项目名称:devsyn,代码行数:104,代码来源:terrain.py

示例12: generate_sphere

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
def generate_sphere(name, radius, resolution):
    """
    Generates a sphere with the provided resolution.

    @type name: string
    @param name: Name of this sphere.

    @type radius: number
    @param radius: Radius of sphere in kilometers.

    @type resolution: number
    @param resolution: Resolution of sphere (minimum 2)

    @rtype: GeomNode
    @return: A GeomNode with the given sphere.
    """

    if resolution < 2:
        raise ValueError, "resolution must be >= 2"

    horizBands = resolution*2
    vertBands = horizBands*2

    vertexFormat = GeomVertexFormat.getV3n3c4t2()
    vdata = GeomVertexData('%s_vdata' % name, vertexFormat, Geom.UHDynamic)

    vertex = GeomVertexWriter(vdata, 'vertex')
    color = GeomVertexWriter(vdata, 'color')
    normal = GeomVertexWriter(vdata, 'normal')
    texcoord = GeomVertexWriter(vdata, 'texcoord')

    vertDelta = omath.TWOPI / vertBands
    horizDelta = omath.TWOPI / horizBands

    numVertices = 0

    for i in range(vertBands+1):
        lowTheta = i * vertDelta
        highTheta = (i+1) * vertDelta

        cosLowTheta = math.cos(lowTheta)
        sinLowTheta = math.sin(lowTheta)
        cosHighTheta = math.cos(highTheta)
        sinHighTheta = math.sin(highTheta)

        for j in range(horizBands):
            horizTheta = j * horizDelta

            cosHorizTheta = math.cos(horizTheta)
            sinHorizTheta = math.sin(horizTheta)

            ex = cosLowTheta*cosHorizTheta
            ey = sinLowTheta
            ez = cosLowTheta*sinHorizTheta

            vertex.addData3f(ex*radius, ey*radius, ez*radius)
            normal.addData3f(ex, ey, ez)
            color.addData4f(.75, .75, .75, 1)
            texcoord.addData2f(i / vertBands, j / horizBands)

            ex = cosHighTheta*cosHorizTheta
            ey = sinHighTheta
            ez = cosHighTheta*sinHorizTheta

            vertex.addData3f(ex*radius, ey*radius, ez*radius)
            normal.addData3f(ex, ey, ez)
            color.addData4f(.75, .75, .75, 1)
            texcoord.addData2f(i / vertBands, j / horizBands)

            numVertices += 2

    prim = GeomTristrips(Geom.UHStatic)
    prim.addConsecutiveVertices(0, numVertices)
    prim.closePrimitive()

    geom = Geom(vdata)
    geom.addPrimitive(prim)

    geomNode = GeomNode(name)
    geomNode.addGeom(geom)

    return GeomScaler(geomNode)
开发者ID:smoluf,项目名称:orbitalindustry,代码行数:84,代码来源:mesh.py

示例13: drawBody

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
def drawBody(nodePath, vdata, pos, vecList, radius=1, keepDrawing=True,numVertices=8):

	circleGeom=Geom(vdata)

	vertWriter=GeomVertexWriter(vdata, "vertex")
	colorWriter=GeomVertexWriter(vdata, "color")
	normalWriter=GeomVertexWriter(vdata, "normal")
	drawReWriter=GeomVertexRewriter(vdata, "drawFlag")
	texReWriter=GeomVertexRewriter(vdata, "texcoord")
	
	
	startRow=vdata.getNumRows()
	vertWriter.setRow(startRow)
	colorWriter.setRow(startRow)
	normalWriter.setRow(startRow)
	
	sCoord=0

	if (startRow!=0):
		texReWriter.setRow(startRow-numVertices)
		sCoord=texReWriter.getData2f().getX()+1
		
		drawReWriter.setRow(startRow-numVertices)
		if(drawReWriter.getData1f()==False):
			sCoord-=1
	
	drawReWriter.setRow(startRow)
	texReWriter.setRow(startRow)	
	
	angleSlice=2*math.pi/numVertices
	currAngle=0
			
	#axisAdj=Mat4.rotateMat(45, axis)*Mat4.scaleMat(radius)*Mat4.translateMat(pos)

	perp1=vecList[1]
	perp2=vecList[2]	

	#vertex information is written here
	for i in range(numVertices):
		adjCircle=pos+(perp1*math.cos(currAngle)+perp2*math.sin(currAngle))*radius
		normal=perp1*math.cos(currAngle)+perp2*math.sin(currAngle)		
		normalWriter.addData3f(normal)
		vertWriter.addData3f(adjCircle)
		texReWriter.addData2f(sCoord,(i+0.001)/(numVertices-1))
		colorWriter.addData4f(0.5,0.5,0.5,1)
		drawReWriter.addData1f(keepDrawing)
		currAngle+=angleSlice

	
	drawReader=GeomVertexReader(vdata, "drawFlag")
	drawReader.setRow(startRow-numVertices)

	#we cant draw quads directly so we use Tristrips
	if (startRow!=0) & (drawReader.getData1f()!=False):
		lines=GeomTristrips(Geom.UHStatic)
		half=int(numVertices*0.5)
		for i in range(numVertices):
			lines.addVertex(i+startRow)
			if i< half:
				lines.addVertex(i+startRow-half)
			else:
				lines.addVertex(i+startRow-half-numVertices)

		lines.addVertex(startRow)
		lines.addVertex(startRow-half)
		lines.closePrimitive()
		lines.decompose()
		circleGeom.addPrimitive(lines)
		

		circleGeomNode=GeomNode("Debug")
		circleGeomNode.addGeom(circleGeom)

		#I accidentally made the front-face face inwards. Make reverse makes the tree render properly and
			#should cause any surprises to any poor programmer that tries to use this code
		circleGeomNode.setAttrib(CullFaceAttrib.makeReverse(),1)
		global numPrimitives
		numPrimitives+=numVertices*2
	
		nodePath.attachNewNode(circleGeomNode)
开发者ID:juancq,项目名称:character-evolver,代码行数:82,代码来源:Tut-Fractal-Plants.py

示例14: draw_body

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]
  def draw_body(self, position, vector_list, radius = 1, keep_drawing = True, num_vertices = 8):
    circle_geom = Geom(self.vdata)

    vertex_writer = GeomVertexWriter(self.vdata, "vertex")
    color_writer = GeomVertexWriter(self.vdata, "color")
    normal_writer = GeomVertexWriter(self.vdata, "normal")
    draw_rewriter = GeomVertexRewriter(self.vdata, "drawFlag")
    tex_rewriter = GeomVertexRewriter(self.vdata, "texcoord")

    start_row = self.vdata.getNumRows()
    vertex_writer.setRow(start_row)
    color_writer.setRow(start_row)
    normal_writer.setRow(start_row)

    sCoord = 0

    if start_row != 0:
      tex_rewriter.setRow(start_row - num_vertices)
      sCoord = tex_rewriter.getData2f().getX() + 1

      draw_rewriter.setRow(start_row - num_vertices)
      if draw_rewriter.getData1f() == False:
        sCoord -= 1

    draw_rewriter.setRow(start_row)
    tex_rewriter.setRow(start_row)

    angle_slice = 2 * math.pi / num_vertices
    current_angle = 0

    perp1 = vector_list[1]
    perp2 = vector_list[2]

    # write vertex information
    for i in range(num_vertices):
      adjacent_circle = position + (perp1 * math.cos(current_angle) + perp2 * math.sin(current_angle)) * radius
      normal = perp1 * math.cos(current_angle) + perp2 * math.sin(current_angle)
      normal_writer.addData3f(normal)
      vertex_writer.addData3f(adjacent_circle)
      tex_rewriter.addData2f(sCoord, (i + 0.001) / (num_vertices - 1))
      color_writer.addData4f(0.5, 0.5, 0.5, 1.0)
      draw_rewriter.addData1f(keep_drawing)
      current_angle += angle_slice

    draw_reader = GeomVertexReader(self.vdata, "drawFlag")
    draw_reader.setRow(start_row - num_vertices)

    # we can't draw quads directly so use Tristrips
    if start_row != 0 and draw_reader.getData1f() != False:
      lines = GeomTristrips(Geom.UHStatic)
      half = int(num_vertices * 0.5)
      for i in range(num_vertices):
        lines.addVertex(i + start_row)
        if i < half:
          lines.addVertex(i + start_row - half)
        else:
          lines.addVertex(i + start_row - half - num_vertices)

      lines.addVertex(start_row)
      lines.addVertex(start_row - half)
      lines.closePrimitive()
      lines.decompose()
      circle_geom.addPrimitive(lines)

      circle_geom_node = GeomNode("Debug")
      circle_geom_node.addGeom(circle_geom)

      circle_geom_node.setAttrib(CullFaceAttrib.makeReverse(), 1)

      self.get_model().attachNewNode(circle_geom_node)
开发者ID:KingAbbott,项目名称:devsyn,代码行数:72,代码来源:simple.py

示例15: pandaRender

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import addGeom [as 别名]

#.........这里部分代码省略.........
            )
            vertex = GeomVertexWriter(vertexData, "vertex")
            color = GeomVertexWriter(vertexData, "color")
            texcoord = GeomVertexWriter(vertexData, "texcoord")

            # Add the square's data
            # Upper-Left corner of square
            vertex.addData3f(-loadedFrame.bound.Width / 2.0, 0, -loadedFrame.bound.Height / 2.0)
            color.addData4f(loadedFrame.color.R, loadedFrame.color.G, loadedFrame.color.B, loadedFrame.color.A)
            texcoord.addData2f(loadedFrame.s, loadedFrame.T)

            # Upper-Right corner of square
            vertex.addData3f(loadedFrame.bound.Width / 2.0, 0, -loadedFrame.bound.Height / 2.0)
            color.addData4f(loadedFrame.color.R, loadedFrame.color.G, loadedFrame.color.B, loadedFrame.color.A)
            texcoord.addData2f(loadedFrame.S, loadedFrame.T)

            # Lower-Left corner of square
            vertex.addData3f(-loadedFrame.bound.Width / 2.0, 0, loadedFrame.bound.Height / 2.0)
            color.addData4f(loadedFrame.color.R, loadedFrame.color.G, loadedFrame.color.B, loadedFrame.color.A)
            texcoord.addData2f(loadedFrame.s, loadedFrame.t)

            # Lower-Right corner of square
            vertex.addData3f(loadedFrame.bound.Width / 2.0, 0, loadedFrame.bound.Height / 2.0)
            color.addData4f(loadedFrame.color.R, loadedFrame.color.G, loadedFrame.color.B, loadedFrame.color.A)
            texcoord.addData2f(loadedFrame.S, loadedFrame.t)

            # Pass data to primitive
            squareMadeByTriangleStrips.addNextVertices(4)
            squareMadeByTriangleStrips.closePrimitive()
            square = Geom(vertexData)
            square.addPrimitive(squareMadeByTriangleStrips)
            # Pass primtive to drawing node
            drawPrimitiveNode = GeomNode("square-" + str(frameIndexForName))
            drawPrimitiveNode.addGeom(square)
            # Pass node to scene (effect camera)
            nodePath = self.effectCameraNodePath.attachNewNode(drawPrimitiveNode)
            # Linear dodge:
            if loadedFrame.blendMode == "darken":
                nodePath.setAttrib(
                    ColorBlendAttrib.make(
                        ColorBlendAttrib.MAdd,
                        ColorBlendAttrib.OOneMinusFbufferColor,
                        ColorBlendAttrib.OOneMinusIncomingColor,
                    )
                )
                pass
            elif loadedFrame.blendMode == "multiply":
                nodePath.setAttrib(
                    ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OFbufferColor, ColorBlendAttrib.OZero)
                )
                pass
            elif loadedFrame.blendMode == "color-burn":
                nodePath.setAttrib(
                    ColorBlendAttrib.make(
                        ColorBlendAttrib.MAdd, ColorBlendAttrib.OZero, ColorBlendAttrib.OOneMinusIncomingColor
                    )
                )
                pass
            elif loadedFrame.blendMode == "linear-burn":
                nodePath.setAttrib(
                    ColorBlendAttrib.make(
                        ColorBlendAttrib.MAdd, ColorBlendAttrib.OZero, ColorBlendAttrib.OIncomingColor
                    )
                )
                pass
            elif loadedFrame.blendMode == "lighten":
开发者ID:GitNitneroc,项目名称:tethical,代码行数:70,代码来源:Effect.py


注:本文中的pandac.PandaModules.GeomNode.addGeom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。