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


Python GeomVertexWriter.setData1i方法代码示例

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


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

示例1: registerObject

# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import setData1i [as 别名]
    def registerObject(self, obj):
        """ Registers a new dynamic object, this will store an index for every
        vertex, which can be used to read and store last position data in order
        to compute the velocity. This method also assigns the standard animated
        shader to the node """

        self.debug("Registering dynamic object")

        # Find all GeomNodes
        for node in obj.findAllMatches("**/+GeomNode"):
            geomNode = node.node()
            geomCount = geomNode.getNumGeoms()

            # Find all Geoms
            for i in xrange(geomCount):

                # Modify vertex data
                geom = geomNode.modifyGeom(i)
                geomVertexData = geom.modifyVertexData()

                # Add a new column named "dovindex" to the vertex data
                formatArray = GeomVertexArrayFormat() 
                formatArray.addColumn(InternalName.make("dovindex"), 1, GeomEnums.NTUint32, GeomEnums.CIndex) 
                newArrayFormat = GeomVertexFormat(geomVertexData.getFormat())
                newArrayFormat.addArray(formatArray)
                newArrayFormat = GeomVertexFormat.registerFormat(newArrayFormat)

                # Convert the old vertex data and assign the new vertex data
                convertedVertexData = geomVertexData.convertTo(newArrayFormat)
                geom.setVertexData(convertedVertexData)

                # Write the per-vertex indices the dovindex column 
                newVertexData = geom.modifyVertexData()
                vtxReader = GeomVertexReader(newVertexData, "vertex")
                indexWriter = GeomVertexWriter(newVertexData, "dovindex")

                while not vtxReader.isAtEnd():
                    data = vtxReader.getData3f()
                    indexWriter.setData1i(self.currentIndex)
                    self.currentIndex += 1

                if self.currentIndex > self.maxVertexCount:
                    self.error("Max dynamic vertex count of", self.maxVertexCount, "reached!")
开发者ID:rimij405,项目名称:RenderPipeline,代码行数:45,代码来源:DynamicObjectsManager.py

示例2: update_nodepath

# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import setData1i [as 别名]
def update_nodepath(pandaNode, refinements):
    geom = pandaNode.modifyGeom(0)
    
    vertdata = geom.modifyVertexData()
    prim = geom.modifyPrimitive(0)
    indexdata = prim.modifyVertices()
    
    indexwriter = GeomVertexWriter(indexdata)
    indexwriter.setColumn(0)
    nextTriangleIndex = indexdata.getNumRows()
    
    vertwriter = GeomVertexWriter(vertdata, 'vertex')
    numverts = vertdata.getNumRows()
    vertwriter.setRow(numverts)
    normalwriter = GeomVertexWriter(vertdata, 'normal')
    normalwriter.setRow(numverts)
    uvwriter = GeomVertexWriter(vertdata, 'texcoord')
    uvwriter.setRow(numverts)
    
    for refinement in refinements:
        for op_index in range(len(refinement)):
            vals = refinement[op_index]
            op = vals[0]
            if op == PM_OP.TRIANGLE_ADDITION:
                indexwriter.setRow(nextTriangleIndex)
                nextTriangleIndex += 3
                indexwriter.addData1i(vals[1])
                indexwriter.addData1i(vals[2])
                indexwriter.addData1i(vals[3])
            elif op == PM_OP.INDEX_UPDATE:
                indexwriter.setRow(vals[1])
                indexwriter.setData1i(vals[2])
            elif op == PM_OP.VERTEX_ADDITION:
                numverts += 1
                vertwriter.addData3f(vals[1], vals[2], vals[3])
                normalwriter.addData3f(vals[4], vals[5], vals[6])
                uvwriter.addData2f(vals[7], vals[8])
开发者ID:jterrace,项目名称:open3dhub-panda3d-tests,代码行数:39,代码来源:python_impl.py


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