2004-05-30 11:09:46 +00:00
|
|
|
# $Id$
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
Documentation for the Rasterizer module.
|
|
|
|
|
2004-06-02 12:43:27 +00:00
|
|
|
Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s 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)
|
|
|
|
|
2008-09-13 19:19:51 +00:00
|
|
|
@group Material Types: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
|
|
|
|
@var KX_TEXFACE_MATERIAL: Materials as defined by the texture face settings.
|
|
|
|
@var KX_BLENDER_MULTITEX_MATERIAL: Materials approximating blender materials with multitexturing.
|
2008-10-14 22:31:10 +00:00
|
|
|
@var KX_BLENDER_GLSL_MATERIAL: Materials approximating blender materials with GLSL.
|
|
|
|
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def getWindowWidth():
|
|
|
|
"""
|
|
|
|
Gets the width of the window (in pixels)
|
|
|
|
|
|
|
|
@rtype: integer
|
|
|
|
"""
|
|
|
|
def getWindowHeight():
|
|
|
|
"""
|
|
|
|
Gets the height of the window (in pixels)
|
|
|
|
|
|
|
|
@rtype: integer
|
|
|
|
"""
|
|
|
|
def makeScreenshot(filename):
|
|
|
|
"""
|
|
|
|
Writes a screenshot to the given filename.
|
|
|
|
|
2004-10-24 11:03:18 +00:00
|
|
|
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.
|
|
|
|
|
2004-05-24 07:49:50 +00:00
|
|
|
@type filename: string
|
|
|
|
"""
|
|
|
|
|
|
|
|
def enableVisibility(visible):
|
|
|
|
"""
|
|
|
|
Doesn't really do anything...
|
|
|
|
"""
|
|
|
|
|
|
|
|
def showMouse(visible):
|
|
|
|
"""
|
|
|
|
Enables or disables the operating system mouse cursor.
|
|
|
|
|
|
|
|
@type visible: boolean
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setMousePosition(x, y):
|
|
|
|
"""
|
|
|
|
Sets the mouse cursor position.
|
|
|
|
|
2008-08-31 19:07:10 +00:00
|
|
|
@type x: integer
|
|
|
|
@type y: integer
|
2004-05-24 07:49:50 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def setBackgroundColor(rgba):
|
|
|
|
"""
|
|
|
|
Sets the window background colour.
|
|
|
|
|
|
|
|
@type rgba: list [r, g, b, a]
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setMistColor(rgb):
|
|
|
|
"""
|
|
|
|
Sets the mist colour.
|
|
|
|
|
|
|
|
@type rgb: list [r, g, b]
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setMistStart(start):
|
|
|
|
"""
|
|
|
|
Sets the mist start value. Objects further away than start will have mist applied to them.
|
|
|
|
|
|
|
|
@type start: float
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setMistEnd(end):
|
|
|
|
"""
|
|
|
|
Sets the mist end value. Objects further away from this will be coloured solid with
|
|
|
|
the colour set by setMistColor().
|
|
|
|
|
|
|
|
@type end: float
|
|
|
|
"""
|
2004-10-24 11:03:18 +00:00
|
|
|
|
|
|
|
def setEyeSeparation(eyesep):
|
|
|
|
"""
|
|
|
|
Sets the eye separation for stereo mode.
|
|
|
|
|
|
|
|
@param eyesep: The distance between the left and right eye.
|
|
|
|
@type eyesep: float
|
|
|
|
"""
|
|
|
|
|
|
|
|
def getEyeSeparation():
|
|
|
|
"""
|
|
|
|
Gets the current eye separation for stereo mode.
|
|
|
|
|
|
|
|
@rtype: float
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setFocalLength(focallength):
|
|
|
|
"""
|
|
|
|
Sets the focal length for stereo mode.
|
|
|
|
|
2004-10-24 23:50:44 +00:00
|
|
|
@param focallength: The focal length.
|
2004-10-24 11:03:18 +00:00
|
|
|
@type focallength: float
|
|
|
|
"""
|
2004-05-24 07:49:50 +00:00
|
|
|
|
2004-10-24 11:03:18 +00:00
|
|
|
def getFocalLength():
|
|
|
|
"""
|
|
|
|
Gets the current focal length for stereo mode.
|
|
|
|
|
|
|
|
@rtype: float
|
|
|
|
"""
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2008-09-13 19:19:51 +00:00
|
|
|
def setMaterialMode(mode):
|
|
|
|
"""
|
|
|
|
Set the material mode to use for OpenGL rendering.
|
|
|
|
|
|
|
|
@type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
|
|
|
|
@note: Changes will only affect newly created scenes.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def getMaterialMode(mode):
|
|
|
|
"""
|
|
|
|
Get the material mode to use for OpenGL rendering.
|
|
|
|
|
|
|
|
@rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
|
|
|
|
"""
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
def setGLSLMaterialSetting(setting, enable):
|
|
|
|
"""
|
|
|
|
Enables or disables a GLSL material setting.
|
|
|
|
|
|
|
|
@type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
|
|
|
|
@type enable: boolean
|
|
|
|
"""
|
|
|
|
|
|
|
|
def getGLSLMaterialSetting(setting, enable):
|
|
|
|
"""
|
|
|
|
Get the state of a GLSL material setting.
|
|
|
|
|
|
|
|
@type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
|
|
|
|
@rtype: boolean
|
|
|
|
"""
|
2008-10-14 22:31:10 +00:00
|
|
|
|
|
|
|
def drawLine(fromVec,toVec,color):
|
2008-09-24 22:58:49 +00:00
|
|
|
"""
|
|
|
|
Draw a line in the 3D scene.
|
|
|
|
|
2008-10-14 22:31:10 +00:00
|
|
|
@param fromVec: the origin of the line
|
|
|
|
@type fromVec: list [x, y, z]
|
|
|
|
@param toVec: the end of the line
|
|
|
|
@type toVec: list [x, y, z]
|
2008-09-24 22:58:49 +00:00
|
|
|
@param color: the color of the line
|
|
|
|
@type color: list [r, g, b]
|
|
|
|
"""
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|