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


Python GeomVertexFormat.get_v3n3c4t2方法代码示例

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


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

示例1: create_node

# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import get_v3n3c4t2 [as 别名]
    def create_node(self):
        # Set up the vertex arrays
        vformat = GeomVertexFormat.get_v3n3c4t2()
        vdata = GeomVertexData("Data", vformat, Geom.UHDynamic)
        vertex = GeomVertexWriter(vdata, 'vertex')
        normal = GeomVertexWriter(vdata, 'normal')
        color = GeomVertexWriter(vdata, 'color')
        texcoord = GeomVertexWriter(vdata, 'texcoord')
        geom = Geom(vdata)

        # Write vertex data
        for v in range(0, self.res[1] + 1):
            for u in range(0, self.res[0] + 1):
                # vertex_number = u * (self.res[0] + 1) + v
                t_u, t_v = float(u)/float(self.res[0]), float(v)/float(self.res[1])
                # Vertex positions and normals will be overwritten before the first displaying anyways.
                vertex.addData3f(0, 0, 0)
                normal.addData3f(0, 0, 0)
                # Color is actually not an issue and should probably be kicked out of here.
                color.addData4f(1, 1, 1, 1)
                # Texcoords are constant, so this should be moved into its own array.
                texcoord.addData2f(t_u, t_v)

        # Add triangles
        for u in range(0, self.res[0]):
            for v in range(0, self.res[1]):
                # The vertex arrangement (y up, x right)
                # 2 3
                # 0 1
                u_verts = self.res[0] + 1
                v_0 = u       + v       * u_verts
                v_1 = (u + 1) + v       * u_verts
                v_2 = u       + (v + 1) * u_verts
                v_3 = (u + 1) + (v + 1) * u_verts
                tris = GeomTriangles(Geom.UHDynamic)
                tris.addVertices(v_2, v_0, v_1)
                tris.closePrimitive()
                geom.addPrimitive(tris)
                tris = GeomTriangles(Geom.UHDynamic)
                tris.addVertices(v_1, v_3, v_2)
                tris.closePrimitive()
                geom.addPrimitive(tris)

        # Create the actual node
        sphere = GeomNode('geom_node')
        sphere.addGeom(geom)
        sphere_np = NodePath(sphere)
        tex = base.loader.loadTexture("assets/geosphere/geosphere_day.jpg")
        sphere_np.setTexture(tex)
        self.sphere_np = sphere_np
        self.sphere_vdata = vdata

        # -----
        vformat = GeomVertexFormat.get_v3n3c4()
        vdata = GeomVertexData("Data", vformat, Geom.UHDynamic)
        vertex = GeomVertexWriter(vdata, 'vertex')
        color = GeomVertexWriter(vdata, 'color')
        geom = Geom(vdata)
        
        vertex.addData3f(-1, -1, 0)
        color.addData4f(1, 1, 1, 1)

        vertex.addData3f(1, -1, 0)
        color.addData4f(1, 1, 1, 1)

        tris = GeomLines(Geom.UHDynamic)
        tris.addVertices(0, 1)
        tris.closePrimitive()
        geom.addPrimitive(tris)

        connections = GeomNode('geom_node')
        connections.addGeom(geom)
        connections_np = NodePath(connections)
        connections_np.setRenderModeThickness(3)
        self.connections_np = connections_np
        self.connections_vdata = vdata
        self.connections_geom = geom
        
        self.connections_np.reparent_to(sphere_np)

        return sphere_np
开发者ID:TheCheapestPixels,项目名称:endgame_singularity__hard_reset,代码行数:83,代码来源:geosphere.py


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