本文整理汇总了Python中panda3d.core.Geom.getVertexData方法的典型用法代码示例。如果您正苦于以下问题:Python Geom.getVertexData方法的具体用法?Python Geom.getVertexData怎么用?Python Geom.getVertexData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.Geom
的用法示例。
在下文中一共展示了Geom.getVertexData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addTriMeshSB
# 需要导入模块: from panda3d.core import Geom [as 别名]
# 或者: from panda3d.core.Geom import getVertexData [as 别名]
def addTriMeshSB(self,vertices, faces,normals = None,ghost=False,**kw):
#step 1) create GeomVertexData and add vertex information
# Soft body world information
info = self.world.getWorldInfo()
info.setAirDensity(0.0)
info.setWaterDensity(0)
info.setWaterOffset(0)
info.setWaterNormal(Vec3(0, 0, 0))
format=GeomVertexFormat.getV3n3() #getV3()#http://www.panda3d.org/manual/index.php/Pre-defined_vertex_formats
# vdata = GeomVertexData('name', format, Geom.UHStatic)
vdata=GeomVertexData("Mesh", format, Geom.UHStatic)
vertexWriter=GeomVertexWriter(vdata, "vertex")
[vertexWriter.addData3f(v[0],v[1],v[2]) for v in vertices]
if normals is not None :
normalWriter = GeomVertexWriter(vdata, 'normal')
[normalWriter.addData3f(n[0],n[1],n[2]) for n in normals]
else :
print "we need normals to bind geom to SoftBody"
return None
#step 2) make primitives and assign vertices to them
tris=GeomTriangles(Geom.UHStatic)
[self.setGeomFaces(tris,face) for face in faces]
#step 3) make a Geom object to hold the primitives
geom=Geom(vdata)
geom.addPrimitive(tris)
vdata = geom.getVertexData()
# print (vdata,vdata.hasColumn(InternalName.getVertex()))
geomNode = GeomNode('')
geomNode.addGeom(geom)
#step 4) create the bullet softbody and node
bodyNode = BulletSoftBodyNode.makeTriMesh(info, geom)
# bodyNode.linkGeom(geomNode.modifyGeom(0))
bodyNode.setName('Tri')
bodyNode.linkGeom(geom)
bodyNode.generateBendingConstraints(1)#???
#bodyNode.getMaterial(0).setLinearStiffness(0.8)
bodyNode.getCfg().setPositionsSolverIterations(4)
# bodyNode.getCfg().setCollisionFlag(BulletSoftBodyConfig.CFVertexFaceSoftSoft, True)
bodyNode.getCfg().setDynamicFrictionCoefficient(1)
bodyNode.getCfg().setDampingCoefficient(0.001)
bodyNode.getCfg().setPressureCoefficient(15000*10.0)
bodyNode.getCfg().setPoseMatchingCoefficient(0.2)
bodyNode.setPose(True, True)
# bodyNode.randomizeConstraints()
bodyNode.setTotalMass(50000*10, True)
bodyNP = self.worldNP.attachNewNode(bodyNode)
# fmt = GeomVertexFormat.getV3n3t2()
# geom = BulletHelper.makeGeomFromFaces(bodyNode, fmt,True)
# bodyNode.linkGeom(geomNode.modifyGeom(0))
# geomNode = GeomNode('')
# geomNode.addGeom(geom)
# world.attachSoftBody(bodyNode)
# inodenp.setPos(0, 0, 0.1)
# self.setRB(bodyNP,**kw)#set po
# inodenp.setCollideMask(BitMask32.allOn())
self.world.attachSoftBody(bodyNode)
geomNP = bodyNP.attachNewNode(geomNode)
return bodyNP,geomNP