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


Python BulletWorld.set_debug_node方法代码示例

本文整理汇总了Python中panda3d.bullet.BulletWorld.set_debug_node方法的典型用法代码示例。如果您正苦于以下问题:Python BulletWorld.set_debug_node方法的具体用法?Python BulletWorld.set_debug_node怎么用?Python BulletWorld.set_debug_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.bullet.BulletWorld的用法示例。


在下文中一共展示了BulletWorld.set_debug_node方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BulletWorld

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
# Physics
bullet_world = BulletWorld()
def run_physics(task):
    bullet_world.do_physics(globalClock.getDt())
    return task.cont
s.task_mgr.add(run_physics, sort=1)


# Debug visualization
debug_node = BulletDebugNode('Debug')
debug_node.showWireframe(True)
debug_node.showConstraints(True)
debug_node.showBoundingBoxes(False)
debug_node.showNormals(False)
debug_np = s.render.attach_new_node(debug_node)
bullet_world.set_debug_node(debug_node)
debug_np.show()


# The object in question
mass = BulletRigidBodyNode()
mass.set_mass(1)
mass.setLinearSleepThreshold(0)
mass.setAngularSleepThreshold(0)
shape = BulletSphereShape(1)
mass.add_shape(shape)
mass_node = s.render.attach_new_node(mass)
mass_node.set_hpr(1, 1, 1)
bullet_world.attach_rigid_body(mass)
model = s.loader.load_model('models/smiley')
model.reparent_to(mass_node)
开发者ID:TheCheapestPixels,项目名称:panda_examples,代码行数:33,代码来源:toy_problem_quat.py

示例2: World

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class World (object):
    """
    The World models basically everything about a map, including gravity, ambient light, the sky, and all map objects.
    """

    def __init__(self, camera, debug=False, audio3d=None, client=None, server=None):
        self.objects = {}

        self.incarnators = []

        self.collidables = set()

        self.updatables = set()
        self.updatables_to_add = set()
        self.garbage = set()
        self.scene = NodePath('world')


        # Set up the physics world. TODO: let maps set gravity.
        self.gravity = DEFAULT_GRAVITY
        self.physics = BulletWorld()
        self.physics.set_gravity(self.gravity)

        self.debug = debug

        if debug:
            debug_node = BulletDebugNode('Debug')
            debug_node.show_wireframe(True)
            debug_node.show_constraints(True)
            debug_node.show_bounding_boxes(False)
            debug_node.show_normals(False)
            np = self.scene.attach_new_node(debug_node)
            np.show()
            self.physics.set_debug_node(debug_node)


    def get_incarn(self):
        return random.choice(self.incarnators)


    def attach(self, obj):
        assert hasattr(obj, 'world') and hasattr(obj, 'name')
        assert obj.name not in self.objects
        obj.world = self
        if obj.name.startswith('Incarnator'):
            self.incarnators.append(obj)
        if hasattr(obj, 'create_node') and hasattr(obj, 'create_solid'):
            # Let each object define it's own NodePath, then reparent them.
            obj.node = obj.create_node()
            obj.solid = obj.create_solid()
            if obj.solid:
                if isinstance(obj.solid, BulletRigidBodyNode):
                    self.physics.attach_rigid_body(obj.solid)
                elif isinstance(obj.solid, BulletGhostNode):
                    self.physics.attach_ghost(obj.solid)
            if obj.node:
                if obj.solid:
                    # If this is a solid visible object, create a new physics node and reparent the visual node to that.
                    phys_node = self.scene.attach_new_node(obj.solid)
                    obj.node.reparent_to(phys_node)
                    obj.node = phys_node
                else:
                    # Otherwise just reparent the visual node to the root.
                    obj.node.reparent_to(self.scene)
            elif obj.solid:
                obj.node = self.scene.attach_new_node(obj.solid)
            if obj.solid and obj.collide_bits is not None:
                obj.solid.set_into_collide_mask(obj.collide_bits)
        self.objects[obj.name] = obj
        # Let the object know it has been attached.
        obj.attached()
        return obj



    def create_hector(self, name=None):
        # TODO: get random incarn, start there
        h = self.attach(Hector(name))
        h.move((0, 15, 0))
        return h

    def register_updater(self, obj):
        assert isinstance(obj, WorldObject)
        self.updatables.add(obj)

    def register_updater_later(self, obj):
        assert isinstance(obj, WorldObject)
        self.updatables_to_add.add(obj)



    def update(self, task):
        """
        Called every frame to update the physics, etc.
        """
        dt = globalClock.getDt()
        for obj in self.updatables_to_add:
            self.updatables.add(obj)
        self.updatables_to_add = set()
        for obj in self.updatables:
