base class —
An active scene that gives access to objects, cameras, lights and scene attributes.
The activity culling stuff is supposed to disable logic bricks when their owner gets too far from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows what it does!
from bge import logic # get the scene scene = logic.getCurrentScene() # print all the objects in the scene for object in scene.objects: print(object.name) # get an object named 'Cube' object = scene.objects["Cube"] # get the first object in the scene. object = scene.objects
# Get the depth of an object in the camera view. from bge import logic object = logic.getCurrentController().owner cam = logic.getCurrentScene().active_camera # Depth is negative and decreasing further from the camera depth = object.position*cam.world_to_camera + object.position*cam.world_to_camera + object.position*cam.world_to_camera + cam.world_to_camera
@bug: All attributes are read only at the moment.
The scene’s name, (read-only).
A list of objects on background layers (used for the addObject actuator), (read-only).
The current active camera.
This can be set directly from python to avoid using the
The override camera used for scene culling, if set to None the culling is proceeded with the camera used to render.
True if the scene is suspended, (read-only).
True if the scene allow object activity culling.
True when Dynamic Bounding box Volume Tree is set (read-only).
A list of callables to be run before the render step. The callbacks can take as argument the rendered camera.
A list of callables to be run after the render step.
A list of callables to be run before the drawing setup (i.e., before the model view and projection matrices are computed). The callbacks can take as argument the rendered camera, the camera could be temporary in case of stereo rendering.
The scene gravity using the world x, y and z axis.
Type: Vector((gx, gy, gz))
addObject(object, reference, time=0.0)¶
Adds an object to the scene like the Add Object Actuator would.
- object (
KX_GameObjector string) – The (name of the) object to add.
- reference (
KX_GameObjector string) – The (name of the) object which position, orientation, and scale to copy (optional), if the object to add is a light and there is not reference the light’s layer will be the same that the active layer in the blender scene.
- time (float) – The lifetime of the added object, in frames (assumes one frame is 1/50 second). A time of 0.0 means the object will last forever (optional).
The newly added object.
- object (
Removes the scene from the game.
Restarts the scene.
Replaces this scene with another one.
Parameters: scene (string) – The name of the scene to replace this scene with. Returns: True if the scene exists and was scheduled for addition, False otherwise. Return type: boolean
Suspends this scene.
Resume this scene.
Return the value matching key, or the default value if its not found. :return: The key value or a default.
Draw debug visualization of obstacle simulation.