Module Rasterizer
[frames | no frames]

Module Rasterizer

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)

Function Summary
  enableVisibility(visible)
Doesn't really do anything...
tuple getCurrentResolution()
Gets the current display resolution.
list getValidResolutions()
Gets a list of valid display resolutions.
integer getWindowHeight()
Gets the height of the window (in pixels)
integer getWindowWidth()
Gets the width of the window (in pixels)
  makeScreenshot(filename)
Writes a screenshot to the given filename.
  setBackgroundColor(rgba)
Sets the window background colour.
  setDisplayResolution(width, height, bpp, rate)
Sets the display resolution.
  setMistColor(rgb)
Sets the mist colour.
  setMistEnd(end)
Sets the mist end value.
  setMistStart(start)
Sets the mist start value.
  setMousePosition(x, y)
Sets the mouse cursor position.
  showMouse(visible)
Enables or disables the operating system mouse cursor.

Function Details

enableVisibility(visible)

Doesn't really do anything...

getCurrentResolution()

Gets the current display resolution.

Example:
       import Rasterizer
       
       currentres = Rasterizer.getCurrentResolution()
       print "Width: ", currentres[0]
       print "Height: ", currentres[1]
       print "BPP: ", currentres[2]
       print "Refresh Rate: ", currentres[3]
Returns:
The current display resolution, in the form (width, height, bpp, rate)
           (type=tuple)

getValidResolutions()

Gets a list of valid display resolutions.

Example:
       import Rasterizer
       
       validres = Rasterizer.getValidResolutions()
       print "Width\tHeight\tBPP\tRefresh Rate"
       for res in validres:
               print res[0], "\t", res[1], "\t", res[2], "\t", res[3]
Returns:
A list of valid display resolutions, in the form [(width, height, bpp, rate)]
           (type=list)

getWindowHeight()

Gets the height of the window (in pixels)
Returns:
integer

getWindowWidth()

Gets the width of the window (in pixels)
Returns:
integer

makeScreenshot(filename)

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 the file based on the extension. .jpg, .png and .tga are supported. It will also not do 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.
Parameters:
filename
           (type=string)

setBackgroundColor(rgba)

Sets the window background colour.
Parameters:
rgba
           (type=list [r, g, b, a])

setDisplayResolution(width, height, bpp, rate)

Sets the display resolution.

The user's desktop resolution will be restored on Blender exit.

Note: X11 platforms can't set bpp.

Example:
       import Rasterizer
       
       Rasterizer.setDisplayResolution(800, 600, 32, 60)
Parameters:
width - New display width, in pixels
           (type=integer)
height - New display height, in pixels
           (type=integer)
bpp - The colour depth to set the display to: valid values are 8, 16, 24 and 32.
           (type=integer)
rate - The refresh rate to set the display
           (type=integer)

setMistColor(rgb)

Sets the mist colour.
Parameters:
rgb
           (type=list [r, g, b])

setMistEnd(end)

Sets the mist end value. Objects further away from this will be coloured solid with the colour set by setMistColor().
Parameters:
end
           (type=float)

setMistStart(start)

Sets the mist start value. Objects further away than start will have mist applied to them.
Parameters:
start
           (type=float)

setMousePosition(x, y)

Sets the mouse cursor position.
Parameters:
x
           (type=integer)
y
           (type=integer)

showMouse(visible)

Enables or disables the operating system mouse cursor.
Parameters:
visible
           (type=boolean)

Generated by Epydoc 2.1 on Sat Aug 28 03:10:00 2004 http://epydoc.sf.net