#.........这里部分代码省略.........
开发者ID:airvoss,项目名称:pavara,代码行数:103,代码来源:world.py

示例3: __init__

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class PhysicsManager:

    def __init__(self, root_nodepath, world):
        self.world = BulletWorld()
        self.world.setGravity((0, 0, -9.81))

        self._timestep = 1 / world.tick_rate

        # # Seems that this does not function
        # on_contact_added = PythonCallbackObject(self._on_contact_added)
        # self.world.set_contact_added_callback(on_contact_added)
        # on_filter = PythonCallbackObject(self._filter_collision)
        # self.world.set_filter_callback(on_filter)

        self.listener = DirectObject()
        self.listener.accept('bullet-contact-added', self._on_contact_added)
        self.listener.accept('bullet-contact-destroyed', self._on_contact_removed)

        self.tracked_contacts = defaultdict(int)
        self.existing_collisions = set()

        # Debugging info
        debug_node = BulletDebugNode('Debug')
        debug_node.showWireframe(True)
        debug_node.showConstraints(True)
        debug_node.showBoundingBoxes(False)
        debug_node.showNormals(False)

        # Add to world
        self.debug_nodepath = root_nodepath.attachNewNode(debug_node)
        self.world.set_debug_node(debug_node)
        self.debug_nodepath.show()

    def _on_contact_removed(self, node_a, node_b):
        self.tracked_contacts[(node_a, node_b)] -= 1

    def _on_contact_added(self, node_a, node_b):
        self.tracked_contacts[(node_a, node_b)] += 1

    def _dispatch_collisions(self):
        # Dispatch collisions
        existing_collisions = self.existing_collisions

        for pair, contact_count in self.tracked_contacts.items():
            # If is new collision
            if contact_count > 0 and pair not in existing_collisions:
                existing_collisions.add(pair)

                # Dispatch collision
                node_a, node_b = pair

                entity_a = node_a.get_python_tag("entity")
                entity_b = node_b.get_python_tag("entity")

                if not (entity_a and entity_b):
                    continue

                contact_result = ContactResult(self.world, node_a, node_b)
                entity_a.messenger.send("collision_started", entity=entity_b, contacts=contact_result.contacts_a)
                entity_b.messenger.send("collision_started", entity=entity_a, contacts=contact_result.contacts_b)

            # Ended collision
            elif contact_count == 0 and pair in existing_collisions:
                existing_collisions.remove(pair)

                # Dispatch collision
                node_a, node_b = pair

                entity_a = node_a.get_python_tag("entity")
                entity_b = node_b.get_python_tag("entity")

                if not (entity_a and entity_b):
                    continue

                entity_a.messenger.send("collision_stopped", entity_b)
                entity_b.messenger.send("collision_stopped", entity_a)

    def add_entity(self, entity, component):
        body = component.body
        self.world.attach_rigid_body(body)
        body.set_python_tag("entity", entity)

    def remove_entity(self, entity, component):
        body = component.body
        self.world.remove_rigid_body(body)
        body.clear_python_tag("entity")

    def tick(self):
        self.world.do_physics(self._timestep)
        self._dispatch_collisions()

    def resimulate_pawn(self, pawn):
        pass
开发者ID:agoose77,项目名称:PyAuthServer,代码行数:95,代码来源:physics.py

