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

bge.render.rst « rst « python_api « doc - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 77d5bd717610308c7f04acf4d1354e9c75730d21 (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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364

Rasterizer (bge.render)
=======================

*****
Intro
*****

.. module:: bge.render

Example of using a :class:`bge.types.SCA_MouseSensor`, and two :class:`bge.types.KX_ObjectActuator` to implement MouseLook:

.. note::
   This can also be achieved with the :class:`bge.types.KX_MouseActuator`.

.. code-block:: python

   # To use a mouse movement sensor "Mouse" and a
   # motion actuator to mouse look:
   import bge

   # scale sets the speed of motion
   scale = 1.0, 0.5

   co = bge.logic.getCurrentController()
   obj = co.owner
   mouse = co.sensors["Mouse"]
   lmotion = co.actuators["LMove"]
   wmotion = co.actuators["WMove"]

   # Transform the mouse coordinates to see how far the mouse has moved.
   def mousePos():
      x = (bge.render.getWindowWidth() / 2 - mouse.position[0]) * scale[0]
      y = (bge.render.getWindowHeight() / 2 - mouse.position[1]) * scale[1]
      return (x, y)

   pos = mousePos()

   # Set the amount of motion: X is applied in world coordinates...
   wmotion.useLocalTorque = False
   wmotion.torque = ((0.0, 0.0, pos[0]))

   # ...Y is applied in local coordinates
   lmotion.useLocalTorque = True
   lmotion.torque = ((-pos[1], 0.0, 0.0))

   # Activate both actuators
   co.activate(lmotion)
   co.activate(wmotion)

   # Centre the mouse
   bge.render.setMousePosition(int(bge.render.getWindowWidth() / 2), int(bge.render.getWindowHeight() / 2))

*********
Constants
*********

.. data:: KX_TEXFACE_MATERIAL

   Materials as defined by the texture face settings.

.. data:: KX_BLENDER_MULTITEX_MATERIAL

   Materials approximating blender materials with multitexturing.

.. data:: KX_BLENDER_GLSL_MATERIAL

   Materials approximating blender materials with GLSL.
   
.. DATA:: VSYNC_OFF

   Disables vsync

.. DATA:: VSYNC_ON

   Enables vsync

.. DATA:: VSYNC_ADAPTIVE

   Enables adaptive vsync if supported. Adaptive vsync enables vsync if the framerate is above the monitors refresh rate. Otherwise, vsync is diabled if the framerate is too low.

.. data:: LEFT_EYE

   Left eye being used during stereoscopic rendering.

.. data:: RIGHT_EYE

   Right eye being used during stereoscopic rendering.

*********
Functions
*********

.. function:: getWindowWidth()

   Gets the width of the window (in pixels)
   
   :rtype: integer

.. function:: getWindowHeight()

   Gets the height of the window (in pixels)
   
   :rtype: integer

.. function:: setWindowSize(width, height)

   Set the width and height of the window (in pixels). This also works for fullscreen applications.
   
   :type width: integer
   :type height: integer

.. function:: setFullScreen(enable)

   Set whether or not the window should be fullscreen.
   
   :type enable: bool

.. function:: getFullScreen()

   Returns whether or not the window is fullscreen.
   
   :rtype: bool

.. function:: makeScreenshot(filename)

   Writes a screenshot to the given filename.
   
   If filename starts with // the image will be saved relative to the current directory.
   If the filename contains # it will be replaced with the frame number.
   
   The standalone player saves .png files. It does not support color space conversion 
   or gamma correction.
   
   When run from Blender, makeScreenshot supports all Blender image file formats like PNG, TGA, Jpeg and OpenEXR.
   Gamma, Colorspace conversion and Jpeg compression are taken from the Render settings panels.
   
   :type filename: string


.. function:: enableVisibility(visible)

   Doesn't really do anything...


.. function:: showMouse(visible)

   Enables or disables the operating system mouse cursor.
   
   :type visible: boolean


.. function:: setMousePosition(x, y)

   Sets the mouse cursor position.
   
   :type x: integer
   :type y: integer


.. function:: setBackgroundColor(rgba)

   Sets the window background color.
   
   :type rgba: list [r, g, b, a]


.. function:: setMistColor(rgb)

   Sets the mist color.
   
   :type rgb: list [r, g, b]

   
.. function:: setAmbientColor(rgb)

   Sets the color of ambient light.
   
   :type rgb: list [r, g, b]


.. function:: setMistStart(start)

   Sets the mist start value.  Objects further away than start will have mist applied to them.
   
   :type start: float


.. function:: setMistEnd(end)

   Sets the mist end value.  Objects further away from this will be colored solid with
   the color set by setMistColor().
   
   :type end: float

   
.. function:: disableMist()

   Disables mist.
   
   .. note:: Set any of the mist properties to enable mist.

   
.. function:: setEyeSeparation(eyesep)

   Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.
   
   :arg eyesep: The distance between the left and right eye.
   :type eyesep: float


.. function:: getEyeSeparation()

   Gets the current eye separation for stereo mode.
   
   :rtype: float

   
.. function:: setFocalLength(focallength)

   Sets the focal length for stereo mode. It uses the current camera focal length as initial value.
   
   :arg focallength: The focal length.  
   :type focallength: float

.. function:: getFocalLength()

   Gets the current focal length for stereo mode.
   
   :rtype: float

.. function:: getStereoEye()

   Gets the current stereoscopy eye being rendered.
   This function is mainly used in a :class:`bge.types.KX_Scene.pre_draw` callback
   function to customize the camera projection matrices for each
   stereoscopic eye.

   :rtype: LEFT_EYE, RIGHT_EYE

.. function:: setMaterialMode(mode)

   Set the material mode to use for OpenGL rendering.
   
   :type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL

   .. note:: Changes will only affect newly created scenes.


.. function:: getMaterialMode(mode)

   Get the material mode to use for OpenGL rendering.
   
   :rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL


.. function:: setGLSLMaterialSetting(setting, enable)

   Enables or disables a GLSL material setting.
   
   :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
   :type enable: boolean


.. function:: getGLSLMaterialSetting(setting, enable)

   Get the state of a GLSL material setting.
   
   :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
   :rtype: boolean

.. function:: setAnisotropicFiltering(level)

   Set the anisotropic filtering level for textures.
   
   :arg level: The new anisotropic filtering level to use
   :type level: integer (must be one of 1, 2, 4, 8, 16)
   
   .. note:: Changing this value can cause all textures to be recreated, which can be slow.
   
.. function:: getAnisotropicFiltering()

   Get the anisotropic filtering level used for textures.
   
   :rtype: integer (one of 1, 2, 4, 8, 16)

.. function:: setMipmapping(value)

   Change how to use mipmapping.
   
   :type value: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR
   
   .. note:: Changing this value can cause all textures to be recreated, which can be slow.

.. function:: getMipmapping()

   Get the current mipmapping setting.
   
   :rtype: RAS_MIPMAP_NONE, RAS_MIPMAP_NEAREST, RAS_MIPMAP_LINEAR
   
.. function:: drawLine(fromVec,toVec,color)

   Draw a line in the 3D scene.
   
   :arg fromVec: the origin of the line
   :type fromVec: list [x, y, z]
   :arg toVec: the end of the line
   :type toVec: list [x, y, z]
   :arg color: the color of the line
   :type color: list [r, g, b]


.. function:: enableMotionBlur(factor)

   Enable the motion blur effect.
   
   :arg factor: the ammount of motion blur to display.
   :type factor: float [0.0 - 1.0]


.. function:: disableMotionBlur()

   Disable the motion blur effect.

.. function:: showFramerate(enable)

   Show or hide the framerate.

   :type enable: boolean

.. function:: showProfile(enable)

   Show or hide the profile.

   :type enable: boolean

.. function:: showProperties(enable)

   Show or hide the debug properties.

   :type enable: boolean

.. function:: autoDebugList(enable)

   Enable or disable auto adding debug properties to the debug list.

   :type enable: boolean

.. function:: clearDebugList()

   Clears the debug property list.

.. function:: setVsync(value)

   Set the vsync value

   :arg value: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE
   :type value: integer

.. function:: getVsync()

   Get the current vsync value

   :rtype: One of VSYNC_OFF, VSYNC_ON, VSYNC_ADAPTIVE