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


Python GeomVertexFormat.getV3n3cpt2方法代码示例

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


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

示例1: makeSquare

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
def makeSquare(x1, y1, z1, x2, y2, z2):
    format = GeomVertexFormat.getV3n3cpt2()
    vdata = GeomVertexData('square', format, Geom.UHDynamic)

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

    # make sure we draw the sqaure in the right plane
    if x1 != x2:
        vertex.addData3(x1, y1, z1)
        vertex.addData3(x2, y1, z1)
        vertex.addData3(x2, y2, z2)
        vertex.addData3(x1, y2, z2)

        normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y1 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z2 - 1))
        normal.addData3(normalized(2 * x1 - 1, 2 * y2 - 1, 2 * z2 - 1))

    else:
        vertex.addData3(x1, y1, z1)
        vertex.addData3(x2, y2, z1)
        vertex.addData3(x2, y2, z2)
        vertex.addData3(x1, y1, z2)

        normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z2 - 1))
        normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z2 - 1))

    # adding different colors to the vertex for visibility
    # color.addData4f(1.0, 0.0, 0.0, 1.0)
    # color.addData4f(0.0, 1.0, 0.0, 1.0)
    # color.addData4f(0.0, 0.0, 1.0, 1.0)
    # color.addData4f(1.0, 0.0, 1.0, 1.0)

    texcoord.addData2f(0.0, 1.0)
    texcoord.addData2f(0.0, 0.0)
    texcoord.addData2f(1.0, 0.0)
    texcoord.addData2f(1.0, 1.0)

    # Quads aren't directly supported by the Geom interface
    # you might be interested in the CardMaker class if you are
    # interested in rectangle though
    tris = GeomTriangles(Geom.UHDynamic)
    tris.addVertices(0, 1, 3)
    tris.addVertices(1, 2, 3)

    square = Geom(vdata)
    square.addPrimitive(tris)
    return square
开发者ID:zjusky,项目名称:python-gems,代码行数:55,代码来源:pycraft.py

示例2: createTetraeder

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
    def createTetraeder(self, iterations):
        ''' 
        Note that the first and the last node of the Thetha_Range should be 0 and 180 Degrees 
        because this will be just one time added to verticies
        '''
        #Format
        format = GeomVertexFormat.getV3n3cpt2()
        #VertexData
        vdata = GeomVertexData('name', format, Geom.UHDynamic)


        ##VertexWriter
        vertex      = GeomVertexWriter(vdata, 'vertex')
        normal      = GeomVertexWriter(vdata, 'normal')
        color       = GeomVertexWriter(vdata, 'color')
        texcoord    = GeomVertexWriter(vdata, 'texcoord')
        
        
        vertex.addData3f(0,1.434,-0.507)
        vertex.addData3f(-1.242,-0.717,-0.507)
        vertex.addData3f(1.242,-0.717,-0.507)
        vertex.addData3f(0,0,1.521)
        
        color.addData4f(1,1,1,1)
        color.addData4f(1,1,1,1)
        color.addData4f(1,1,1,1)
        color.addData4f(1,1,1,1)

        normal.addData3f(0,1.434,-0.507)
        normal.addData3f(-1.242,-0.717,-0.507)
        normal.addData3f(1.242,-0.717,-0.507)
        normal.addData3f(0,0,1.521)

        ### Create Geom
        geom = Geom(vdata)
        ### Create Primitives
        prim = GeomTriangles(Geom.UHStatic)
        prim.addVertices(0, 1, 2)
        prim.addVertices(0, 1, 3)
        prim.addVertices(1, 2, 3)
        prim.addVertices(2, 0, 3)
        prim.closePrimitive()

        geom.addPrimitive(prim)
        
        node = GeomNode('gnode')
        node.addGeom(geom)
        
        return node
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:51,代码来源:ObjectGenerator.py