示例4: BlockTutorial

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class BlockTutorial(ShowBase):

    def __init__(self):
        # Step 2: Set up graphics
        ShowBase.__init__(self)
        self.setup_camera()
        self.load_block_model()

        # Step 3: Set up physics
        self.create_physics()
        self.load_block_physics()

        # Step 4: Link graphics and physics
        self.link()

        # This lets us see the debug skeletons for the physics objects.
        self.setup_debug()

        # Setup keybindings
        print
        print "Keybindings"
        print "-----------"

        # Turn on/off the debug skeletons by pressing 'd'
        self.accept('d', self.toggle_debug)
        print "d\t: toggle debug mode"

        # Turn on/off physics simulation by pressing 'space'
        self.accept('space', self.toggle_physics)
        print "space\t: toggle physics"

        # Exit the application by pressing 'esc'
        self.accept('escape', sys.exit)
        print "esc\t: exit"

    def setup_camera(self):
        """Position the camera so we can see the objects in the scene"""

        self.cam.set_pos(-8, -6, 2.75)
        self.cam.look_at((0, 0, 0))

    def load_block_model(self):
        """Load the 3D model of a block, and tell Panda3D to render it"""

        self.block_graphics = self.loader.loadModel("wood_block.egg")
        self.block_graphics.reparent_to(self.render)
        self.block_graphics.set_scale(0.2, 0.2, 0.2)

    def create_physics(self):
        """Create the physical world, and start a task to simulate physics"""

        self.world = BulletWorld()
        self.world.set_gravity((0, 0, -9.81))

        self.physics_on = False
        self.taskMgr.add(self.step_physics, "physics")

    def step_physics(self, task):
        """Get the amount of time that has elapsed, and simulate physics for
        that amount of time"""

        if self.physics_on:
            dt = globalClock.get_dt()
            self.world.do_physics(dt)
        return task.cont

    def toggle_physics(self):
        """Turn physics on or off."""

        self.physics_on = not(self.physics_on)

    def load_block_physics(self):
        """Create collision geometry and a physical body for the block."""

        self.block_body = BulletRigidBodyNode('block-physics')
        self.block_body.add_shape(BulletBoxShape((0.2, 0.6, 0.2)))
        self.block_body.set_mass(1.0)
        self.world.attach_rigid_body(self.block_body)

    def link(self):
        """Tell Panda3D that the block's physics and graphics should be
        linked, by making the physics NodePath be the parent of the
        graphics NodePath.

        """

        self.block_physics = self.render.attach_new_node(self.block_body)
        self.block_graphics.reparent_to(self.block_physics)

    def setup_debug(self):
        """Set up a debug node, which will render skeletons for all the
        physics objects in the physics world."""

        debug_node = BulletDebugNode('Debug')
        debug_node.show_wireframe(True)
        debug_node.show_constraints(True)
        debug_node.show_bounding_boxes(True)
        debug_node.show_normals(True)
        self.world.set_debug_node(debug_node)
        self.debug_np = self.render.attach_new_node(debug_node)
#.........这里部分代码省略.........
开发者ID:clebio,项目名称:pycon-2014-talk,代码行数:103,代码来源:tutorial.py

