2 Game Engine bge.render Module
3 =============================
9 # Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement MouseLook::
10 # To use a mouse movement sensor "Mouse" and a
11 # motion actuator to mouse look:
15 # SCALE sets the speed of motion
18 co = bge.logic.getCurrentController()
20 mouse = co.getSensor("Mouse")
21 lmotion = co.getActuator("LMove")
22 wmotion = co.getActuator("WMove")
24 # Transform the mouse coordinates to see how far the mouse has moved.
26 x = (bge.render.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0]
27 y = (bge.render.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1]
32 # Set the amount of motion: X is applied in world coordinates...
33 lmotion.setTorque(0.0, 0.0, pos[0], False)
34 # ...Y is applied in local coordinates
35 wmotion.setTorque(-pos[1], 0.0, 0.0, True)
37 # Activate both actuators
38 bge.logic.addActiveActuator(lmotion, True)
39 bge.logic.addActiveActuator(wmotion, True)
42 bge.render.setMousePosition(bge.render.getWindowWidth()/2, bge.render.getWindowHeight()/2)
45 .. data:: KX_TEXFACE_MATERIAL
47 Materials as defined by the texture face settings.
49 .. data:: KX_BLENDER_MULTITEX_MATERIAL
51 Materials approximating blender materials with multitexturing.
53 .. data:: KX_BLENDER_GLSL_MATERIAL
55 Materials approximating blender materials with GLSL.
57 .. function:: getWindowWidth()
59 Gets the width of the window (in pixels)
63 .. function:: getWindowHeight()
65 Gets the height of the window (in pixels)
69 .. function:: makeScreenshot(filename)
71 Writes a screenshot to the given filename.
73 If filename starts with // the image will be saved relative to the current directory.
74 If the filename contains # it will be replaced with the frame number.
76 The standalone player saves .png files. It does not support colour space conversion
79 When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg.
80 Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels.
82 :type filename: string
85 .. function:: enableVisibility(visible)
87 Doesn't really do anything...
90 .. function:: showMouse(visible)
92 Enables or disables the operating system mouse cursor.
94 :type visible: boolean
97 .. function:: setMousePosition(x, y)
99 Sets the mouse cursor position.
105 .. function:: setBackgroundColor(rgba)
107 Sets the window background colour.
109 :type rgba: list [r, g, b, a]
112 .. function:: setMistColor(rgb)
114 Sets the mist colour.
116 :type rgb: list [r, g, b]
119 .. function:: setAmbientColor(rgb)
121 Sets the color of ambient light.
123 :type rgb: list [r, g, b]
126 .. function:: setMistStart(start)
128 Sets the mist start value. Objects further away than start will have mist applied to them.
133 .. function:: setMistEnd(end)
135 Sets the mist end value. Objects further away from this will be coloured solid with
136 the colour set by setMistColor().
141 .. function:: disableMist()
145 .. note:: Set any of the mist properties to enable mist.
148 .. function:: setEyeSeparation(eyesep)
150 Sets the eye separation for stereo mode. Usually Focal Length/30 provides a confortable value.
152 :arg eyesep: The distance between the left and right eye.
156 .. function:: getEyeSeparation()
158 Gets the current eye separation for stereo mode.
163 .. function:: setFocalLength(focallength)
165 Sets the focal length for stereo mode. It uses the current camera focal length as initial value.
167 :arg focallength: The focal length.
168 :type focallength: float
170 .. function:: getFocalLength()
172 Gets the current focal length for stereo mode.
176 .. function:: setMaterialMode(mode)
178 Set the material mode to use for OpenGL rendering.
180 :type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
182 .. note:: Changes will only affect newly created scenes.
185 .. function:: getMaterialMode(mode)
187 Get the material mode to use for OpenGL rendering.
189 :rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
192 .. function:: setGLSLMaterialSetting(setting, enable)
194 Enables or disables a GLSL material setting.
196 :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
197 :type enable: boolean
200 .. function:: getGLSLMaterialSetting(setting, enable)
202 Get the state of a GLSL material setting.
204 :type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
208 .. function:: drawLine(fromVec,toVec,color)
210 Draw a line in the 3D scene.
212 :arg fromVec: the origin of the line
213 :type fromVec: list [x, y, z]
214 :arg toVec: the end of the line
215 :type toVec: list [x, y, z]
216 :arg color: the color of the line
217 :type color: list [r, g, b]
220 .. function:: enableMotionBlur(factor)
222 Enable the motion blue effect.
224 :arg factor: the ammount of motion blur to display.
225 :type factor: float [0.0 - 1.0]
228 .. function:: disableMotionBlur()
230 Disable the motion blue effect.