示例3: __init__

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
    def __init__(self):
        formatArray = GeomVertexArrayFormat()
        formatArray.addColumn(
            InternalName.make("drawFlag"), 1, Geom.NTUint8, Geom.COther)

        format = GeomVertexFormat(GeomVertexFormat.getV3n3cpt2())
        format.addArray(formatArray)
        self.format = GeomVertexFormat.registerFormat(format)

        bodydata = GeomVertexData("body vertices", format, Geom.UHStatic)

        self.barkTexture = loader.loadTexture("barkTexture.jpg")
        treeNodePath = NodePath("Tree Holder")
        makeFractalTree(bodydata, treeNodePath, LVector3(4, 4, 7))

        treeNodePath.setTexture(self.barkTexture, 1)
        treeNodePath.reparentTo(render)

        self.accept("q", self.regenTree)
        self.accept("w", self.addTree)
        self.accept("arrow_up", self.upIterations)
        self.accept("arrow_down", self.downIterations)
        self.accept("arrow_right", self.upCopies)
        self.accept("arrow_left", self.downCopies)

        self.numIterations = 11
        self.numCopies = 4

        self.upDownEvent = OnscreenText(
            text="Up/Down: Increase/Decrease the number of iterations (" + str(
                self.numIterations) + ")",
            parent=base.a2dTopLeft, align=TextNode.ALeft,
            style=1, fg=(1, 1, 1, 1), pos=(0.06, -0.22),
            scale=.05, mayChange=True)

        self.leftRightEvent = OnscreenText(
            text="Left/Right: Increase/Decrease branching (" + str(
                self.numCopies) + ")",
            parent=base.a2dTopLeft, align=TextNode.ALeft,
            style=1, fg=(1, 1, 1, 1), pos=(0.06, -0.28),
            scale=.05, mayChange=True)
开发者ID:AdrianF98,项目名称:Toontown-2-Revised,代码行数:43,代码来源:main.py

示例4: makeSquare

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
def makeSquare(face, rhs=True):
    format=GeomVertexFormat.getV3n3cpt2()
    format=GeomVertexFormat.getV3n3t2()
    vdata=GeomVertexData('square', format, Geom.UHStatic)

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

    if not rhs:
        face = list(reversed(face))

    normalvec = (face[1]-face[0]).cross(face[2]-face[0])
    normalvec.normalize()

    f = 0.9 if rhs else 0.8
    f = 1.0
    for ver in face:
        vertex.addData3f(ver*f)
        normal.addData3f(normalvec)
        #color.addData3f((ver+1.0+2.0)*0.25)
        #color.addData3f(ver*0.0+1.0)

    if not normalvec.z:
        texcoord.addData2f(0.0, 0.0)
        texcoord.addData2f(1.0, 0.0)
        texcoord.addData2f(1.0, 1.0)
        texcoord.addData2f(0.0, 1.0)

    
    tri=GeomTriangles(Geom.UHStatic)
    tri.addVertices(0, 1, 2)
    tri.addVertices(2, 3, 0)
    tri.closePrimitive()

    square=Geom(vdata)
    square.addPrimitive(tri)
    return square
开发者ID:btdevel,项目名称:bt,代码行数:41,代码来源:pd.py

示例5: reconstruct

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
	def reconstruct(self):
		trianglator = Triangulator()

		#Add vertices to the trianglator
		for vertex in self.vertices:
			trianglator.addPolygonVertex(trianglator.addVertex(vertex))
		
		trianglator.triangulate()

		#Prepare to create the primative
		self.vdata = GeomVertexData('floor', GeomVertexFormat.getV3n3cpt2(), Geom.UHStatic)
		vertexW = GeomVertexWriter(self.vdata, 'vertex')
		normalW = GeomVertexWriter(self.vdata, 'normal')
		colorW = GeomVertexWriter(self.vdata, 'color')
		texcoordW = GeomVertexWriter(self.vdata, 'texcoord')

		#Add vertices to the primative
		i = 0
		while i < trianglator.getNumVertices():
			vertex = trianglator.getVertex(i)
			vertexW.addData3f(vertex.x,vertex.y,0.0)
			normalW.addData3f(0,0,1)
			colorW.addData4f(0.1,0.1,0.1,0.5)
			texcoordW.addData2f(0.0, 1.0)	
			i+=1

		self.geom = Geom(self.vdata)

		#Add triangles to the primative
		i = 0
		print(trianglator.getNumTriangles())
		while i < trianglator.getNumTriangles():
			tri = GeomTriangles(Geom.UHStatic)
			tri.addVertices(trianglator.getTriangleV0(i),trianglator.getTriangleV1(i),trianglator.getTriangleV2(i))
			tri.closePrimitive()
			self.geom.addPrimitive(tri)
			i+=1

		self.addGeom(self.geom)
