本文整理汇总了Python中panda3d.bullet.BulletWorld.sweepTestClosest方法的典型用法代码示例。如果您正苦于以下问题:Python BulletWorld.sweepTestClosest方法的具体用法?Python BulletWorld.sweepTestClosest怎么用?Python BulletWorld.sweepTestClosest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletWorld
的用法示例。
在下文中一共展示了BulletWorld.sweepTestClosest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import sweepTestClosest [as 别名]
#.........这里部分代码省略.........
ts = node.getTransform()
m = ts.getMat().getUpper3()
p = ts.getMat().getRow3(3)
points=[]
geom = geomNode.getGeoms()[0]
vdata = geom.getVertexData()
reader = GeomVertexReader(vdata, 'vertex')
while not reader.isAtEnd():
v = reader.getData3f()
v = m.xform(v) + p
points.append(Point3(v))
return numpy.array(points,dtype=numpy.float32)
def pandaMatrice(self,mat):
mat = mat.transpose().reshape((16,))
# print mat,len(mat),mat.shape
pMat = Mat4(mat[0],mat[1],mat[2],mat[3],
mat[4],mat[5],mat[6],mat[7],
mat[8],mat[9],mat[10],mat[11],
mat[12],mat[13],mat[14],mat[15],)
return pMat
#
# def addRB(self,rtype,static,**kw):
# # Sphere
# if panda3d is None :
# return None
# if rotMatis not None and trans is not None:
# mat = rotMat.copy()
# mat = mat.transpose().reshape((16,))
#
# pMat = TransformState.makeMat(Mat4(mat[0],mat[1],mat[2],mat[3],
# mat[4],mat[5],mat[6],mat[7],
# mat[8],mat[9],mat[10],mat[11],
# trans[0],trans[1],trans[2],mat[15],))
# shape = None
# inodenp = None
## print (pMat)
# inodenp = self.rb_func_dic[rtype](ingr,pMat,trans,rotMat)
# inodenp.setCollideMask(BitMask32.allOn())
# self.world.attachRigidBody(inodenp.node())
# if static :
# self.static.append(inodenp.node())
# else :
# self.moving = inodenp.node()
# self.rb_panda.append(inodenp.node())
# return inodenp.node()
def moveRBnode(self,node, trans, rotMat):
mat = rotMat.copy()
# mat[:3, 3] = trans
# mat = mat.transpose()
mat = mat.transpose().reshape((16,))
# print mat,len(mat),mat.shape
pMat = Mat4(mat[0],mat[1],mat[2],mat[3],
mat[4],mat[5],mat[6],mat[7],
mat[8],mat[9],mat[10],mat[11],
trans[0],trans[1],trans[2],mat[15],)
pTrans = TransformState.makeMat(pMat)
nodenp = NodePath(node)
nodenp.setMat(pMat)
# nodenp.setPos(trans[0],trans[1],trans[2])
# print nodenp.getPos()
def applyForce(self,node,F):
F*=self.scale
node.node().applyCentralForce(Vec3(F[0],F[1],F[2]))
# node.node().applyForce(Vec3(F[0],F[1],F[2]),Point3(0, 0, 0))
# print F
def rayCast(self, startp,endp,closest=False):
start=Point3(startp[0],startp[1],startp[2])
end=Point3(endp[0],endp[1],endp[2])
if closest :
res = self.world.rayTestClosest(start, end)
else :
res = self.world.rayTestAll(start, end)
return res
def sweepRay(self, startp,endp):
tsFrom = TransformState.makePos(Point3(0, 0, 0))
tsTo = TransformState.makePos(Point3(10, 0, 0))
shape = BulletSphereShape(0.5)
penetration = 0.0
result = self.world.sweepTestClosest(shape, tsFrom, tsTo, penetration)
return result
def update(self,task,cb=None):
# print "update"
dt = globalClock.getDt()
# print dt
self.world.doPhysics(dt, 10, 0.008)#,100,1.0/500.0)#world.doPhysics(dt, 10, 1.0/180.0)
#this may be different for relaxing ?
# print task.time
if cb is not None :
cb()
if task is not None:
return task.cont