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

Source Code for Module Rasterizer

  1  # $Id: Rasterizer.py 17083 2008-10-14 22:31:10Z campbellbarton $ 
  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   
47 -def getWindowWidth():
48 """ 49 Gets the width of the window (in pixels) 50 51 @rtype: integer 52 """
53 -def getWindowHeight():
54 """ 55 Gets the height of the window (in pixels) 56 57 @rtype: integer 58 """
59 -def makeScreenshot(filename):
60 """ 61 Writes a screenshot to the given filename. 62 63 If filename starts with // the image will be saved relative to the current directory. 64 If the filename contains # it will be replaced with the frame number. 65 66 The standalone player saves .png files. It does not support colour space conversion 67 or gamma correction. 68 69 When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg. 70 Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels. 71 72 @type filename: string 73 """
74
75 -def enableVisibility(visible):
76 """ 77 Doesn't really do anything... 78 """
79
80 -def showMouse(visible):
81 """ 82 Enables or disables the operating system mouse cursor. 83 84 @type visible: boolean 85 """
86
87 -def setMousePosition(x, y):
88 """ 89 Sets the mouse cursor position. 90 91 @type x: integer 92 @type y: integer 93 """
94
95 -def setBackgroundColor(rgba):
96 """ 97 Sets the window background colour. 98 99 @type rgba: list [r, g, b, a] 100 """
101
102 -def setMistColor(rgb):
103 """ 104 Sets the mist colour. 105 106 @type rgb: list [r, g, b] 107 """
108
109 -def setMistStart(start):
110 """ 111 Sets the mist start value. Objects further away than start will have mist applied to them. 112 113 @type start: float 114 """
115
116 -def setMistEnd(end):
117 """ 118 Sets the mist end value. Objects further away from this will be coloured solid with 119 the colour set by setMistColor(). 120 121 @type end: float 122 """
123
124 -def setEyeSeparation(eyesep):
125 """ 126 Sets the eye separation for stereo mode. 127 128 @param eyesep: The distance between the left and right eye. 129 @type eyesep: float 130 """
131
132 -def getEyeSeparation():
133 """ 134 Gets the current eye separation for stereo mode. 135 136 @rtype: float 137 """
138
139 -def setFocalLength(focallength):
140 """ 141 Sets the focal length for stereo mode. 142 143 @param focallength: The focal length. 144 @type focallength: float 145 """
146
147 -def getFocalLength():
148 """ 149 Gets the current focal length for stereo mode. 150 151 @rtype: float 152 """
153
154 -def setMaterialMode(mode):
155 """ 156 Set the material mode to use for OpenGL rendering. 157 158 @type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL 159 @note: Changes will only affect newly created scenes. 160 """
161
162 -def getMaterialMode(mode):
163 """ 164 Get the material mode to use for OpenGL rendering. 165 166 @rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL 167 """
168
169 -def setGLSLMaterialSetting(setting, enable):
170 """ 171 Enables or disables a GLSL material setting. 172 173 @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) 174 @type enable: boolean 175 """
176
177 -def getGLSLMaterialSetting(setting, enable):
178 """ 179 Get the state of a GLSL material setting. 180 181 @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) 182 @rtype: boolean 183 """
184
185 -def drawLine(fromVec,toVec,color):
186 """ 187 Draw a line in the 3D scene. 188 189 @param fromVec: the origin of the line 190 @type fromVec: list [x, y, z] 191 @param toVec: the end of the line 192 @type toVec: list [x, y, z] 193 @param color: the color of the line 194 @type color: list [r, g, b] 195 """
196