Module Rasterizer

Module Rasterizer

source code

Documentation for the Rasterizer module.

Example Uses an SCA_MouseSensor, and two KX_ObjectActuators to implement MouseLook:
       # To use a mouse movement sensor "Mouse" and a 
       # motion actuator to mouse look:
       import Rasterizer
       import GameLogic

       # SCALE sets the speed of motion
       SCALE=[1, 0.5]
       
       co = GameLogic.getCurrentController()
       obj = co.getOwner()
       mouse = co.getSensor("Mouse")
       lmotion = co.getActuator("LMove")
       wmotion = co.getActuator("WMove")
       
       # Transform the mouse coordinates to see how far the mouse has moved.
       def mousePos():
               x = (Rasterizer.getWindowWidth()/2 - mouse.getXPosition())*SCALE[0]
               y = (Rasterizer.getWindowHeight()/2 - mouse.getYPosition())*SCALE[1]
               return (x, y)
       
       pos = mousePos()
       
       # Set the amount of motion: X is applied in world coordinates...
       lmotion.setTorque(0.0, 0.0, pos[0], False)
       # ...Y is applied in local coordinates
       wmotion.setTorque(-pos[1], 0.0, 0.0, True)
       
       # Activate both actuators
       GameLogic.addActiveActuator(lmotion, True)
       GameLogic.addActiveActuator(wmotion, True)
       
       # Centre the mouse
       Rasterizer.setMousePosition(Rasterizer.getWindowWidth()/2, Rasterizer.getWindowHeight()/2)


Functions
integer
getWindowWidth()
Gets the width of the window (in pixels)
source code
integer
getWindowHeight()
Gets the height of the window (in pixels)
source code
 
makeScreenshot(filename)
Writes a screenshot to the given filename.
source code
 
enableVisibility(visible)
Doesn't really do anything...
source code
 
showMouse(visible)
Enables or disables the operating system mouse cursor.
source code
 
setMousePosition(x, y)
Sets the mouse cursor position.
source code
 
setBackgroundColor(rgba)
Sets the window background colour.
source code
 
setMistColor(rgb)
Sets the mist colour.
source code
 
setMistStart(start)
Sets the mist start value.
source code
 
setMistEnd(end)
Sets the mist end value.
source code
 
setEyeSeparation(eyesep)
Sets the eye separation for stereo mode.
source code
float
getEyeSeparation()
Gets the current eye separation for stereo mode.
source code
 
setFocalLength(focallength)
Sets the focal length for stereo mode.
source code
float
getFocalLength()
Gets the current focal length for stereo mode.
source code
Function Details

makeScreenshot(filename)

source code 

Writes a screenshot to the given filename.

If filename starts with // the image will be saved relative to the current directory. If the filename contains # it will be replaced with the frame number.

The standalone player saves .png files. It does not support colour space conversion or gamma correction.

When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg. Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels.

showMouse(visible)

source code 
Enables or disables the operating system mouse cursor.

setBackgroundColor(rgba)

source code 
Sets the window background colour.

setMistColor(rgb)

source code 
Sets the mist colour.

setMistStart(start)

source code 
Sets the mist start value. Objects further away than start will have mist applied to them.

setMistEnd(end)

source code 
Sets the mist end value. Objects further away from this will be coloured solid with the colour set by setMistColor().

setEyeSeparation(eyesep)

source code 
Sets the eye separation for stereo mode.
Parameters:
  • eyesep (float) - The distance between the left and right eye.

setFocalLength(focallength)

source code 
Sets the focal length for stereo mode.
Parameters:
  • focallength (float) - The focal length.