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


Python BulletRigidBodyNode.removeShape方法代码示例

本文整理汇总了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()
#.........这里部分代码省略.........
开发者ID:tbackus127,项目名称:AbominableSnowmanGame,代码行数:103,代码来源:SMBall.py


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