Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bge.types.KX_Scene.rst « bge_types « rst « python_api « doc - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5bd8e3a77decdde8f653d1af4981af0479daebb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
KX_Scene(PyObjectPlus)
======================

.. module:: bge.types

base class --- :class:`PyObjectPlus`

.. class:: KX_Scene(PyObjectPlus)

   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!

   .. code-block:: python

      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[0]

   .. code-block:: python

      # 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[0]*cam.world_to_camera[2][0] + object.position[1]*cam.world_to_camera[2][1] + object.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]

   @bug: All attributes are read only at the moment.

   .. attribute:: name

      The scene's name, (read-only).

      :type: string

   .. attribute:: objects

      A list of objects in the scene, (read-only).

      :type: :class:`CListValue` of :class:`KX_GameObject`

   .. attribute:: objectsInactive

      A list of objects on background layers (used for the addObject actuator), (read-only).

      :type: :class:`CListValue` of :class:`KX_GameObject`

   .. attribute:: lights

      A list of lights in the scene, (read-only).

      :type: :class:`CListValue` of :class:`KX_LightObject`

   .. attribute:: cameras

      A list of cameras in the scene, (read-only).

      :type: :class:`CListValue` of :class:`KX_Camera`

   .. attribute:: active_camera

      The current active camera.

      :type: :class:`KX_Camera`
      
      .. note::
         
         This can be set directly from python to avoid using the :class:`KX_SceneActuator`.

   .. attribute:: world

      The current active world, (read-only).

      :type: :class:`KX_WorldInfo`

   .. attribute:: suspended

      True if the scene is suspended, (read-only).

      :type: boolean

   .. attribute:: activity_culling

      True if the scene is activity culling.

      :type: boolean

   .. attribute:: activity_culling_radius

      The distance outside which to do activity culling. Measured in manhattan distance.

      :type: float

   .. attribute:: dbvt_culling

      True when Dynamic Bounding box Volume Tree is set (read-only).

      :type: boolean

   .. attribute:: pre_draw

      A list of callables to be run before the render step.

      :type: list

   .. attribute:: post_draw

      A list of callables to be run after the render step.

      :type: list

   .. attribute:: pre_draw_setup

      A list of callables to be run before the drawing setup (i.e., before the model view and projection matrices are computed).

      :type: list

   .. attribute:: gravity

      The scene gravity using the world x, y and z axis.

      :type: Vector((gx, gy, gz))

   .. method:: addObject(object, reference, time=0)

      Adds an object to the scene like the Add Object Actuator would.

      :arg object: The (name of the) object to add.
      :type object: :class:`KX_GameObject` or string
      :arg reference: 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.
      :type reference: :class:`KX_GameObject` or string
      :arg time: The lifetime of the added object, in frames. A time of 0 means the object will last forever (optional).
      :type time: integer
      :return: The newly added object.
      :rtype: :class:`KX_GameObject`

   .. method:: end()

      Removes the scene from the game.

   .. method:: restart()

      Restarts the scene.

   .. method:: replace(scene)

      Replaces this scene with another one.

      :arg scene: The name of the scene to replace this scene with.
      :type scene: string
      :return: True if the scene exists and was scheduled for addition, False otherwise.
      :rtype: boolean

   .. method:: suspend()

      Suspends this scene.

   .. method:: resume()

      Resume this scene.

   .. method:: get(key, default=None)

      Return the value matching key, or the default value if its not found.
      :return: The key value or a default.

   .. method:: drawObstacleSimulation()

      Draw debug visualization of obstacle simulation.