2 # Documentation for KX_Scene.py
8 The activity culling stuff is supposed to disable logic bricks when their owner gets too far
9 from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
16 scene = GameLogic.getCurrentScene()
18 # print all the objects in the scene
19 for obj in scene.getObjectList():
22 # get an object named 'Cube'
23 obj = scene.getObjectList()["OBCube"]
25 # get the first object in the scene.
26 obj = scene.getObjectList()[0]
29 # Get the depth of an object in the camera view.
32 obj = GameLogic.getCurrentController().getOwner()
33 cam = GameLogic.getCurrentScene().active_camera
35 # Depth is negative and decreasing further from the camera
36 depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
38 @bug: All attributes are read only at the moment.
40 @ivar name: The scene's name
42 @ivar objects: A list of objects in the scene.
43 @type objects: list [L{KX_GameObject}]
44 @ivar active_camera: The current active camera
45 @type active_camera: L{KX_Camera}
46 @ivar suspended: True if the scene is suspended.
47 @type suspended: boolean
48 @ivar activity_culling: True if the scene is activity culling
49 @type activity_culling: boolean
50 @ivar activity_culling_radius: The distance outside which to do activity culling. Measured in manhattan distance.
51 @type activity_culling_radius: float
56 Returns the list of lights in the scene.
58 @rtype: list [L{KX_Light}]
62 Returns the list of objects in the scene.
64 @rtype: list [L{KX_GameObject}]
68 Returns the name of the scene.
73 def addObject(object, other, time=0):
75 Adds an object to the scene like the Add Object Actuator would, and returns the created object.
77 @param object: The object to add
78 @type object: L{KX_GameObject} or string
79 @param other: The object's center to use when adding the object
80 @type other: L{KX_GameObject} or string
81 @param time: The lifetime of the added object, in frames. A time of 0 means the object will last forever.
84 @rtype: L{KX_GameObject}