示例5: World

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class World (object):
    """
    The World models basically everything about a map, including gravity, ambient light, the sky, and all map objects.
    """

    def __init__(self, camera, debug=False, audio3d=None, client=None, server=None):
        self.objects = {}
        self.incarnators = []
        self.collidables = set()
        self.updatables = set()
        self.updatables_to_add = set()
        self.garbage = set()
        self.render = NodePath('world')
        self.camera = camera
        self.audio3d = audio3d
        self.ambient = self._make_ambient()
        self.celestials = CompositeObject()
        self.sky = self.attach(Sky())
        # Set up the physics world. TODO: let maps set gravity.
        self.gravity = DEFAULT_GRAVITY
        self.physics = BulletWorld()
        self.physics.set_gravity(self.gravity)
        self.debug = debug
        self.client = client
        self.server = server
        if debug:
            debug_node = BulletDebugNode('Debug')
            debug_node.show_wireframe(True)
            debug_node.show_constraints(True)
            debug_node.show_bounding_boxes(False)
            debug_node.show_normals(False)
            np = self.render.attach_new_node(debug_node)
            np.show()
            self.physics.set_debug_node(debug_node)

    def _make_ambient(self):
        alight = AmbientLight('ambient')
        alight.set_color(VBase4(*DEFAULT_AMBIENT_COLOR))
        node = self.render.attach_new_node(alight)
        self.render.set_light(node)
        return node

    def attach(self, obj):
        assert hasattr(obj, 'world') and hasattr(obj, 'name')
        assert obj.name not in self.objects
        obj.world = self
        if obj.name.startswith('Incarnator'):
            self.incarnators.append(obj)
        if hasattr(obj, 'create_node') and hasattr(obj, 'create_solid'):
            # Let each object define it's own NodePath, then reparent them.
            obj.node = obj.create_node()
            obj.solid = obj.create_solid()
            if obj.solid:
                if isinstance(obj.solid, BulletRigidBodyNode):
                    self.physics.attach_rigid_body(obj.solid)
                elif isinstance(obj.solid, BulletGhostNode):
                    self.physics.attach_ghost(obj.solid)
            if obj.node:
                if obj.solid:
                    # If this is a solid visible object, create a new physics node and reparent the visual node to that.
                    phys_node = self.render.attach_new_node(obj.solid)
                    obj.node.reparent_to(phys_node)
                    obj.node = phys_node
                else:
                    # Otherwise just reparent the visual node to the root.
                    obj.node.reparent_to(self.render)
            elif obj.solid:
                obj.node = self.render.attach_new_node(obj.solid)
            if obj.solid and obj.collide_bits is not None:
                obj.solid.set_into_collide_mask(obj.collide_bits)
        self.objects[obj.name] = obj
        # Let the object know it has been attached.
        obj.attached()
        return obj

    def get_incarn(self):
        return random.choice(self.incarnators)

    def create_hector(self, name=None):
        # TODO: get random incarn, start there
        h = self.attach(Hector(name))
        h.move((0, 15, 0))
        return h

    def set_ambient(self, color):
        """
        Sets the ambient light to the given color.
        """
        self.ambient.node().set_color(VBase4(*color))

    def add_celestial(self, azimuth, elevation, color, intensity, radius, visible):
        """
        Adds a celestial light source to the scene. If it is a visible celestial, also add a sphere model.
        """
        if not self.camera:
            return
        location = Vec3(to_cartesian(azimuth, elevation, 1000.0 * 255.0 / 256.0))
        if intensity:
            dlight = DirectionalLight('celestial')
            dlight.set_color((color[0] * intensity, color[1] * intensity,
#.........这里部分代码省略.........
开发者ID:jorjuato,项目名称:pavara,代码行数:103,代码来源:world.py

示例6: PandaPhysicsSystem

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class PandaPhysicsSystem(DelegateByNetmode, SignalListener):
    subclasses = {}

    def __init__(self):
        self.register_signals()

        self.world = BulletWorld()
        self.world.setGravity((0, 0, -9.81))

        # # Seems that this does not function
        # on_contact_added = PythonCallbackObject(self._on_contact_added)
        # self.world.set_contact_added_callback(on_contact_added)

        # on_filter = PythonCallbackObject(self._filter_collision)
        # self.world.set_filter_callback(on_filter)

        self.listener = DirectObject()
        self.listener.accept('bullet-contact-added', self._on_contact_added)
        self.listener.accept('bullet-contact-destroyed', self._on_contact_removed)

        debug_node = BulletDebugNode('Debug')
        debug_node.showWireframe(True)
        debug_node.showConstraints(True)
        debug_node.showBoundingBoxes(False)
        debug_node.showNormals(False)

        self.debug_nodepath = render.attachNewNode(debug_node)
        self.world.set_debug_node(debug_node)

        self.tracked_contacts = defaultdict(int)
        self.existing_collisions = set()

    def _create_contacts_from_result(self, requesting_node, contact_result):
        """Return collision contacts between two nodes"""
        contacts = []

        for contact in contact_result.get_contacts():
            if contact.get_node0() == requesting_node:
                manifold = contact.get_manifold_point()

                position = manifold.get_position_world_on_a()
                normal = -manifold.get_normal_world_on_b()

            elif contact.get_node1() == requesting_node:
                manifold = contact.get_manifold_point()

                position = manifold.get_position_world_on_b()
                normal = manifold.get_normal_world_on_b()

            impulse = manifold.get_applied_impulse()
            contact_ = CollisionContact(position, normal, impulse)
            contacts.append(contact_)

        return contacts

    def _on_contact_removed(self, node_a, node_b):
        self.tracked_contacts[(node_a, node_b)] -= 1

    def _on_contact_added(self, node_a, node_b):
        self.tracked_contacts[(node_a, node_b)] += 1

    def _filter_collision(self, filter_data):
        filter_data.set_collide(True)

    @RegisterPhysicsNode.on_global
    def register_node(self, node):
        self.world.attachRigidBody(node)
        node.set_python_tag("world", self.world)

    @DeregisterPhysicsNode.on_global
    def deregister_node(self, node):
        self.world.removeRigidBody(node)
        node.clear_python_tag("world")

    def dispatch_collisions(self):
        # Dispatch collisions
        existing_collisions = self.existing_collisions
        for pair, contact_count in self.tracked_contacts.items():
            if contact_count > 0 and pair not in existing_collisions:
                existing_collisions.add(pair)

                # Dispatch collision
                node_a, node_b = pair

                entity_a = entity_from_nodepath(node_a)
                entity_b = entity_from_nodepath(node_b)

                contact_result = None

                if entity_a is not None:
                    def contact_getter():
                        nonlocal contact_result
                        if contact_result is None:
                            contact_result = self.world.contact_test_pair(node_a, node_b)

                        return self._create_contacts_from_result(node_a, contact_result)

                    collision_result = LazyCollisionResult(entity_b, CollisionState.started, contact_getter)
                    CollisionSignal.invoke(collision_result, target=entity_a)

#.........这里部分代码省略.........
开发者ID:agoose77,项目名称:PyAuthServer,代码行数:103,代码来源:physics.py

示例7: PandaPhysicsSystem

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class PandaPhysicsSystem(DelegateByNetmode, SignalListener):
    subclasses = {}

    def __init__(self):
        self.register_signals()

        self.world = BulletWorld()
        self.world.setGravity((0, 0, -9.81))

        # # Seems that this does not function
        # on_contact_added = PythonCallbackObject(self._on_contact_added)
        # self.world.set_contact_added_callback(on_contact_added)

        # on_filter = PythonCallbackObject(self._filter_collision)
        # self.world.set_filter_callback(on_filter)

        self.listener = DirectObject()
        self.listener.accept('bullet-contact-added', self._on_contact_added)
        self.listener.accept('bullet-contact-destroyed', self._on_contact_removed)

        debug_node = BulletDebugNode('Debug')
        debug_node.showWireframe(True)
        debug_node.showConstraints(True)
        debug_node.showBoundingBoxes(False)
        debug_node.showNormals(False)

        self.debug_nodepath = render.attachNewNode(debug_node)
        self.world.set_debug_node(debug_node)

        self.debug_nodepath.show()

    def _get_contacts(self, node):
        test = self.world.contact_test(node)
        contacts = []

        for contact in test.get_contacts():
            if contact.get_node0() == node:
                manifold = contact.get_manifold_point()

                position = manifold.get_position_world_on_a()
                normal = None

            elif contact.get_node1() == node:
                manifold = contact.get_manifold_point()

                position = manifold.get_position_world_on_b()
                normal = None

            else:
                continue

            impulse = manifold.get_applied_impulse()
            contact_ = CollisionContact(position, normal, impulse)
            contacts.append(contact_)

        return contacts

    def _on_contact_added(self, node_a, node_b):
        if node_a.has_python_tag("on_contact_added"):
            callback = node_a.get_python_tag("on_contact_added")

            contacts = self._get_contacts(node_a)
            callback(node_b, contacts)

        if node_b.has_python_tag("on_contact_added"):
            callback = node_b.get_python_tag("on_contact_added")

            contacts = self._get_contacts(node_b)
            callback(node_a, contacts)

    def _on_contact_removed(self, node_a, node_b):
        if node_a.has_python_tag("on_contact_removed"):
            callback = node_a.get_python_tag("on_contact_removed")
            callback(node_b)

        if node_b.has_python_tag("on_contact_removed"):
            callback = node_b.get_python_tag("on_contact_removed")
            callback(node_a)

    def _filter_collision(self, filter_data):
        filter_data.set_collide(True)

    @RegisterPhysicsNode.on_global
    def register_node(self, node):
        self.world.attachRigidBody(node)
        node.set_python_tag("world", self.world)

    @DeregisterPhysicsNode.on_global
    def deregister_node(self, node):
        self.world.removeRigidBody(node)
        node.clear_python_tag("world")

    def update(self, delta_time):
        self.world.doPhysics(delta_time)
开发者ID:TurBoss,项目名称:PyAuthServer,代码行数:96,代码来源:physics.py

示例8: __init__

# 需要导入模块: from panda3d.bullet import BulletWorld [as 别名]
# 或者: from panda3d.bullet.BulletWorld import set_debug_node [as 别名]
class World:

    def __init__(self, loader=None, camera=None, debug=False):
        self.loader = loader
        self.camera = camera
        self.physics = BulletWorld()
        self.gravity = Vec3(0, 0, -30.0)
        self.physics.set_gravity(self.gravity)
        self.objects = {}
        self.frame = 0
        self.last_object_id = 0
        self.incarnators = []
        self.debug = debug
        self.setup()
        self.commands = []

    def setup(self):
        self.node = NodePath('world')
        self.node.set_transparency(TransparencyAttrib.MAlpha)
        if self.debug:
            d = BulletDebugNode('Debug')
            d.show_wireframe(True)
            d.show_normals(True)
            self.node.attach_new_node(d).show()
            self.physics.set_debug_node(d)
        if self.camera:
            self.camera.node().get_lens().set_fov(80.0, 50.0)
            self.camera.node().get_lens().set_near(0.1)
        # Default ambient light
        alight = AmbientLight('ambient')
        alight.set_color(DEFAULT_AMBIENT_COLOR)
        self.ambient = self.node.attach_new_node(alight)
        self.node.set_light(self.ambient)
        # Default directional lights
        self.add_celestial(math.radians(20), math.radians(45), (1, 1, 1, 1), 0.4, 30.0)
        self.add_celestial(math.radians(200), math.radians(20), (1, 1, 1, 1), 0.3, 30.0)

    def tick(self, dt):
        self.frame += 1
        self.physics.doPhysics(dt, 4, 1.0 / 60.0)
        state = {}
        for obj in list(self.objects.values()):
            if obj.update(self, dt):
                state[obj.world_id] = obj.get_state()
        for cmd, args in self.commands:
            yield cmd, args
        if state:
            yield 'state', {'frame': self.frame, 'state': state}
        self.commands = []

    def attach(self, obj):
        obj.setup(self)
        if obj.world_id is None:
            self.last_object_id += 1
            obj.world_id = self.last_object_id
        self.objects[obj.world_id] = obj
        obj.attached(self)
        if self.frame > 0 and False:
            self.commands.append(('attached', {
                'objects': [obj.serialize()],
                'state': {
                    obj.world_id: obj.get_state(),
                }
            }))
        return obj

    def remove(self, world_id):
        if isinstance(world_id, GameObject):
            world_id = world_id.world_id
        if world_id not in self.objects:
            return
        self.objects[world_id].removed(self)
        del self.objects[world_id]
        if self.frame > 0:
            self.commands.append(('removed', {'world_ids': [world_id]}))

    def find(self, pos, radius):
        for obj in self.objects.values():
            if isinstance(obj, PhysicalObject):
                d = (obj.node.get_pos() - pos).length()
                if d <= radius:
                    yield obj, d

    def add_incarnator(self, pos, heading):
        self.incarnators.append((pos, heading))

    def load_model(self, name):
        """
        Stubbed out here in case we want to allow adding/loading custom models from map XML.
        """
        return self.loader.load_model(name) if self.loader else None

    def serialize(self):
        return {world_id: obj.serialize() for world_id, obj in self.objects.items()}

    def deserialize(self, data):
        self.node.remove_node()
        self.setup()
        for world_id, obj_data in data.items():
            self.attach(GameObject.deserialize(obj_data))
#.........这里部分代码省略.........
开发者ID:dcwatson,项目名称:pavara,代码行数:103,代码来源:world.py


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