本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.apply_impulse方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.apply_impulse方法的具体用法?Python BulletRigidBodyNode.apply_impulse怎么用?Python BulletRigidBodyNode.apply_impulse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletRigidBodyNode
的用法示例。
在下文中一共展示了BulletRigidBodyNode.apply_impulse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: step_physics
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import apply_impulse [as 别名]
def step_physics(task):
dt = globalClock.getDt()
physics.doPhysics(dt)
return task.cont
s.taskMgr.add(step_physics, 'physics simulation')
# A physical object in the simulation
node = BulletRigidBodyNode('Box')
node.setMass(1.0)
node.addShape(BulletSphereShape(1))
# Attaching the physical object in the scene graph and adding
# a visible model to it
np = s.render.attachNewNode(node)
np.set_pos(0, 0, 0)
np.set_hpr(45, 0, 45)
m = loader.loadModel("models/smiley")
m.reparentTo(np)
physics.attachRigidBody(node)
# Let's actually see what's happening
base.cam.setPos(0, -10, 0)
base.cam.lookAt(0, 0, 0)
# Give the object a nudge and run the program
# the impulse vector is in world space, the position at which it is
# applied is in object space.
node.apply_impulse(Vec3(0, 0, 1), Point3(1, 0, 0))
node.apply_impulse(Vec3(0, 0, -1), Point3(-1, 0, 0))
s.run()
示例2: BulletWorld
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import apply_impulse [as 别名]
physics = BulletWorld()
physics.setGravity(Vec3(0, 0, 0))
def step_physics(task):
dt = globalClock.getDt()
physics.doPhysics(dt)
return task.cont
s.taskMgr.add(step_physics, 'physics simulation')
# A physical object in the simulation
node = BulletRigidBodyNode('Box')
node.setMass(1.0)
node.addShape(BulletSphereShape(1))
physics.attachRigidBody(node)
# Attaching the physical object in the scene graph and adding
# a visible model to it
np = s.render.attachNewNode(node)
np.setPos(0, 0, 0)
m = loader.loadModel("models/smiley")
m.reparentTo(np)
# Let's actually see what's happening
base.cam.setPos(0, -10, 0)
base.cam.lookAt(0, 0, 0)
# Give the object a nudge and run the program
node.apply_impulse(Vec3(0,1,0), Point3(0,0,0))
s.run()