本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.getMass方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.getMass方法的具体用法?Python BulletRigidBodyNode.getMass怎么用?Python BulletRigidBodyNode.getMass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletRigidBodyNode
的用法示例。
在下文中一共展示了BulletRigidBodyNode.getMass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DynamicBox
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import getMass [as 别名]
class DynamicBox(DynamicObject):
def __init__(self, name, game, pos):
self.name = name
self.game = game
self.shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))
self.node = BulletRigidBodyNode(name)
self.node.setMass(10.0)
self.node.addShape(self.shape)
self.setFriction(20)
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(pos)
self.game.world.attachRigidBody(self.node)
self.model = self.game.loader.loadModel("models/crate.egg")
self.model.reparentTo(self.np)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
self.debugOff()
self.slice_able = True
def update(self, dt):
#self.activate()
#if self.node.isActive():
# return
contact = self.checkFeet()
contacts = self.getContacts()
if contact in self.game.objects and contact in contacts:
obj = self.game.objects[contact]
if type(obj) is KinematicPlatform:
self.activate()
self.setAngularVelocity(self.getAngularVelocity()*0.9)
self.setFriction(0.1)
#print "%s is a box sliding on %s" % (self.name, obj.name)
#self.addSpeedVec(self.game.objects[contact].getSpeedVec())
#self.setForce(obj.getSpeedVec()*self.node.getMass() * 100)
platform_speed = obj.getSpeedVec()
force = platform_speed * self.node.getMass() * 50
#self.setSpeedXY(platform_speed[0], platform_speed[1])
self.setSpeedVec(platform_speed)
#self.setAngularVelocity(0)
#self.node.addLin(obj.getSpeedVec()*self.node.getMass() * 100)
#self.node.applyCentralForce(force)
#self.setForce(force)
#self.setFriction(20)
#self.setPos(self.getPos() + obj.getSpeedVec())
#self.node.setActive(False)
else:
self.setFriction(20)