Blender 3d game engine: Rasterizer Module
Methods:
disableMotionBlur setAmbientColor
drawLine setBackgroundColor
enableMotionBlur setEyeSeparation
enableVisibility setFocalLength
getEyeSeparation setGLSLMaterialSetting
getFocalLength setMaterialMode
getGLSLMaterialSetting setMistColor
getMaterialMode setMistEnd
getWindowHeight setMistStart
getWindowWidth setMousePosition
makeScreenshot showMouse
Variables:
---------- ----------
Constants:
---------- ----------



Instance Methods

disableMotionBlur

disableMotionBlur()

Disables the motion blur effect.

Sample Code

# import Rasterizer
import Rasterizer

# enable motion blur
Rasterizer.disableMotionBlur()

drawLine

drawLine(start, end, color)

Draws a line.

start:
  Type:    List [ x, y, z]

x =  x world coordinate
Type: float
y =  y world coordinate
Type: float
z =  z world coordinate
Type: float

end:
  Type:    List [ x, y, z]

x =  x world coordinate
Type: float
y =  y world coordinate
Type: float
z =  z world coordinate
Type: float

color:
  Type:    List [ r, g, b]

r =  red color value
Type: float
range: 0.0 - 1.0
g =  green color value
Type: float
range: 0.0 - 1.0
b =  blue color value
Type: float
range: 0.0 - 1.0

Note:
Line isn't permanent.  It has to be redrawn every time the frame is redrawn.    

Sample Code

# import Rasterizer
import Rasterizer

# draw a  red line
start = [0.0, 0.0, 0.0]
end = [100.0, 100.0, 5.0]
color = [ 1.0, 0.0, 0.0]

# draw it
Rasterizer.drawLine( start, end, color)

enableMotionBlur

enableMotionBlur(blur)

Enables the motion blur effect.

blur:
Type:  float
Range:  0.0 to 1.0

Note:
Your video card and drivers must provide support for the OpenGL accumulation buffer (gl_Accum)

Sample Code

# import Rasterizer
import Rasterizer

# enable motion blur
Rasterizer.enableMotionBlur( 0.65)

enableVisibility

enableVisibility(bool)

bool:
Type:   bool value.
    True or False.   1 or 0

Note:  
Documentation says it doesn't really do anything.

Sample Code

# import Rasterizer
import Rasterizer

# enable visibility
Rasterizer.enableVisibility(True)

getEyeSeparation

getEyeSeparation()

Returns the distance between left and right eye settings in stereo mode.  (3D glasses)

Return type:  float number

Note:
By default stereo mode is turned off.  To turn it on, Buttons Window Menu >> Panels Scene(F10) >> Format Tab >> Game framing settings.  Anaglyph button (red-blue stereo method)

Sample Code

# import Rasterizer
import Rasterizer

# get eye seperation
eyeSeparation = Rasterizer.getEyeSeparation()

getFocalLength

getFocalLength()

Returns the optimal focusing distance in stereo mode.  (3D glasses)

Return type:  float

Note:
By default stereo mode is turned off.  To turn it on, Buttons Window Menu >> Panels Scene(F10) >> Format Tab >> Game framing settings.  Anaglyph button (red-blue stereo method)

Sample Code

# import rasterizer
import Rasterizer

# get the focal length
focalLength = Rasterizer.getFocalLength()

getGLSLMaterialSetting

getGLSLMaterialSetting(setting)

Returns whether or not a GLSL material setting is enabled.

Return Type:  Bool

1 = False = Not enabled
0 = True = enabled
    
setting:
   lights, shaders, shadows, ramps, nodes and extra_textures

   Type:  string

Note:
This function returns 1 for False and 0 for True
It should return 0 for False and 1 for True

Sample Code

# import Rasterizer
import Rasterizer

# GLSL lights enabled?
lightsEnabled = Rasterizer.getGLSLMaterialSetting("lights")

# GLSL shaders enabled?
shadersEnabled = Rasterizer.getGLSLMaterialSetting("shaders")

getMaterialMode

getMaterialMode()

Returns the material mode being used.

Return Type:  integer

0 = KX_TEXFACE_MATERIAL
1 = KX_BLENDER_MULTITEX_MATERIAL
2 = KX_BLENDER_GLSL_MATERIAL

Note:
KX_BLENDER_MULTITEX_MATERIAL should return 1
Instead it returns 2.  Same as KX_BLENDER_GLSL_MATERIAL

Note:
Texture Face Materials (KX_TEXFACE_MATERIAL)
Blender Multitexture Materials (KX_BLENDER_MULTITEX_MATERIAL)
Blender GLSL Materials (KX_BLENDER_GLSL_MATERIAL)

Sample Code

# import Rasterizer
import Rasterizer

# get material mode
mode = Rasterizer.getMaterialMode()

getWindowHeight

getWindowHeight()

Returns the height of the game window in pixels

Return type:  integer

Sample Code

# import Rasterizer
import Rasterizer

# get game window height
height = Rasterizer.getWindowHeight()

getWindowWidth

getWindowWidth()

Returns the width of the game window in pixels

Return type:  integer

Sample Code

# import Rasterizer
import Rasterizer

# get game window width
width = Rasterizer.getWindowWidth()

makeScreenshot

makeScreenshot(filename)

Saves a screenshot to the filename.

filename:
Type:  string

Note:
The image format (jpeg or png or bmp etc) the screenshot is saved as is set in Scene(F10).  ie Buttons Window Menu >> Panels Scene(F10) >> Format Tab

Sample Code

# import Rasterizer
import Rasterizer

# save screenshot
Rasterizer.makeScreenshot("myScreenshot")


setAmbientColor

setAmbientColor(rgb)

Sets the ambient color.

rgb:
Type:  List [ r, g, b]

   r (red channel):
Type:  float
Range: 0.0 to 1.0

   g (green channel):
Type:  float
Range: 0.0 to 1.0

   b (blue channel):
Type:  float
Range: 0.0 to 1.0

Sample Code

# import Rastizer
import Rasterizer

# set the ambient color
Rasterizer.setAmbientColor([ 0.8, 0.0, 0.0])

setBackgroundColor

setBackgroundColor(rgba)

Sets the background color.

rgba:
Type:  List [ r, g, b, a]

   r (red channel):
Type:  float
Range: 0.0 to 1.0

   g (green channel):
Type:  float
Range: 0.0 to 1.0

   b (blue channel):
Type:  float
Range: 0.0 to 1.0

   a (alpha channel):
Type:  float
Range: 0.0 to 1.0

Sample Code

# import Rastizer
import Rasterizer

# set the background color to Red
Rasterizer.setBackgroundColor([1.0, 0.0, 0.0, 1.0])

setEyeSeparation

setEyeSeparation(eyeSeparation)

Sets  the distance between left and right eye settings in stereo mode.  (3D glasses)

eyeSeparation:
Type:  float variable

Note:
By default stereo mode is turned off.  To turn it on, Buttons Window Menu >> Panels Scene(F10) >> Format Tab >> Game framing settings.  Anaglyph button (red-blue stereo method)

Sample Code

# import Rastizer
import Rasterizer

# set eye separation
Rasterizer.setEyeSeparation(0.01)

setFocalLength

setFocalLength(focalLength)

Sets the optimal focusing distance in stereo mode.  (3D glasses)

focalLength:
Type:  float number

Note:
By default stereo mode is turned off.  To turn it on, Buttons Window Menu >> Panels Scene(F10) >> Format Tab >> Game framing settings.  Anaglyph button (red-blue stereo method)

Sample Code

# import rasterizer
import Rasterizer

# set focal length
Rasterizer.setFocalLength(0.15)

setGLSLMaterialSetting

setGLSLMaterialSetting(setting, enable)

Enables/disables a GLSL material setting.  

There are 6 settings (lights, shaders, shadows, ramps, nodes and extra_textures) that can be enabled/disabled.  

setting:
   lights, shaders, shadows, ramps, nodes and extra_textures

   Type:  string

enable:
   Type:  Bool

True or 1 = enable setting
False or 0 = disable setting

Note:
getGLSLMaterialSetting:
0 = True
1 = False
setGLSLMaterialSetting:
1 = True
0 = False

Sample Code

# import Rasterizer
import Rasterizer

# enable GLSL shaders
Rasterizer.setGLSLMaterialSetting("shaders", True)

setMaterialMode

setMateriaMode(mode)

Sets the material mode being used.

mode:
Type: integer

  0 = KX_TEXFACE_MATERIAL
  1 = KX_BLENDER_MULTITEX_MATERIAL
  2 = KX_BLENDER_GLSL_MATERIAL

Note:
Takes effect when a scene is started/restarted.
Note:
Texture Face Materials (KX_TEXFACE_MATERIAL)
Blender Multitexture Materials (KX_BLENDER_MULTITEX_MATERIAL)
Blender GLSL Materials (KX_BLENDER_GLSL_MATERIAL) 

Sample Code

# import rasterizer
import Rasterizer

# enable GLSL shaders
Rasterizer.setMaterialMode(2)

setMistColor

setMistColor(rgb)

Sets the mist color

rgb:
Type:  List [ r, g, b]

r (red channel):
Type:  float
Range: 0.0 to 1.0

g (green channel):
Type:  float
Range: 0.0 to 1.0

b (blue channel):
Type:  float
Range: 0.0 to 1.0

Sample Code

# import Rasterizer
import Rasterizer

# set mist color
Rasterizer.setMistColor([ 0.8, 0.8, 0.8])

setMistEnd

setMistEnd(end)

Sets the mist end value.  Anything farther than the end value will be colored solid with the color set in the mist color.

end:
Type:  float

Sample Code

# import Rasterizer
import Rasterizer

# set mist end
Rasterizer.setMistEnd(50.0)

setMistStart

setMistStart(start)

Sets the mist start value.  Anything further than the start value will have the mist applied to it.

start:
Type:  Blender units (float)

Sample Code

# import rasterizer
import Rasterizer

# set mist start
Rasterizer.setMistStart(10.0)

setMousePosition

setMousePosition(x, y)

Sets the position of the mouse cursor in the game window.

x, y:
Type:  integers

Note:
(0, 0) is upper left corner of the game window

Sample Code

# import rasterizer
import Rasterizer

# set mouse position to upper left corner
Rasterizer.setMousePosition(0, 0)

showMouse

showMouse(show)

Shows/hides the mouse cursor.

show:
Type:  Bool
   True or False.  1 or 0

   True shows the cursor.  False hides it.

Sample Code

# import rasterizer
import Rasterizer

# show the mouse cursor
Rasterizer.showMouse(True)


Blender 3D
Game Engine
Rapid prototyping for 3D games. Test realtime 3D gameplay without having to compile the game code. 3D game models automatically added.  GLSL shaders. Normal Mapping and Parallax Mapping. All OpenGL Lighting modes. This includes transparencies, animated and reflection mapped textures. Multiple textures and materials. UV mapping. Per-pixel lighting and dynamic lighting.  Uses Bullet Physics. Soft body dynamics. Rigid body dynamics. Collision detection and dynamics simulation. Collision bounds of all types. Car physics engine with full support for vehicle dynamics. (Spring reactions, stiffness, damping, tire friction etc.).