开发者ID:aggronerd,项目名称:Crowd-Control,代码行数:41,代码来源:environment.py

示例6: __init__

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
 def __init__(self, name):
     self.name = name
     self.poly_groups = []
     
     # GeomVertexFormats
     #
     # GeomVertexFormat.getV3cpt2()  - vertex, color, uv
     # GeomVertexFormat.getV3t2()    - vertex, uv
     # GeomVertexFormat.getV3cp()    - vertex, color
     # GeomVertexFormat.getV3n3t2()  - vertex, normal, uv
     # GeomVertexFormat.getV3n3cpt2()- vertex, normal, rgba, uv
     
     # textured
     self.vdata = GeomVertexData(name, GeomVertexFormat.getV3n3cpt2(), Geom.UHStatic)
     
     # plain color filled polys
     # self.vdata = GeomVertexData(name, GeomVertexFormat.getV3cp(), Geom.UHStatic)
     
     self.vertex = GeomVertexWriter(self.vdata, 'vertex')
     self.vnormal = GeomVertexWriter(self.vdata, 'normal')
     self.color = GeomVertexWriter(self.vdata, 'color')
     self.texcoord = GeomVertexWriter(self.vdata, 'texcoord')
     
     self.root = NodePath(PandaNode(name+'_mesh'))
开发者ID:aportner,项目名称:panda-zonewalk,代码行数:26,代码来源:mesh.py

示例7: make_square

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
def make_square(sq_color):
    # sq_color is a list of tuples, describing each vertex:
    # (r, g, b, a) for [bl, br, tr, tl]
    x1 = -1
    y1 = -1
    z1 = -1
    x2 = 1
    y2 = -1
    z2 = 1
    v_format = GeomVertexFormat.getV3n3cpt2()
    v_data = GeomVertexData('square', v_format, Geom.UHDynamic)

    vertex = GeomVertexWriter(v_data, 'vertex')
    normal = GeomVertexWriter(v_data, 'normal')
    color = GeomVertexWriter(v_data, 'color')
    tex_coord = GeomVertexWriter(v_data, 'texcoord')

    # make sure we draw the sqaure in the right plane
    if x1 != x2:
        vertex.addData3(x1, y1, z1)
        vertex.addData3(x2, y1, z1)
        vertex.addData3(x2, y2, z2)
        vertex.addData3(x1, y2, z2)

        normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y1 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z2 - 1))
        normal.addData3(normalized(2 * x1 - 1, 2 * y2 - 1, 2 * z2 - 1))

    else:
        vertex.addData3(x1, y1, z1)
        vertex.addData3(x2, y2, z1)
        vertex.addData3(x2, y2, z2)
        vertex.addData3(x1, y1, z2)

        normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z1 - 1))
        normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z2 - 1))
        normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z2 - 1))

    # adding different colors to the vertex for visibility
    # color.addData4f(1.0, 0.0, 0.0, 1.0)
    # color.addData4f(0.0, 1.0, 0.0, 1.0)
    # color.addData4f(0.0, 0.0, 1.0, 1.0)
    # color.addData4f(1.0, 0.0, 1.0, 1.0)
    color.addData4f(sq_color[0])  # (0, 0) bottom left
    color.addData4f(sq_color[1])  # (0.5, 0) bottom right
    color.addData4f(sq_color[2])  # (0.5, 0.5) top right
    color.addData4f(sq_color[3])  # (0, 0.5) top left

    tex_coord.addData2f(0.0, 1.0)
    tex_coord.addData2f(0.0, 0.0)
    tex_coord.addData2f(1.0, 0.0)
    tex_coord.addData2f(1.0, 1.0)

    # Quads aren't directly supported by the Geom interface
    # you might be interested in the CardMaker class if you are
    # interested in rectangle though
    tris = GeomTriangles(Geom.UHDynamic)
    tris.addVertices(0, 1, 3)
    tris.addVertices(1, 2, 3)

    square = Geom(v_data)
    square.addPrimitive(tris)
    return square
