本文整理汇总了Python中panda3d.core.GeomVertexWriter.addData1i方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexWriter.addData1i方法的具体用法?Python GeomVertexWriter.addData1i怎么用?Python GeomVertexWriter.addData1i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexWriter
的用法示例。
在下文中一共展示了GeomVertexWriter.addData1i方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_nodepath
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData1i [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])
示例2: getNodeFromController
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData1i [as 别名]
def getNodeFromController(controller, controlled_prim):
if type(controlled_prim) is collada.controller.BoundSkinPrimitive:
ch = Character('simplechar')
bundle = ch.getBundle(0)
skeleton = PartGroup(bundle, '<skeleton>')
character_joints = {}
for (name, joint_matrix) in controller.joint_matrices.iteritems():
joint_matrix.shape = (-1)
character_joints[name] = CharacterJoint(ch, bundle, skeleton, name, Mat4(*joint_matrix))
tbtable = TransformBlendTable()
for influence in controller.index:
blend = TransformBlend()
for (joint_index, weight_index) in influence:
char_joint = character_joints[controller.getJoint(joint_index)]
weight = controller.getWeight(weight_index)[0]
blend.addTransform(JointVertexTransform(char_joint), weight)
tbtable.addBlend(blend)
array = GeomVertexArrayFormat()
array.addColumn(InternalName.make('vertex'), 3, Geom.NTFloat32, Geom.CPoint)
array.addColumn(InternalName.make('normal'), 3, Geom.NTFloat32, Geom.CPoint)
array.addColumn(InternalName.make('texcoord'), 2, Geom.NTFloat32, Geom.CTexcoord)
blendarr = GeomVertexArrayFormat()
blendarr.addColumn(InternalName.make('transform_blend'), 1, Geom.NTUint16, Geom.CIndex)
format = GeomVertexFormat()
format.addArray(array)
format.addArray(blendarr)
aspec = GeomVertexAnimationSpec()
aspec.setPanda()
format.setAnimation(aspec)
format = GeomVertexFormat.registerFormat(format)
dataname = controller.id + '-' + controlled_prim.primitive.material.id
vdata = GeomVertexData(dataname, format, Geom.UHStatic)
vertex = GeomVertexWriter(vdata, 'vertex')
normal = GeomVertexWriter(vdata, 'normal')
texcoord = GeomVertexWriter(vdata, 'texcoord')
transform = GeomVertexWriter(vdata, 'transform_blend')
numtris = 0
if type(controlled_prim.primitive) is collada.polylist.BoundPolylist:
for poly in controlled_prim.primitive.polygons():
for tri in poly.triangles():
for tri_pt in range(3):
vertex.addData3f(tri.vertices[tri_pt][0], tri.vertices[tri_pt][1], tri.vertices[tri_pt][2])
normal.addData3f(tri.normals[tri_pt][0], tri.normals[tri_pt][1], tri.normals[tri_pt][2])
if len(controlled_prim.primitive._texcoordset) > 0:
texcoord.addData2f(tri.texcoords[0][tri_pt][0], tri.texcoords[0][tri_pt][1])
transform.addData1i(tri.indices[tri_pt])
numtris+=1
elif type(controlled_prim.primitive) is collada.triangleset.BoundTriangleSet:
for tri in controlled_prim.primitive.triangles():
for tri_pt in range(3):
vertex.addData3f(tri.vertices[tri_pt][0], tri.vertices[tri_pt][1], tri.vertices[tri_pt][2])
normal.addData3f(tri.normals[tri_pt][0], tri.normals[tri_pt][1], tri.normals[tri_pt][2])
if len(controlled_prim.primitive._texcoordset) > 0:
texcoord.addData2f(tri.texcoords[0][tri_pt][0], tri.texcoords[0][tri_pt][1])
transform.addData1i(tri.indices[tri_pt])
numtris+=1
tbtable.setRows(SparseArray.lowerOn(vdata.getNumRows()))
gprim = GeomTriangles(Geom.UHStatic)
for i in range(numtris):
gprim.addVertices(i*3, i*3+1, i*3+2)
gprim.closePrimitive()
pgeom = Geom(vdata)
pgeom.addPrimitive(gprim)
render_state = getStateFromMaterial(controlled_prim.primitive.material)
control_node = GeomNode("ctrlnode")
control_node.addGeom(pgeom, render_state)
ch.addChild(control_node)
bundle = AnimBundle('simplechar', 5.0, 2)
skeleton = AnimGroup(bundle, '<skeleton>')
root = AnimChannelMatrixXfmTable(skeleton, 'root')
#hjoint = AnimChannelMatrixXfmTable(root, 'joint1')
#table = [10, 11, 12, 13, 14, 15, 14, 13, 12, 11]
#data = PTAFloat.emptyArray(len(table))
#for i in range(len(table)):
# data.setElement(i, table[i])
#hjoint.setTable(ord('i'), CPTAFloat(data))
#vjoint = AnimChannelMatrixXfmTable(hjoint, 'joint2')
#table = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9]
#data = PTAFloat.emptyArray(len(table))
#for i in range(len(table)):
# data.setElement(i, table[i])
#vjoint.setTable(ord('j'), CPTAFloat(data))
wiggle = AnimBundleNode('wiggle', bundle)
np = NodePath(ch)
#.........这里部分代码省略.........