2 Game Engine bge.render Module
3 =============================
11 .. code-block:: python
13 # Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement MouseLook::
14 # To use a mouse movement sensor "Mouse" and a
15 # motion actuator to mouse look:
19 # SCALE sets the speed of motion
22 co = bge.logic.getCurrentController()
24 mouse = co.getSensor("Mouse")
25 lmotion = co.getActuator("LMove")
26 wmotion = co.getActuator("WMove")
28 # Transform the mouse coordinates to see how far the mouse has moved.
30 x = (bge.render.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0]
31 y = (bge.render.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1]
36 # Set the amount of motion: X is applied in world coordinates...
37 lmotion.setTorque(0.0, 0.0, pos[0], False)
38 # ...Y is applied in local coordinates
39 wmotion.setTorque(-pos[1], 0.0, 0.0, True)
41 # Activate both actuators
42 bge.logic.addActiveActuator(lmotion, True)
43 bge.logic.addActiveActuator(wmotion, True)
46 bge.render.setMousePosition(bge.render.getWindowWidth()/2, bge.render.getWindowHeight()/2)
52 .. data:: KX_TEXFACE_MATERIAL
54 Materials as defined by the texture face settings.
56 .. data:: KX_BLENDER_MULTITEX_MATERIAL
58 Materials approximating blender materials with multitexturing.
60 .. data:: KX_BLENDER_GLSL_MATERIAL
62 Materials approximating blender materials with GLSL.
68 .. function:: getWindowWidth()
70 Gets the width of the window (in pixels)
74 .. function:: getWindowHeight()
76 Gets the height of the window (in pixels)
80 .. function:: makeScreenshot(filename)
82 Writes a screenshot to the given filename.
84 If filename starts with // the image will be saved relative to the current directory.
85 If the filename contains # it will be replaced with the frame number.
87 The standalone player saves .png files. It does not support colour space conversion
90 When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg.
91 Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels.
93 :type filename: string
96 .. function:: enableVisibility(visible)
98 Doesn't really do anything...
101 .. function:: showMouse(visible)
103 Enables or disables the operating system mouse cursor.
105 :type visible: boolean
108 .. function:: setMousePosition(x, y)
110 Sets the mouse cursor position.
116 .. function:: setBackgroundColor(rgba)
118 Sets the window background colour.
120 :type rgba: list [r, g, b, a]
123 .. function:: setMistColor(rgb)
125 Sets the mist colour.
127 :type rgb: list [r, g, b]
130 .. function:: setAmbientColor(rgb)
132 Sets the color of ambient light.
134 :type rgb: list [r, g, b]
137 .. function:: setMistStart(start)
139 Sets the mist start value. Objects further away than start will have mist applied to them.
144 .. function:: setMistEnd(end)
146 Sets the mist end value. Objects further away from this will be coloured solid with
147 the colour set by setMistColor().
152 .. function:: disableMist()
156 .. note:: Set any of the mist properties to enable mist.
159 .. function:: setEyeSeparation(eyesep)
161 Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.
163 :arg eyesep: The distance between the left and right eye.
167 .. function:: getEyeSeparation()
169 Gets the current eye separation for stereo mode.
174 .. function:: setFocalLength(focallength)
176 Sets the focal length for stereo mode. It uses the current camera focal length as initial value.
178 :arg focallength: The focal length.
179 :type focallength: float
181 .. function:: getFocalLength()
183 Gets the current focal length for stereo mode.
187 .. function:: setMaterialMode(mode)
189 Set the material mode to use for OpenGL rendering.
191 :type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
193 .. note:: Changes will only affect newly created scenes.
196 .. function:: getMaterialMode(mode)
198 Get the material mode to use for OpenGL rendering.
200 :rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
203 .. function:: setGLSLMaterialSetting(setting, enable)
205 Enables or disables a GLSL material setting.
207 :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
208 :type enable: boolean
211 .. function:: getGLSLMaterialSetting(setting, enable)
213 Get the state of a GLSL material setting.
215 :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
219 .. function:: drawLine(fromVec,toVec,color)
221 Draw a line in the 3D scene.
223 :arg fromVec: the origin of the line
224 :type fromVec: list [x, y, z]
225 :arg toVec: the end of the line
226 :type toVec: list [x, y, z]
227 :arg color: the color of the line
228 :type color: list [r, g, b]
231 .. function:: enableMotionBlur(factor)
233 Enable the motion blue effect.
235 :arg factor: the ammount of motion blur to display.
236 :type factor: float [0.0 - 1.0]
239 .. function:: disableMotionBlur()
241 Disable the motion blue effect.