开发者ID:codedragon,项目名称:color_world,代码行数:67,代码来源:square.py

示例8: createNewSphere

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
    def createNewSphere(self, radius, height, width, vertexcolour = None, transparency = 1):
        ''' 
        Note that the first and the last node of the Thetha_Range should be 0 and 180 Degrees 
        because this will be just one time added to verticies
        '''
        #Format
        format = GeomVertexFormat.getV3n3cpt2()
        #VertexData
        vdata = GeomVertexData('name', format, Geom.UHStatic)


        ##VertexWriter
        vertex      = GeomVertexWriter(vdata, 'vertex')
        normal      = GeomVertexWriter(vdata, 'normal')
        color       = GeomVertexWriter(vdata, 'color')
        texcoord    = GeomVertexWriter(vdata, 'texcoord')
        
        if (vertexcolour == None):
            vertexcolour = [0.5, 0.5, 0.5]
        
        counter = 0
        ### Create the Skeleton of the Sphere
        for j in range(width):
            for i in range(height):
                if (i == 0):
                    vect = self.sphereToKartesian(radius, 0, 0)
                    vertex.addData3f(vect[0],vect[1],vect[2])
                    normal.addData3f(vect[0],vect[1],vect[2])
                    color.addData4f(vertexcolour[0],vertexcolour[1],vertexcolour[2],transparency)
                    texcoord.addData2f(1-(float(j)/(width)), (float(i)/(height)))                   
                elif (i == height-1):
                    vect = self.sphereToKartesian(radius, 0, 180)
                    vertex.addData3f(vect[0],vect[1],vect[2])
                    normal.addData3f(vect[0],vect[1],vect[2])
                    color.addData4f(vertexcolour[0],vertexcolour[1],vertexcolour[2],transparency)
                    texcoord.addData2f(1-(float(j)/(width)), (float(i)/(height)))
                else:
                    vect = self.sphereToKartesian(radius, (float(j)/(width-2)) * 360, (float(i)/(height)) * 180)
                    vertex.addData3f(vect[0],vect[1],vect[2])
                    normal.addData3f(vect[0],vect[1],vect[2])
                    texcoord.addData2f(1-(float(j)/(width-2)), (float(i)/(height)))
                    color.addData4f(vertexcolour[0],vertexcolour[1],vertexcolour[2],transparency)
                    counter += 1

        ### Create Geom
        geom = Geom(vdata)
        
        
        ### Create Top Trifans
        prim = self.createTrifans(0,range(1,width+1))
       #geom.addPrimitive(prim)
        
        ### Create Belttristrips
        
        for i in range(0,height-2):
            prim = self.createTristrips(width, width*i)

            geom.addPrimitive(prim)
        

        ### Create Bottom Trifans
        lastpoint = width*height-1
        a = [i-1 for i in range(lastpoint,lastpoint-width,-1)]
        prim = self.createTrifans(lastpoint,a)
        #geom.addPrimitive(prim)
 
        geomnode = GeomNode('gnode')
        geomnode.addGeom(geom)
        
        return geomnode
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:72,代码来源:ObjectGenerator.py

示例9: GeomVertexArrayFormat

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
            x = random.randint(sx, ex)
            y = random.randint(sy, ey)
            z = self.world.map3d[x, y]
            if 0 < z < self.config.low_mount_level[1]:
                res[tree].append((x, y, z))

        self[item] = res
        return res


# Shit for fucking trees

formatArray = GeomVertexArrayFormat()
formatArray.addColumn(InternalName.make("drawFlag"), 1, Geom.NTUint8, Geom.COther)

treeform = GeomVertexFormat(GeomVertexFormat.getV3n3cpt2())
treeform.addArray(formatArray)
treeform = GeomVertexFormat.registerFormat(treeform)


