Module Rasterizer

Source Code for Module Rasterizer

  1  # $Id: Rasterizer.py 3304 2004-10-24 23:50:44Z kester $ 
  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           
 41  """ 
 42   
43 -def getWindowWidth():
44 """ 45 Gets the width of the window (in pixels) 46 47 @rtype: integer 48 """
49 -def getWindowHeight():
50 """ 51 Gets the height of the window (in pixels) 52 53 @rtype: integer 54 """
55 -def makeScreenshot(filename):
56 """ 57 Writes a screenshot to the given filename. 58 59 If filename starts with // the image will be saved relative to the current directory. 60 If the filename contains # it will be replaced with the frame number. 61 62 The standalone player saves .png files. It does not support colour space conversion 63 or gamma correction. 64 65 When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg. 66 Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels. 67 68 @type filename: string 69 """
70
71 -def enableVisibility(visible):
72 """ 73 Doesn't really do anything... 74 """
75
76 -def showMouse(visible):
77 """ 78 Enables or disables the operating system mouse cursor. 79 80 @type visible: boolean 81 """
82
83 -def setMousePosition(x, y):
84 """ 85 Sets the mouse cursor position. 86 87 @type x, y: integer 88 """
89
90 -def setBackgroundColor(rgba):
91 """ 92 Sets the window background colour. 93 94 @type rgba: list [r, g, b, a] 95 """
96
97 -def setMistColor(rgb):
98 """ 99 Sets the mist colour. 100 101 @type rgb: list [r, g, b] 102 """
103
104 -def setMistStart(start):
105 """ 106 Sets the mist start value. Objects further away than start will have mist applied to them. 107 108 @type start: float 109 """
110
111 -def setMistEnd(end):
112 """ 113 Sets the mist end value. Objects further away from this will be coloured solid with 114 the colour set by setMistColor(). 115 116 @type end: float 117 """
118
119 -def setEyeSeparation(eyesep):
120 """ 121 Sets the eye separation for stereo mode. 122 123 @param eyesep: The distance between the left and right eye. 124 @type eyesep: float 125 """
126
127 -def getEyeSeparation():
128 """ 129 Gets the current eye separation for stereo mode. 130 131 @rtype: float 132 """
133
134 -def setFocalLength(focallength):
135 """ 136 Sets the focal length for stereo mode. 137 138 @param focallength: The focal length. 139 @type focallength: float 140 """
141
142 -def getFocalLength():
143 """ 144 Gets the current focal length for stereo mode. 145 146 @rtype: float 147 """
148