本文整理汇总了Python中panda3d.bullet.BulletWorld.getCharacters方法的典型用法代码示例。如果您正苦于以下问题:Python BulletWorld.getCharacters方法的具体用法?Python BulletWorld.getCharacters怎么用?Python BulletWorld.getCharacters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletWorld
的用法示例。
在下文中一共展示了BulletWorld.getCharacters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BulletBase
# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import getCharacters [as 别名]
#.........这里部分代码省略.........
""" Remove Bullet objects to the world."""
if not self.world:
raise BulletBaseError("No BulletWorld initialized.")
# Make sure they're iterable.
if not isinstance(objs, Iterable):
objs = [objs]
elif isinstance(objs, dict):
objs = objs.itervalues()
bw_objs = []
for obj in objs:
if isinstance(obj, NodePath):
obj = obj.node()
if isinstance(obj, self.bw_types):
bw_objs.append(obj)
# Remove them.
for obj in bw_objs:
# Remove the objects from the world.
try:
self.world.remove(obj)
except AttributeError:
DeprecationWarning("Upgrade to Panda3d 1.9.")
for attr in ("removeRigidBody", "removeConstraint",
"removeGhost"):
remove = getattr(self.world, attr)
try:
remove(obj)
except TypeError:
pass
else:
break
def remove_all(self):
""" Remove all objects from world."""
objs = (self.world.getCharacters() + self.world.getConstraints() +
self.world.getGhosts() + self.world.getRigidBodies() +
self.world.getSoftBodies() + self.world.getVehicles())
self.remove(objs)
@property
def gravity(self):
""" Get gravity on self.world. """
return self.world.getGravity()
@gravity.setter
def gravity(self, gravity):
""" Set gravity on self.world. """
self.world.setGravity(Vec3(*gravity))
def step(self, *args, **kwargs):
""" Wrapper for BulletWorld.doPhysics."""
# Defaults.
dt = args[0] if len(args) > 0 else self.sim_par["size"]
n_subs = args[1] if len(args) > 1 else self.sim_par["n_subs"]
size_sub = args[2] if len(args) > 2 else self.sim_par["size_sub"]
force = kwargs.get("force", None)
if force:
bodies, vecpos, dur = force
dt0 = np.clip(dur, 0., dt)
n_subs0 = int(np.ceil(n_subs * dt0 / dt))
dt1 = dt - dt0
n_subs1 = n_subs - n_subs0 + 1
for body in bodies:
body.applyForce(Vec3(*vecpos[0]), Point3(*vecpos[1]))
# With force.
self.world.doPhysics(dt0, n_subs0, size_sub)
for body in bodies: