本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.removeShape方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.removeShape方法的具体用法?Python BulletRigidBodyNode.removeShape怎么用?Python BulletRigidBodyNode.removeShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletRigidBodyNode
的用法示例。
在下文中一共展示了BulletRigidBodyNode.removeShape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SMBall
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import removeShape [as 别名]
class SMBall():
def __init__(self, bWrld, wObj, pObj, playerNP):
self.playerObj = pObj
self.player = playerNP
self.worldBullet = bWrld
self.worldObj = wObj
self.rolledOnce = False
self.rollState = False
self.ballExists = False
self.ballModel = loader.loadModel("../res/models/sphere.egg.pz")
self.ballModel.setScale(INIT_SCALE, INIT_SCALE, INIT_SCALE)
self.ballNP = NodePath()
self.ballRBody = NodePath()
print("Snowball initialized.")
def setRolling(self, roll):
self.rollState = roll
def isRolling(self):
return self.rollState
def getSnowAmount(self):
result = 0
size = self.ballModel.getScale().getX()
if(self.rollState and size > 2.0):
size = floor(size)
result += (size * size)
return result
def exists(self):
return self.ballExists
def getRigidbody(self):
return self.ballRBody
def getNodePath(self):
return self.ballNP
def destroy(self):
self.ballNP.removeNode()
self.ballNP = None
self.ballModel.detachNode()
self.ballNP = NodePath()
self.ballExists = False
self.rollState = False
def respawn(self):
# Drop the ball
if(self.isRolling()):
self.setRolling(False)
self.dropBall()
# Make the ball
else:
if(self.rolledOnce):
self.ballRBody.removeShape(self.ballShape)
self.ballModel.detachNode()
pos = self.playerObj.getPosition()
x = pos.getX()
y = pos.getY()
z = pos.getZ()
self.ballModel.setScale(INIT_SCALE, INIT_SCALE, INIT_SCALE)
self.ballNP = self.playerObj.getNodePath().attachNewNode(self.ballModel.node())
self.ballNP.setPos(0, 4, -5) # In front and and bit below the yeti.
self.setRolling(True)
self.ballExists = False
def dropBall(self):
self.ballNP.removeNode()
pos = self.playerObj.getPosition()
pNP = self.playerObj.getNodePath()
px = pos.getX()
py = pos.getY()
pz = pos.getZ()
size = self.ballModel.getScale().getX()
self.ballShape = BulletCylinderShape(size, size * 1.7, ZUp)
self.ballRBody = BulletRigidBodyNode()
self.ballRBody.setMass(0)
self.ballRBody.addShape(self.ballShape)
rbNP = self.worldObj.attachNewNode(self.ballRBody)
ph = self.playerObj.getRotation()
self.ballModel.setPos(0, 0, 0)
dx = -sin(ph * DEG_TO_RAD) * size * 3
dy = cos(ph * DEG_TO_RAD) * size * 3
self.ballModel.reparentTo(rbNP)
rbNP.setPos(px + dx, py + dy, pz)
self.worldBullet.attachRigidBody(self.ballRBody)
self.setRolling(False)
self.rolledOnce = True
self.ballExists = True
print(self.rolledOnce)
def grow(self):
size = self.ballModel.getScale()
sx = size.getX()
if(sx < MAX_SCALE):
pos = self.ballModel.getPos()
#.........这里部分代码省略.........