Module Rasterizer
[hide private]
[frames] | no frames]

Source Code for Module Rasterizer

  1  # $Id: Rasterizer.py 20284 2009-05-20 05:33:39Z dfelinto $ 
  2  """ 
  3  Documentation for the Rasterizer module. 
  4   
  5  Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement MouseLook:: 
  6          # To use a mouse movement sensor "Mouse" and a  
  7          # motion actuator to mouse look: 
  8          import Rasterizer 
  9          import GameLogic 
 10   
 11          # SCALE sets the speed of motion 
 12          SCALE=[1, 0.5] 
 13           
 14          co = GameLogic.getCurrentController() 
 15          obj = co.getOwner() 
 16          mouse = co.getSensor("Mouse") 
 17          lmotion = co.getActuator("LMove") 
 18          wmotion = co.getActuator("WMove") 
 19           
 20          # Transform the mouse coordinates to see how far the mouse has moved. 
 21          def mousePos(): 
 22                  x = (Rasterizer.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0] 
 23                  y = (Rasterizer.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1] 
 24                  return (x, y) 
 25           
 26          pos = mousePos() 
 27           
 28          # Set the amount of motion: X is applied in world coordinates... 
 29          lmotion.setTorque(0.0, 0.0, pos[0], False) 
 30          # ...Y is applied in local coordinates 
 31          wmotion.setTorque(-pos[1], 0.0, 0.0, True) 
 32           
 33          # Activate both actuators 
 34          GameLogic.addActiveActuator(lmotion, True) 
 35          GameLogic.addActiveActuator(wmotion, True) 
 36           
 37          # Centre the mouse 
 38          Rasterizer.setMousePosition(Rasterizer.getWindowWidth()/2, Rasterizer.getWindowHeight()/2) 
 39   
 40  @group Material Types: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL 
 41  @var KX_TEXFACE_MATERIAL: Materials as defined by the texture face settings. 
 42  @var KX_BLENDER_MULTITEX_MATERIAL: Materials approximating blender materials with multitexturing. 
 43  @var KX_BLENDER_GLSL_MATERIAL: Materials approximating blender materials with GLSL. 
 44   
 45  """ 
46 -def getWindowWidth():
47 """ 48 Gets the width of the window (in pixels) 49 50 @rtype: integer 51 """
52 -def getWindowHeight():
53 """ 54 Gets the height of the window (in pixels) 55 56 @rtype: integer 57 """
58 -def makeScreenshot(filename):
59 """ 60 Writes a screenshot to the given filename. 61 62 If filename starts with // the image will be saved relative to the current directory. 63 If the filename contains # it will be replaced with the frame number. 64 65 The standalone player saves .png files. It does not support colour space conversion 66 or gamma correction. 67 68 When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg. 69 Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels. 70 71 @type filename: string 72 """
73
74 -def enableVisibility(visible):
75 """ 76 Doesn't really do anything... 77 """
78
79 -def showMouse(visible):
80 """ 81 Enables or disables the operating system mouse cursor. 82 83 @type visible: boolean 84 """
85
86 -def setMousePosition(x, y):
87 """ 88 Sets the mouse cursor position. 89 90 @type x: integer 91 @type y: integer 92 """
93
94 -def setBackgroundColor(rgba):
95 """ 96 Sets the window background colour. 97 98 @type rgba: list [r, g, b, a] 99 """
100
101 -def setMistColor(rgb):
102 """ 103 Sets the mist colour. 104 105 @type rgb: list [r, g, b] 106 """
107
108 -def setAmbientColor(rgb):
109 """ 110 Sets the color of ambient light. 111 112 @type rgb: list [r, g, b] 113 """
114
115 -def setMistStart(start):
116 """ 117 Sets the mist start value. Objects further away than start will have mist applied to them. 118 119 @type start: float 120 """
121
122 -def setMistEnd(end):
123 """ 124 Sets the mist end value. Objects further away from this will be coloured solid with 125 the colour set by setMistColor(). 126 127 @type end: float 128 """
129
130 -def disableMist():
131 """ 132 Disables mist. 133 134 @note: Set any of the mist properties to enable mist. 135 """
136
137 -def setEyeSeparation(eyesep):
138 """ 139 Sets the eye separation for stereo mode. 140 141 @param eyesep: The distance between the left and right eye. 142 @type eyesep: float 143 """
144
145 -def getEyeSeparation():
146 """ 147 Gets the current eye separation for stereo mode. 148 149 @rtype: float 150 """
151
152 -def setFocalLength(focallength):
153 """ 154 Sets the focal length for stereo mode. 155 156 @param focallength: The focal length. 157 @type focallength: float 158 """
159
160 -def getFocalLength():
161 """ 162 Gets the current focal length for stereo mode. 163 164 @rtype: float 165 """
166
167 -def setMaterialMode(mode):
168 """ 169 Set the material mode to use for OpenGL rendering. 170 171 @type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL 172 @note: Changes will only affect newly created scenes. 173 """
174
175 -def getMaterialMode(mode):
176 """ 177 Get the material mode to use for OpenGL rendering. 178 179 @rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL 180 """
181
182 -def setGLSLMaterialSetting(setting, enable):
183 """ 184 Enables or disables a GLSL material setting. 185 186 @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) 187 @type enable: boolean 188 """
189
190 -def getGLSLMaterialSetting(setting, enable):
191 """ 192 Get the state of a GLSL material setting. 193 194 @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) 195 @rtype: boolean 196 """
197
198 -def drawLine(fromVec,toVec,color):
199 """ 200 Draw a line in the 3D scene. 201 202 @param fromVec: the origin of the line 203 @type fromVec: list [x, y, z] 204 @param toVec: the end of the line 205 @type toVec: list [x, y, z] 206 @param color: the color of the line 207 @type color: list [r, g, b] 208 """
209
210 -def enableMotionBlur(factor):
211 """ 212 Enable the motion blue effect. 213 214 @param factor: the ammount of motion blur to display. 215 @type factor: float [0.0 - 1.0] 216 """
217
218 -def disableMotionBlur():
219 """ 220 Disable the motion blue effect. 221 """
222