# this draws the body of the tree. This draws a ring of vertices and connects the rings with
# triangles to form the body.
# this keepDrawing paramter tells the function wheter or not we're at an end
# if the vertices before you were an end, dont draw branches to it
def draw_body(nodePath, vdata, pos, vecList, radius=1, keepDrawing=True, numVertices=3):

    circleGeom = Geom(vdata)

    vertWriter = GeomVertexWriter(vdata, "vertex")
    colorWriter = GeomVertexWriter(vdata, "color")
    normalWriter = GeomVertexWriter(vdata, "normal")
开发者ID:viatoriche,项目名称:suber,代码行数:33,代码来源:treegen.py

示例10: create_box

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
    def create_box():
        # Format
        format = GeomVertexFormat.getV3n3cpt2()
        # VertexData
        vdata = GeomVertexData("name", format, Geom.UHDynamic)

        ##VertexWriter
        vertex = GeomVertexWriter(vdata, "vertex")
        normal = GeomVertexWriter(vdata, "normal")
        color = GeomVertexWriter(vdata, "color")
        texcoord = GeomVertexWriter(vdata, "texcoord")

        points = [(-1, -1, -1), (-1, 1, -1), (1, -1, -1), (1, 1, -1), (-1, -1, 1), (-1, 1, 1), (1, -1, 1), (1, 1, 1)]

        for p in points:
            vertex.addData3f(*p)

        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)

        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)

        ### Create Geom
        geom = Geom(vdata)
        ### Create Primitives
        prim = GeomTriangles(Geom.UHStatic)
        prim.addVertices(0, 1, 2)
        prim.addVertices(2, 1, 3)

        prim.addVertices(4, 5, 6)
        prim.addVertices(4, 6, 7)

        for i in range(8):
            for k in range(8):
                for t in range(8):
                    prim.addVertices(i, k, t)

        prim.closePrimitive()

        geom.addPrimitive(prim)

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

        xc = sum(x for (x, y, z) in points) / float(len(points))
        yc = sum(y for (x, y, z) in points) / float(len(points))
        zc = sum(z for (x, y, z) in points) / float(len(points))

        return GeomResult(node, (xc, yc, zc), GeomGenerator.volume_for_cube(points))
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:64,代码来源:GeomGenerator.py

示例11: get_foot_geom

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3n3cpt2 [as 别名]
    def get_foot_geom():
        # Format
        format = GeomVertexFormat.getV3n3cpt2()
        # VertexData
        vdata = GeomVertexData("name", format, Geom.UHDynamic)
        ##VertexWriter
        vertex = GeomVertexWriter(vdata, "vertex")
        normal = GeomVertexWriter(vdata, "normal")
        color = GeomVertexWriter(vdata, "color")
        texcoord = GeomVertexWriter(vdata, "texcoord")

        Ax, Ay = (-10, -10)
        Bx, By = (10, -10)
        Cx, Cy = (0, 20)
        z0, z1 = -1, 1

        points = [(Ax, Ay, z0), (Bx, By, z0), (Cx, Cy, z0), (Ax, Ay, z1), (Bx, By, z1), (Cx, Cy, z1)]

        for p in points:
            vertex.addData3f(*p)

        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 1, 1, 1)
        color.addData4f(1, 0, 1, 1)
        color.addData4f(1, 0, 1, 1)
        color.addData4f(1, 0, 1, 1)

        normal.addData3f(0, 0, -1)
        normal.addData3f(0, 0, -1)
        normal.addData3f(0, 0, -1)

        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)
        normal.addData3f(0, 0, 1)

        ### Create Geom
        geom = Geom(vdata)
        ### Create Primitives
        prim = GeomTriangles(Geom.UHStatic)
        for i in range(6):
            for k in range(6):
                for t in range(6):
                    prim.addVertices(i, k, t)
        prim.closePrimitive()

        geom.addPrimitive(prim)

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

        xc = sum(x for (x, y, z) in points) / float(len(points))
        yc = sum(y for (x, y, z) in points) / float(len(points))
        zc = sum(z for (x, y, z) in points) / float(len(points))

        Ax, Ay = points[0][0:2]
        Bx, By = points[1][0:2]
        Cx, Cy = points[2][0:2]

        volume = abs(Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By) / 2)

        return GeomResult(node, (xc, yc, zc), volume)
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:64,代码来源:GeomGenerator.py


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