setAction(action,
reset=True)
DEPRECATED: use the 'action' property Sets the current action.
setStart(start)
DEPRECATED: use the 'start' property Specifies the starting frame of
the animation.
setEnd(end)
DEPRECATED: use the 'end' property Specifies the ending frame of the
animation.
setBlendin(blendin)
DEPRECATED: use the 'blendin' property Specifies the number of frames
of animation to generate when making transitions between actions.
setPriority(priority)
DEPRECATED: use the 'priority' property Sets the priority of this
actuator.
setFrame(frame)
DEPRECATED: use the 'frame' property Sets the current frame for the
animation.
setProperty(prop)
DEPRECATED: use the 'property' property Sets the property to be used
in FromProp playback mode.
setBlendtime(blendtime)
DEPRECATED: use the 'blendTime' property Sets the internal frame
timer.
setType(mode)
DEPRECATED: use the 'type' property Sets the operation mode of the
actuator
setContinue(cont)
DEPRECATED: use the 'continue' property Set the actions continue
option True or False.
integer
getType()
DEPRECATED: use the 'type' property Returns the operation mode of the
actuator
bool
getContinue()
DEPRECATED: use the 'continue' property When True, the action will
always play from where last left off, otherwise negative events to
this actuator will reset it to its start frame.
string
getAction()
DEPRECATED: use the 'action' property getAction() returns the name of
the action associated with this actuator.
float
getStart()
DEPRECATED: use the 'start' property Returns the starting frame of
the action.
float
getEnd()
DEPRECATED: use the 'end' property Returns the last frame of the
action.
float
getBlendin()
DEPRECATED: use the 'blendin' property Returns the number of
interpolation animation frames to be generated when this actuator is
triggered.
integer
getPriority()
DEPRECATED: use the 'priority' property Returns the priority for this
actuator.
float
getFrame()
DEPRECATED: use the 'frame' property Returns the current frame
number.
string
getProperty()
DEPRECATED: use the 'property' property Returns the name of the
property to be used in FromProp mode.
setFrameProperty(prop)
DEPRECATED: use the 'frameProperty' property
string
getFrameProperty()
DEPRECATED: use the 'frameProperty' property Returns the name of the
property that is set to the current frame number.
blendin
Specifies the number of frames of animation to generate when making
transitions between actions.
continue
The actions continue option, True or False.
float
end
Specifies the ending frame of the animation.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
float
frame
Sets the current frame for the animation.
string
frameProperty
The name of the property that is set to the current frame number.
channel (string) - A string specifying the name of the bone channel.
matrix (list [[float]]) - A 4x4 matrix specifying the overriding transformation as an
offset from the bone's rest position.
mode (boolean) - True for armature/world space, False for bone space
setAction(action,
reset=True)
DEPRECATED: use the 'action' property Sets the current action.
Parameters:
action (string) - The name of the action to set as the current action.
reset - Optional parameter indicating whether to reset the blend timer or
not. A value of 1 indicates that the timer should be reset. A
value of 0 will leave it unchanged. If reset is not specified,
the timer will be reset.
setStart(start)
DEPRECATED: use the 'start' property Specifies the starting frame of
the animation.
Parameters:
start (float) - the starting frame of the animation
setEnd(end)
DEPRECATED: use the 'end' property Specifies the ending frame of the
animation.
Parameters:
end (float) - the ending frame of the animation
setBlendin(blendin)
DEPRECATED: use the 'blendin' property Specifies the number of frames
of animation to generate when making transitions between actions.
Parameters:
blendin (float) - the number of frames in transition.
setPriority(priority)
DEPRECATED: use the 'priority' property Sets the priority of this
actuator.
Parameters:
priority (integer) - Specifies the new priority. Actuators will lower priority
numbers will override actuators with higher numbers.
setFrame(frame)
DEPRECATED: use the 'frame' property Sets the current frame for the
animation.
Parameters:
frame (float) - Specifies the new current frame for the animation
setProperty(prop)
DEPRECATED: use the 'property' property Sets the property to be used
in FromProp playback mode.
Parameters:
prop (string.) - the name of the property to use.
setBlendtime(blendtime)
DEPRECATED: use the 'blendTime' property Sets the internal frame
timer.
Allows the script to directly modify the internal timer used when
generating transitions between actions.
Parameters:
blendtime (float) - The new time. This parameter must be in the range from 0.0 to
1.0.
setType(mode)
DEPRECATED: use the 'type' property Sets the operation mode of the
actuator
DEPRECATED: use the 'priority' property Returns the priority for this
actuator. Actuators with lower Priority numbers will override actuators
with higher numbers.
Returns: integer
setFrameProperty(prop)
DEPRECATED: use the 'frameProperty' property
Parameters:
prop (string) - A string specifying the property of the object that will be
updated with the action frame number.
Instance Variable Details
blendTime
Sets the internal frame timer. This property must be in the range from
0.0 to blendin.
Type:
float
continue
The actions continue option, True or False. When True, the action will
always play from where last left off, otherwise negative events to this
actuator will reset it to its start frame.
priority
Sets the priority of this actuator. Actuators will lower priority numbers
will override actuators with higher numbers.
Type:
integer
type
The operation mode of the actuator. KX_ACTIONACT_PLAY,
KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP,
KX_ACTIONACT_LOOPEND
ShapeAction Actuators apply an shape action to an mesh object.
Instance Methods
setAction(action,
reset=True)
DEPRECATED: use the 'action' property Sets the current action.
setStart(start)
DEPRECATED: use the 'start' property Specifies the starting frame of
the animation.
setEnd(end)
DEPRECATED: use the 'end' property Specifies the ending frame of the
animation.
setBlendin(blendin)
DEPRECATED: use the 'blendin' property Specifies the number of frames
of animation to generate when making transitions between actions.
setPriority(priority)
DEPRECATED: use the 'priority' property Sets the priority of this
actuator.
setFrame(frame)
DEPRECATED: use the 'frame' property Sets the current frame for the
animation.
setProperty(prop)
DEPRECATED: use the 'property' property Sets the property to be used
in FromProp playback mode.
setBlendtime(blendtime)
DEPRECATED: use the 'blendTime' property Sets the internal frame
timer.
setType(mode)
DEPRECATED: use the 'type' property Sets the operation mode of the
actuator
integer
getType()
DEPRECATED: use the 'type' property Returns the operation mode of the
actuator
string
getAction()
DEPRECATED: use the 'action' property getAction() returns the name of
the action associated with this actuator.
float
getStart()
DEPRECATED: use the 'start' property Returns the starting frame of
the action.
float
getEnd()
DEPRECATED: use the 'end' property Returns the last frame of the
action.
float
getBlendin()
DEPRECATED: use the 'blendin' property Returns the number of
interpolation animation frames to be generated when this actuator is
triggered.
integer
getPriority()
DEPRECATED: use the 'priority' property Returns the priority for this
actuator.
float
getFrame()
DEPRECATED: use the 'frame' property Returns the current frame
number.
string
getProperty()
DEPRECATED: use the 'property' property Returns the name of the
property to be used in FromProp mode.
setFrameProperty(prop)
DEPRECATED: use the 'frameProperty' property
string
getFrameProperty()
DEPRECATED: use the 'frameProperty' property Returns the name of the
property that is set to the current frame number.
blendin
Specifies the number of frames of animation to generate when making
transitions between actions.
float
end
Specifies the ending frame of the shape animation.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
float
frame
Sets the current frame for the animation.
string
frameProperty
The name of the property that is set to the current frame number.
DEPRECATED: use the 'action' property Sets the current action.
Parameters:
action (string) - The name of the action to set as the current action.
reset - Optional parameter indicating whether to reset the blend timer or
not. A value of 1 indicates that the timer should be reset. A
value of 0 will leave it unchanged. If reset is not specified,
the timer will be reset.
setStart(start)
DEPRECATED: use the 'start' property Specifies the starting frame of
the animation.
Parameters:
start (float) - the starting frame of the animation
setEnd(end)
DEPRECATED: use the 'end' property Specifies the ending frame of the
animation.
Parameters:
end (float) - the ending frame of the animation
setBlendin(blendin)
DEPRECATED: use the 'blendin' property Specifies the number of frames
of animation to generate when making transitions between actions.
Parameters:
blendin (float) - the number of frames in transition.
setPriority(priority)
DEPRECATED: use the 'priority' property Sets the priority of this
actuator.
Parameters:
priority (integer) - Specifies the new priority. Actuators will lower priority
numbers will override actuators with higher numbers.
setFrame(frame)
DEPRECATED: use the 'frame' property Sets the current frame for the
animation.
Parameters:
frame (float) - Specifies the new current frame for the animation
setProperty(prop)
DEPRECATED: use the 'property' property Sets the property to be used
in FromProp playback mode.
Parameters:
prop (string.) - the name of the property to use.
setBlendtime(blendtime)
DEPRECATED: use the 'blendTime' property Sets the internal frame
timer.
Allows the script to directly modify the internal timer used when
generating transitions between actions.
Parameters:
blendtime (float) - The new time. This parameter must be in the range from 0.0 to
1.0.
setType(mode)
DEPRECATED: use the 'type' property Sets the operation mode of the
actuator
DEPRECATED: use the 'priority' property Returns the priority for this
actuator. Actuators with lower Priority numbers will override actuators
with higher numbers.
Returns: integer
setFrameProperty(prop)
DEPRECATED: use the 'frameProperty' property
Parameters:
prop (string) - A string specifying the property of the object that will be
updated with the action frame number.
Instance Variable Details
blendTime
Sets the internal frame timer. This property must be in the range from
0.0 to blendin.
Type:
float
priority
Sets the priority of this actuator. Actuators will lower priority numbers
will override actuators with higher numbers.
Type:
integer
type
The operation mode of the actuator. KX_ACTIONACT_PLAY,
KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP,
KX_ACTIONACT_LOOPEND
This module holds key constants for the SCA_KeyboardSensor.
Alphabet keys
AKEY
BKEY
CKEY
DKEY
EKEY
FKEY
GKEY
HKEY
IKEY
JKEY
KKEY
LKEY
MKEY
NKEY
OKEY
PKEY
QKEY
RKEY
SKEY
TKEY
UKEY
VKEY
WKEY
XKEY
YKEY
ZKEY
Number keys
ZEROKEY
ONEKEY
TWOKEY
THREEKEY
FOURKEY
FIVEKEY
SIXKEY
SEVENKEY
EIGHTKEY
NINEKEY
Shift Modifiers
CAPSLOCKKEY
LEFTCTRLKEY
LEFTALTKEY
RIGHTALTKEY
RIGHTCTRLKEY
RIGHTSHIFTKEY
LEFTSHIFTKEY
Arrow Keys
LEFTARROWKEY
DOWNARROWKEY
RIGHTARROWKEY
UPARROWKEY
Numberpad Keys
PAD0
PAD1
PAD2
PAD3
PAD4
PAD5
PAD6
PAD7
PAD8
PAD9
PADPERIOD
PADSLASHKEY
PADASTERKEY
PADMINUS
PADENTER
PADPLUSKEY
Function Keys
F1KEY
F2KEY
F3KEY
F4KEY
F5KEY
F6KEY
F7KEY
F8KEY
F9KEY
F10KEY
F11KEY
F12KEY
Other Keys
ACCENTGRAVEKEY
BACKSLASHKEY
BACKSPACEKEY
COMMAKEY
DELKEY
ENDKEY
EQUALKEY
ESCKEY
HOMEKEY
INSERTKEY
LEFTBRACKETKEY
LINEFEEDKEY
MINUSKEY
PAGEDOWNKEY
PAGEUPKEY
PAUSEKEY
PERIODKEY
QUOTEKEY
RIGHTBRACKETKEY
RETKEY
SEMICOLONKEY
SLASHKEY
SPACEKEY
TABKEY
Example:
# Set a connected keyboard sensor to accept F1
import GameLogic
import GameKeys
co = GameLogic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.getSensor('Keyboard')
sensor.key = GameKeys.F1KEY
Example:
# Do the all keys thing
import GameLogic
import GameKeys
co = GameLogic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.getSensor('Keyboard')
keylist = sensor.events
for key in keylist:
# key[0] == GameKeys.keycode, key[1] = status
if key[1] == GameLogic.KX_INPUT_JUST_ACTIVATED:
if key[0] == GameKeys.WKEY:
# Activate Forward!
if key[0] == GameKeys.SKEY:
# Activate Backward!
if key[0] == GameKeys.AKEY:
# Activate Left!
if key[0] == GameKeys.DKEY:
# Activate Right!
Functions
string
EventToString(event)
Return the string name of a key event.
string
EventToCharacter(event,
shift)
Return the string name of a key event.
Variables
__package__ = None
Function Details
EventToString(event)
Return the string name of a key event. Will raise a ValueError error
if its invalid.
Parameters:
event (int) - key event from GameKeys or the keyboard sensor.
Returns: string
EventToCharacter(event,
shift)
Return the string name of a key event. Returns an empty string if the
event cant be represented as a character.
Parameters:
event (int) - key event from GameKeys or the keyboard sensor.
All the other modules are accessible through the methods in
GameLogic.
See WhatsNew for
updates, changes and new functionality in the Game Engine Python
API.
Examples:
# To get the controller thats running this python script:
co = GameLogic.getCurrentController() # GameLogic is automatically imported
# To get the game object this controller is on:
obj = co.getOwner()
# To get a sensor linked to this controller.
# "sensorname" is the name of the sensor as defined in the Blender interface.
# +---------------------+ +--------+
# | Sensor "sensorname" +--+ Python +
# +---------------------+ +--------+
sens = co.getSensor("sensorname")
# To get a list of all sensors:
sensors = co.getSensors()
Most logic brick's methods are accessors for the properties
available in the logic buttons. Consult the logic bricks documentation
for more information on how each logic brick works.
There are also methods to access the current KX_Scene:
# Get the current scene
scene = GameLogic.getCurrentScene()
# Get the current camera
cam = scene.active_camera
Matricies as used by the game engine are row major:
body (string) - The body of the message (optional)
to (string) - The name of the object to send the message to (optional)
message_from (string) - The name of the object that the message is coming from (optional)
setGravity(gravity)
Sets the world gravity.
Parameters:
gravity (list [fx, fy, fz])
getSpectrum()
Returns a 512 point list from the sound card. This only works if the
fmod sound driver is being used.
Returns: list [float], len(getSpectrum()) == 512
stopDSP()
Stops the sound driver using DSP effects.
Only the fmod sound driver supports this. DSP can be computationally
expensive.
getLogicTicRate()
Gets the logic update frequency.
Returns: float
The logic frequency in Hz
setLogicTicRate(ticrate)
Sets the logic update frequency.
The logic update frequency is the number of times logic bricks are
executed every second. The default is 30 Hz.
Parameters:
ticrate (float) - The new logic update frequency (in Hz).
getPhysicsTicRate()
Gets the physics update frequency
Returns: float
The physics update frequency in Hz
setPhysicsTicRate(ticrate)
Sets the physics update frequency
The physics update frequency is the number of times the physics system
is executed every second. The default is 60 Hz.
Parameters:
ticrate (float) - The new update frequency (in Hz).
getAverageFrameRate()
Gets the estimated average framerate
Returns: float
The estimed average framerate in frames per second
expandPath(path)
Converts a blender internal path into a proper file system path.
Use / as directory separator in path You can use '//' at the start of
the string to define a relative path; Blender replaces that string by the
directory of the startup .blend or runtime file to make a full path name
(doesn't change during the game, even if you load other .blend). The
function also converts the directory separator to the local file system
format.
Parameters:
path (string) - The path string to be converted/expanded.
Returns: string
The converted string
getBlendFileList(path='//')
Returns a list of blend files in the same directory as the open blend
file, or from using the option argument.
Parameters:
path (string) - Optional directory argument, will be expanded (like expandPath)
into the full path.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
float
gain
the gain (volume) of the CD between 0.0 and 1.0.
rayCast(objto,
objfrom,
dist,
prop,
face,
xray,
poly)
Look from a point/object to another point/object and find first
object hit within dist that matches prop.
(Inherited from KX_GameObject.KX_GameObject)
rayCastTo(other,
dist,
prop)
Look towards another point/object and find first object hit within
dist that matches prop.
(Inherited from KX_GameObject.KX_GameObject)
INSIDE
see sphereInsideFrustum() and boxInsideFrustum()
INTERSECT
see sphereInsideFrustum() and boxInsideFrustum()
OUTSIDE
see sphereInsideFrustum() and boxInsideFrustum()
Method Details
sphereInsideFrustum(centre,
radius)
Tests the given sphere against the view frustum.
Parameters:
centre (list [x, y, z]) - The centre of the sphere (in world coordinates.)
radius (float) - the radius of the sphere
Returns:
INSIDE, OUTSIDE or INTERSECT
Example:
import GameLogic
co = GameLogic.getCurrentController()
cam = co.GetOwner()
# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
# Sphere is inside frustum !
# Do something useful !
else:
# Sphere is outside frustum
boxInsideFrustum(box)
Tests the given box against the view frustum.
Example:
import GameLogic
co = GameLogic.getCurrentController()
cam = co.GetOwner()
# Box to test...
box = []
box.append([-1.0, -1.0, -1.0])
box.append([-1.0, -1.0, 1.0])
box.append([-1.0, 1.0, -1.0])
box.append([-1.0, 1.0, 1.0])
box.append([ 1.0, -1.0, -1.0])
box.append([ 1.0, -1.0, 1.0])
box.append([ 1.0, 1.0, -1.0])
box.append([ 1.0, 1.0, 1.0])
if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
# Box is inside/intersects frustum !
# Do something useful !
else:
# Box is outside the frustum !
Parameters:
box (list) - Eight (8) corner points of the box (in world coordinates.)
Returns:
INSIDE, OUTSIDE or INTERSECT
pointInsideFrustum(point)
Tests the given point against the view frustum.
Example:
import GameLogic
co = GameLogic.getCurrentController()
cam = co.GetOwner()
# Test point [0.0, 0.0, 0.0]
if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
# Point is inside frustum !
# Do something useful !
else:
# Box is outside the frustum !
Parameters:
point ([x, y, z]) - The point to test (in world coordinates.)
Returns: boolean
True if the given point is inside this camera's viewing frustum.
getCameraToWorld()
Returns the camera-to-world transform.
Returns: matrix (4x4 list)
the camera-to-world transform matrix.
getWorldToCamera()
Returns the world-to-camera transform.
This returns the inverse matrix of getCameraToWorld().
Returns: matrix (4x4 list)
the world-to-camera transform matrix.
getProjectionMatrix()
Returns the camera's projection matrix.
Returns: matrix (4x4 list)
the camera's projection matrix.
setProjectionMatrix(matrix)
Sets the camera's projection matrix.
You should use normalised device coordinates for the clipping planes:
left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = cam.near, far
= cam.far
Example:
import GameLogic
def Scale(matrix, size):
for y in range(4):
for x in range(4):
matrix[y][x] = matrix[y][x] * size[y]
return matrix
# Generate a perspective projection matrix
def Perspective(cam):
return [[cam.near, 0.0 , 0.0 , 0.0 ],
[0.0 , cam.near, 0.0 , 0.0 ],
[0.0 , 0.0 , -(cam.far+cam.near)/(cam.far-cam.near), -2.0*cam.far*cam.near/(cam.far - cam.near)],
[0.0 , 0.0 , -1.0 , 0.0 ]]
# Generate an orthographic projection matrix
# You will need to scale the camera
def Orthographic(cam):
return [[1.0/cam.scaling[0], 0.0 , 0.0 , 0.0 ],
[0.0 , 1.0/cam.scaling[1], 0.0 , 0.0 ],
[0.0 , 0.0 , -2.0/(cam.far-cam.near), -(cam.far+cam.near)/(cam.far-cam.near)],
[0.0 , 0.0 , 0.0 , 1.0 ]]
# Generate an isometric projection matrix
def Isometric(cam):
return Scale([[0.707, 0.0 , 0.707, 0.0],
[0.408, 0.816,-0.408, 0.0],
[0.0 , 0.0 , 0.0 , 0.0],
[0.0 , 0.0 , 0.0 , 1.0]],
[1.0/cam.scaling[0], 1.0/cam.scaling[1], 1.0/cam.scaling[2], 1.0])
co = GameLogic.getCurrentController()
cam = co.getOwner()
cam.setProjectionMatrix(Perspective(cam)))
Parameters:
matrix (4x4 matrix.) - The new projection matrix for this camera.
enableViewport(viewport)
Use this camera to draw a viewport on the screen (for split screen
games or overlay scenes). The viewport region is defined with setViewport.
Parameters:
viewport (bool) - the new viewport status
setViewport(left,
bottom,
right,
top)
Sets the region of this viewport on the screen in pixels.
This camera's camera to world transform. (read only) Regenerated every
frame from the camera's position and orientation.
Type:
4x4 Matrix [[float]]
modelview_matrix
This camera's 4x4 model view matrix. (read only) Regenerated every frame
from the camera's position and orientation.
Type:
4x4 Matrix [[float]]
perspective
True if this camera has a perspective transform.
If perspective is False, this camera has an orthographic
transform.
Note that the orthographic transform is faked by multiplying the lens
attribute by 100.0 and translating the camera 100.0 along the z axis.
This is the same as Blender. If you want a true orthographic
transform, see setProjectionMatrix.
Type:
boolean
world_to_camera
This camera's world to camera transform. (read only) Regenerated every
frame from the camera's position and orientation. This is camera_to_world
inverted.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
float
height
height to stay above the target object
float
max
maximum distance to stay from the target object
float
min
minimum distance to the target object maintained by the actuator
damp
time constant of the constraint expressed in frame (not use by Force
field constraint)
3-tuple of float: [x,y,z]
direction
the reference direction in world coordinate for the orientation
constraint
float
distance
the target distance of the distance constraint
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
integer
limit
type of constraint, use one of the following constant:
KX_ACT_CONSTRAINT_LOCX ( 1) : limit X coord KX_ACT_CONSTRAINT_LOCY
( 2) : limit Y coord KX_ACT_CONSTRAINT_LOCZ ( 3) : limit Z coord
KX_ACT_CONSTRAINT_ROTX ( 4) : limit X rotation
KX_ACT_CONSTRAINT_ROTY ( 5) : limit Y rotation
KX_ACT_CONSTRAINT_ROTZ ( 6) : limit Z rotation
KX_ACT_CONSTRAINT_DIRPX ( 7) : set distance along positive X axis
KX_ACT_CONSTRAINT_DIRPY ( 8) : set distance along positive Y axis
KX_ACT_CONSTRAINT_DIRPZ ( 9) : set distance along positive Z axis
KX_ACT_CONSTRAINT_DIRNX (10) : set distance along negative X axis
KX_ACT_CONSTRAINT_DIRNY (11) : set distance along negative Y axis
KX_ACT_CONSTRAINT_DIRNZ (12) : set distance along negative Z axis
KX_ACT_CONSTRAINT_ORIX (13) : set orientation of X axis
KX_ACT_CONSTRAINT_ORIY (14) : set orientation of Y axis
KX_ACT_CONSTRAINT_ORIZ (15) : set orientation of Z axis
KX_ACT_CONSTRAINT_FHPX (16) : set force field along positive X axis
KX_ACT_CONSTRAINT_FHPY (17) : set force field along positive Y axis
KX_ACT_CONSTRAINT_FHPZ (18) : set force field along positive Z axis
KX_ACT_CONSTRAINT_FHNX (19) : set force field along negative X axis
KX_ACT_CONSTRAINT_FHNY (20) : set force field along negative Y axis
KX_ACT_CONSTRAINT_FHNZ (21) : set force field along negative Z axis
Sets the time constant of the orientation constraint.
Parameters:
duration (integer) - If the duration is negative, it is set to 0.
setDirection(vector)
Sets the reference direction in world coordinate for the orientation
constraint
Parameters:
vector (3-tuple)
setOption(option)
Sets several options of the distance constraint.
Parameters:
option (integer) - Binary combination of the following values: 64 : Activate
alignment to surface 128 : Detect material rather than property
256 : No deactivation if ray does not hit target 512 : Activate
distance control
setTime(duration)
Sets the activation time of the actuator.
Parameters:
duration (integer) - The actuator disables itself after this many frame. If set to 0
or negative, the actuator is not limited in time.
setProperty(property)
Sets the name of the property or material for the ray detection of the
distance constraint.
Parameters:
property (string) - If empty, the ray will detect any collisioning object.
setDistance(distance)
Sets the target distance in distance constraint.
Parameters:
distance (float)
setRayLength(length)
Sets the maximum ray length of the distance constraint.
Parameters:
length (float)
Instance Variable Details
max
the upper bound of the constraint. For rotation and orientation
constraints, it represents radiant.
Type:
float
option
Binary combination of the following values: Applicable to Distance
constraint:
KX_ACT_CONSTRAINT_NORMAL ( 64) : Activate alignment to surface
KX_ACT_CONSTRAINT_DISTANCE ( 512) : Activate distance control
KX_ACT_CONSTRAINT_LOCAL (1024) : direction of the ray
is along the local axis
Applicable to Force field constraint:
KX_ACT_CONSTRAINT_DOROTFH (2048) : Force field act on rotation as
well
Applicable to both:
KX_ACT_CONSTRAINT_MATERIAL ( 128) : Detect material rather than
property
KX_ACT_CONSTRAINT_PERMANENT ( 256) : No deactivation if ray does not
hit target
Type:
integer
time
activation time of the actuator. The actuator disables itself after this
many frame. If set to 0, the actuator is not limited in time.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
Properties assigned to game objects are accessible as attributes of
this class.
note: Calling ANY method or attribute on an object that has been
removed from a scene will raise a RuntimeError, if an object may have
been removed since last accessing it use the isValid attribute to check.
Instance Methods
alignAxisToVect(vect,
axis)
Aligns any of the game object's axis along the given vector.
applyForce(force,
local=0)
Sets the game object's force.
applyImpulse(point,
impulse)
Applies an impulse to the game object.
applyMovement(movement,
local=0)
Sets the game object's movement.
applyRotation(rotation,
local=0)
Sets the game object's rotation.
applyTorque(torque,
local=0)
Sets the game object's torque.
rayCast(objto,
objfrom,
dist,
prop,
face,
xray,
poly)
Look from a point/object to another point/object and find first
object hit within dist that matches prop.
Aligns any of the game object's axis along the given vector.
Parameters:
vect (3d vector.) - a vector to align the axis.
axis (integer.) - The axis you want to align
0: X axis
1: Y axis
2: Z axis (default)
applyForce(force,
local=0)
Sets the game object's force.
This requires a dynamic object.
Parameters:
force (3d vector.) - force vector.
local (boolean) - - False: you get the "global" force ie: relative to
world orientation (default).
True: you get the "local" force ie: relative to
object orientation.
applyImpulse(point,
impulse)
Applies an impulse to the game object.
This will apply the specified impulse to the game object at the
specified point. If point != getPosition(), applyImpulse will also change
the object's angular momentum. Otherwise, only linear momentum will
change.
Parameters:
point (list [x, y, z]) - the point to apply the impulse to (in world coordinates)
applyMovement(movement,
local=0)
Sets the game object's movement.
Parameters:
movement (3d vector.) - movement vector.
local (boolean) - - False: you get the "global" movement ie: relative to
world orientation (default).
True: you get the "local" movement ie: relative to
object orientation.
applyRotation(rotation,
local=0)
Sets the game object's rotation.
Parameters:
rotation (3d vector.) - rotation vector.
local (boolean) - - False: you get the "global" rotation ie: relative to
world orientation (default).
True: you get the "local" rotation ie: relative to
object orientation.
applyTorque(torque,
local=0)
Sets the game object's torque.
This requires a dynamic object.
Parameters:
torque (3d vector.) - torque vector.
local (boolean) - - False: you get the "global" torque ie: relative to
world orientation (default).
True: you get the "local" torque ie: relative to
object orientation.
disableRigidBody()
Disables rigid body physics for this object.
Note:
This is not working with bullet physics yet. The angular is removed
but rigid body physics can still rotate it later.
enableRigidBody()
Enables rigid body physics for this object.
Rigid body physics allows the object to roll on collisions.
Note:
This is not working with bullet physics yet.
endObject()
Delete this object, can be used inpace of the EndObject Actuator. The
actual removal of the object from the scene is delayed.
getAngularVelocity(local=0)
Gets the game object's angular velocity.
Parameters:
local (boolean) - - False: you get the "global" velocity ie: relative to
world orientation (default).
True: you get the "local" velocity ie: relative to
object orientation.
Returns: list [vx, vy, vz]
the object's angular velocity.
getAxisVect(vect)
Returns the axis vector rotates by the objects worldspace orientation.
This is the equivalent if multiplying the vector by the orientation
matrix.
Parameters:
vect (3d vector.) - a vector to align the axis.
Returns: 3d vector.
The vector in relation to the objects rotation.
getChildren()
Return a list of immediate children of this object.
Look from a point/object to another point/object and find first object
hit within dist that matches prop. if poly is 0, returns a 3-tuple with
object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th
element.
Ex:
# shoot along the axis gun-gunAim (gunAim should be collision-free)
ob,point,normal = gun.rayCast(gunAim,None,50)
if ob:
# hit something
Notes: The ray ignores the object on which the method is called. It is
casted from/to object center or explicit [x,y,z] points.
The face paremeter determines the orientation of the normal:
0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the
first object hit (other than self object) stops the ray. The prop and
xray parameters interact as follow:
prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
prop off, xray on : idem.
prop on, xray off: return closest hit if it matches prop, no hit otherwise.
prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
The KX_PolyProxy
4th element of the return tuple when poly=1 allows to retrieve
information on the polygon hit by the ray. If there is no hit or the hit
object is not a static mesh, None is returned as 4th element.
The ray ignores collision-free objects and faces that dont have the
collision flag enabled, you can however use ghost objects.
Parameters:
objto (KX_GameObject or 3-tuple) - [x,y,z] or object to which the ray is casted
objfrom (KX_GameObject or 3-tuple or None) - [x,y,z] or object from which the ray is casted; None or omitted
=> use self object center
dist (float) - max distance to look (can be negative => look behind); 0 or
omitted => detect up to to
prop (string) - property name that object must have; can be omitted => detect
any object
face (int) - normal option: 1=>return face normal; 0 or omitted =>
normal is oriented towards origin
xray (int) - X-ray option: 1=>skip objects that don't match prop; 0 or
omitted => stop on first object
poly (int) - polygon option: 1=>return value is a 4-tuple and the 4th
element is a KX_PolyProxy
(object,hitpoint,hitnormal) or
(object,hitpoint,hitnormal,polygon) If no hit, returns
(None,None,None) or (None,None,None,None) If the object hit is
not a static mesh, polygon is None
rayCastTo(other,
dist,
prop)
Look towards another point/object and find first object hit within
dist that matches prop.
The ray is always casted from the center of the object, ignoring the
object itself. The ray is casted towards the center of another object or
an explicit [x,y,z] point. Use rayCast() if you need to retrieve the hit
point
Parameters:
other (KX_GameObject or 3-tuple) - [x,y,z] or object towards which the ray is casted
dist (float) - max distance to look (can be negative => look behind); 0 or
omitted => detect up to other
prop (string) - property name that object must have; can be omitted => detect
any object
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
string
framePropName
Assign this property this action current frame number
Set whether to apply the force in the object's local coordinates
rather than the world global coordinates. (deprecated)
Parameters:
local (boolean) - Apply the ipo-as-force in the object's local coordinates?
(KX_TRUE, KX_FALSE)
getForceIpoActsLocal()
Return whether to apply the force in the object's local coordinates
rather than the world global coordinates. (deprecated)
Instance Variable Details
type
Play mode for the ipo. (In GameLogic.KX_IPOACT_PLAY, KX_IPOACT_PINGPONG,
KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND,
KX_IPOACT_FROM_PROP)
rayCast(objto,
objfrom,
dist,
prop,
face,
xray,
poly)
Look from a point/object to another point/object and find first
object hit within dist that matches prop.
(Inherited from KX_GameObject.KX_GameObject)
rayCastTo(other,
dist,
prop)
Look towards another point/object and find first object hit within
dist that matches prop.
(Inherited from KX_GameObject.KX_GameObject)
A point light source with no attenuation. See attribute 'type'
colour
The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0,
1.0]
Type:
list [r, g, b]
distance
The maximum distance this light can illuminate. (SPOT and NORMAL lights
only)
Type:
float
lin_attenuation
The linear component of this light's attenuation. (SPOT and NORMAL lights
only)
Type:
float
spotblend
Specifies the intensity distribution of the spot light. (float) (SPOT
lights only) Higher values result in a more focused light source. 0.0
<= spotblend <= 1.0.
spotsize
The cone angle of the spot light, in degrees. (float) (SPOT lights only)
0.0 <= spotsize <= 180.0. Spotsize = 360.0 is also accepted.
You can only change the vertex properties of a mesh object, not the
mesh topology.
To use mesh objects effectively, you should know a bit about how the
game engine handles them.
Mesh Objects are converted from Blender at scene load.
The Converter groups polygons by Material. This means they can be
sent to the renderer efficiently. A material holds:
The texture.
The Blender material.
The Tile properties
The face properties - (From the "Texture Face" panel)
Transparency & z sorting
Light layer
Polygon shape (triangle/quad)
Game Object
Verticies will be split by face if necessary. Verticies can only be
shared between faces if:
They are at the same position
UV coordinates are the same
Their normals are the same (both polygons are "Set
Smooth")
They are the same colour
For example: a cube has 24 verticies: 6 faces with 4 verticies per
face.
The correct method of iterating over every KX_VertexProxy in a
game object:
import GameLogic
co = GameLogic.getcurrentController()
obj = co.getOwner()
m_i = 0
mesh = obj.getMesh(m_i) # There can be more than one mesh...
while mesh != None:
for mat in range(mesh.getNumMaterials()):
for v_index in range(mesh.getVertexArrayLength(mat)):
vertex = mesh.getVertex(mat, v_index)
# Do something with vertex here...
# ... eg: colour the vertex red.
vertex.colour = [1.0, 0.0, 0.0, 1.0]
m_i += 1
mesh = obj.getMesh(m_i)
Instance Methods
integer
getNumMaterials()
Gets the number of materials associated with this object.
string
getMaterialName(matid)
Gets the name of the specified material.
string
getTextureName(matid)
Gets the name of the specified material's texture.
integer
getVertexArrayLength(matid)
Gets the length of the vertex array associated with the specified
material.
A mesh must have only one material with collision flags, and have all
collision primitives in one vertex array (ie. < 65535 verts) and be
either a polytope or polyheder mesh. If you don't get a warning in the
console when the collision type is polytope, the mesh is suitable for
reinstance.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
getTouchMaterial()
DEPRECATED: use the useMaterial property Returns KX_TRUE if this
sensor looks for a specific material, KX_FALSE if it looks for a
specific property.
(Inherited from KX_TouchSensor.KX_TouchSensor)
getUseNegPulseMode()
True if the sensor is in negative pulse mode.
(Inherited from SCA_ISensor.SCA_ISensor)
getUsePosPulseMode()
True if the sensor is in positive pulse mode.
(Inherited from SCA_ISensor.SCA_ISensor)
isPositive()
True if this sensor brick is in a positive state.
(Inherited from SCA_ISensor.SCA_ISensor)
isTriggered()
True if this sensor brick has triggered the current controller.
(Inherited from SCA_ISensor.SCA_ISensor)
reset()
Reset sensor internal state, effect depends on the type of sensor and
settings.
(Inherited from SCA_ISensor.SCA_ISensor)
distance
The near sensor activates when an object is within this distance.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
frameMessageCount
The number of messages received since the last frame.
KX_ObjectActuator
The object actuator ("Motion Actuator") applies force,
torque, displacement, angular displacement, velocity, or angular
velocity to an object.
The object actuator ("Motion Actuator") applies force,
torque, displacement, angular displacement, velocity, or angular velocity
to an object. Servo control allows to regulate force to achieve a certain
speed target.
Instance Methods
list [fx, fy, fz, local]
getForce()
Returns the force applied by the actuator.
setForce(fx,
fy,
fz,
local)
Sets the force applied by the actuator.
list [Τx, Τy, Τz, local]
getTorque()
Returns the torque applied by the actuator.
setTorque(tx,
ty,
tz,
local)
Sets the torque applied by the actuator.
list [dx, dy, dz, local]
getDLoc()
Returns the displacement vector applied by the actuator.
setDLoc(dx,
dy,
dz,
local)
Sets the displacement vector applied by the actuator.
list [dx, dy, dz, local]
getDRot()
Returns the angular displacement vector applied by the actuator.
setDRot(dx,
dy,
dz,
local)
Sets the angular displacement vector applied by the actuator.
list [vx, vy, vz, local]
getLinearVelocity()
Returns the linear velocity applied by the actuator.
setLinearVelocity(vx,
vy,
vz,
local)
Sets the linear velocity applied by the actuator.
list [ωx, ωy, ωz, local]
getAngularVelocity()
Returns the angular velocity applied by the actuator.
setAngularVelocity(wx,
wy,
wz,
local)
Sets the angular velocity applied by the actuator.
integer
getDamping()
Returns the damping parameter of the servo controller.
setDamping(damp)
Sets the damping parameter of the servo controller.
list [min, max, enabled]
getForceLimitX()
Returns the min/max force limit along the X axis used by the servo
controller.
setForceLimitX(min,
max,
enable)
Sets the min/max force limit along the X axis and activates or
deactivates the limits in the servo controller.
list [min, max, enabled]
getForceLimitY()
Returns the min/max force limit along the Y axis used by the servo
controller.
setForceLimitY(min,
max,
enable)
Sets the min/max force limit along the Y axis and activates or
deactivates the limits in the servo controller.
list [min, max, enabled]
getForceLimitZ()
Returns the min/max force limit along the Z axis used by the servo
controller.
setForceLimitZ(min,
max,
enable)
Sets the min/max force limit along the Z axis and activates or
deactivates the limits in the servo controller.
list [P, I, D]
getPID()
Returns the PID coefficient of the servo controller.
setPID(P,
I,
D)
Sets the PID coefficients of the servo controller.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
A four item list, containing the vector force, and a flag
specifying whether the force is local.
setForce(fx,
fy,
fz,
local)
Sets the force applied by the actuator.
Parameters:
fx (float) - the x component of the force.
fy (float) - the z component of the force.
fz (float) - the z component of the force.
local (boolean) - - False: the force is applied in world coordinates.
True: the force is applied in local coordinates.
getTorque()
Returns the torque applied by the actuator.
Returns: list [Τx, Τy, Τz, local]
A four item list, containing the vector torque, and a flag
specifying whether the torque is applied in local coordinates
(True) or world coordinates (False)
setTorque(tx,
ty,
tz,
local)
Sets the torque applied by the actuator.
Parameters:
tx (float) - the x component of the torque.
ty (float) - the z component of the torque.
tz (float) - the z component of the torque.
local (boolean) - - False: the torque is applied in world coordinates.
True: the torque is applied in local coordinates.
getDLoc()
Returns the displacement vector applied by the actuator.
Returns: list [dx, dy, dz, local]
A four item list, containing the vector displacement, and whether
the displacement is applied in local coordinates (True) or world
coordinates (False)
setDLoc(dx,
dy,
dz,
local)
Sets the displacement vector applied by the actuator.
Since the displacement is applied every frame, you must adjust the
displacement based on the frame rate, or you game experience will depend
on the player's computer speed.
Parameters:
dx (float) - the x component of the displacement vector.
dy (float) - the z component of the displacement vector.
dz (float) - the z component of the displacement vector.
local (boolean) - - False: the displacement vector is applied in world coordinates.
True: the displacement vector is applied in local
coordinates.
getDRot()
Returns the angular displacement vector applied by the actuator.
Returns: list [dx, dy, dz, local]
A four item list, containing the angular displacement vector, and
whether the displacement is applied in local coordinates (True)
or world coordinates (False)
setDRot(dx,
dy,
dz,
local)
Sets the angular displacement vector applied by the actuator.
Since the displacement is applied every frame, you must adjust the
displacement based on the frame rate, or you game experience will depend
on the player's computer speed.
Parameters:
dx (float) - the x component of the angular displacement vector.
dy (float) - the z component of the angular displacement vector.
dz (float) - the z component of the angular displacement vector.
local (boolean) - - False: the angular displacement vector is applied in world
coordinates.
True: the angular displacement vector is applied in local
coordinates.
getLinearVelocity()
Returns the linear velocity applied by the actuator. For the servo
control actuator, this is the target speed.
Returns: list [vx, vy, vz, local]
A four item list, containing the vector velocity, and whether the
velocity is applied in local coordinates (True) or world
coordinates (False)
setLinearVelocity(vx,
vy,
vz,
local)
Sets the linear velocity applied by the actuator. For the servo
control actuator, sets the target speed.
Parameters:
vx (float) - the x component of the velocity vector.
vy (float) - the z component of the velocity vector.
vz (float) - the z component of the velocity vector.
local (boolean) - - False: the velocity vector is in world coordinates.
True: the velocity vector is in local coordinates.
getAngularVelocity()
Returns the angular velocity applied by the actuator.
Returns: list [ωx, ωy, ωz, local]
A four item list, containing the vector velocity, and whether the
velocity is applied in local coordinates (True) or world
coordinates (False)
setAngularVelocity(wx,
wy,
wz,
local)
Sets the angular velocity applied by the actuator.
Parameters:
wx (float) - the x component of the velocity vector.
wy (float) - the z component of the velocity vector.
wz (float) - the z component of the velocity vector.
local (boolean) - - False: the velocity vector is applied in world coordinates.
True: the velocity vector is applied in local coordinates.
getDamping()
Returns the damping parameter of the servo controller.
Returns: integer
the time constant of the servo controller in frame unit.
setDamping(damp)
Sets the damping parameter of the servo controller.
Parameters:
damp (integer) - the damping parameter in frame unit.
getForceLimitX()
Returns the min/max force limit along the X axis used by the servo
controller.
Returns: list [min, max, enabled]
A three item list, containing the min and max limits of the force
as float and whether the limits are active(true) or
inactive(true)
setForceLimitX(min,
max,
enable)
Sets the min/max force limit along the X axis and activates or
deactivates the limits in the servo controller.
Parameters:
min (float) - the minimum value of the force along the X axis.
max (float) - the maximum value of the force along the X axis.
enable (boolean) - - True: the force will be limited to the min/max
False: the force will not be limited
getForceLimitY()
Returns the min/max force limit along the Y axis used by the servo
controller.
Returns: list [min, max, enabled]
A three item list, containing the min and max limits of the force
as float and whether the limits are active(true) or
inactive(true)
setForceLimitY(min,
max,
enable)
Sets the min/max force limit along the Y axis and activates or
deactivates the limits in the servo controller.
Parameters:
min (float) - the minimum value of the force along the Y axis.
max (float) - the maximum value of the force along the Y axis.
enable (boolean) - - True: the force will be limited to the min/max
False: the force will not be limited
getForceLimitZ()
Returns the min/max force limit along the Z axis used by the servo
controller.
Returns: list [min, max, enabled]
A three item list, containing the min and max limits of the force
as float and whether the limits are active(true) or
inactive(true)
setForceLimitZ(min,
max,
enable)
Sets the min/max force limit along the Z axis and activates or
deactivates the limits in the servo controller.
Parameters:
min (float) - the minimum value of the force along the Z axis.
max (float) - the maximum value of the force along the Z axis.
enable (boolean) - - True: the force will be limited to the min/max
False: the force will not be limited
getPID()
Returns the PID coefficient of the servo controller.
Returns: list [P, I, D]
A three item list, containing the PID coefficient as floats: P :
proportional coefficient I : Integral coefficient D : Derivate
coefficient
setPID(P,
I,
D)
Sets the PID coefficients of the servo controller.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
KX_GameObject or None
object
the object this actuator sets the parent too.
getMaterialIndex()
Returns the material bucket index of the polygon.
integer
getNumVertex()
Returns the number of vertex of the polygon.
integer
isVisible()
Returns whether the polygon is visible or not
integer
isCollider()
Returns whether the polygon is receives collision or not
integer
getVertexIndex(vertex)
Returns the mesh vertex index of a polygon vertex This index and the
one returned by getMaterialIndex() are needed to retrieve the vertex
proxy from KX_MeshProxy.
matid
The material index of the polygon, use this to retrieve vertex proxy
from mesh proxy
string
matname
The name of polygon material, empty if no material.
string
texture
The texture name of the polygon.
integer
v1
vertex index of the first vertex of the polygon, use this to retrieve
vertex proxy from mesh proxy
integer
v2
vertex index of the second vertex of the polygon, use this to
retrieve vertex proxy from mesh proxy
integer
v3
vertex index of the third vertex of the polygon, use this to retrieve
vertex proxy from mesh proxy
integer
v4
vertex index of the fourth vertex of the polygon, 0 if polygon has
only 3 vertex use this to retrieve vertex proxy from mesh proxy
integer
visible
visible state of the polygon: 1=visible, 0=invisible
Method Details
getMaterialName()
Returns the polygon material name with MA prefix
Returns: string
material name
getTextureName()
Returns the polygon texture name
Returns: string
texture name
getMaterialIndex()
Returns the material bucket index of the polygon. This index and the
ones returned by getVertexIndex() are needed to retrieve the vertex proxy
from KX_MeshProxy.
Returns: integer
the material index in the mesh
getNumVertex()
Returns the number of vertex of the polygon.
Returns: integer
number of vertex, 3 or 4.
isVisible()
Returns whether the polygon is visible or not
Returns: integer
0=invisible, 1=visible
isCollider()
Returns whether the polygon is receives collision or not
Returns: integer
0=collision free, 1=receives collision
getVertexIndex(vertex)
Returns the mesh vertex index of a polygon vertex This index and the
one returned by getMaterialIndex() are needed to retrieve the vertex
proxy from KX_MeshProxy.
Parameters:
vertex (integer) - index of the vertex in the polygon: 0->3
This is the interface to materials in the game engine.
Materials define the render state to be applied to mesh objects.
Warning: Some of the methods/variables are CObjects. If you mix
these up, you will crash blender.
This example requires:
PyOpenGL http://pyopengl.sourceforge.net/
GLEWPy http://glewpy.sourceforge.net/
Example:
import GameLogic
import OpenGL
from OpenGL.GL import *
from OpenGL.GLU import *
import glew
from glew import *
glewInit()
vertex_shader = """
void main(void)
{
gl_Position = ftransform();
}
"""
fragment_shader ="""
void main(void)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
"""
class MyMaterial:
def __init__(self):
self.pass_no = 0
# Create a shader
self.m_program = glCreateProgramObjectARB()
# Compile the vertex shader
self.shader(GL_VERTEX_SHADER_ARB, (vertex_shader))
# Compile the fragment shader
self.shader(GL_FRAGMENT_SHADER_ARB, (fragment_shader))
# Link the shaders together
self.link()
def PrintInfoLog(self, tag, object):
"""
PrintInfoLog prints the GLSL compiler log
"""
print "Tag: def PrintGLError(self, tag = ""):
def PrintGLError(self, tag = ""):
"""
Prints the current GL error status
"""
if len(tag):
print tag
err = glGetError()
if err != GL_NO_ERROR:
print "GL Error: %s\n"%(gluErrorString(err))
def shader(self, type, shaders):
"""
shader compiles a GLSL shader and attaches it to the current
program.
type should be either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB
shaders should be a sequence of shader source to compile.
"""
# Create a shader object
shader_object = glCreateShaderObjectARB(type)
# Add the source code
glShaderSourceARB(shader_object, len(shaders), shaders)
# Compile the shader
glCompileShaderARB(shader_object)
# Print the compiler log
self.PrintInfoLog("vertex shader", shader_object)
# Check if compiled, and attach if it did
compiled = glGetObjectParameterivARB(shader_object, GL_OBJECT_COMPILE_STATUS_ARB)
if compiled:
glAttachObjectARB(self.m_program, shader_object)
# Delete the object (glAttachObjectARB makes a copy)
glDeleteObjectARB(shader_object)
# print the gl error log
self.PrintGLError()
def link(self):
"""
Links the shaders together.
"""
# clear error indicator
glGetError()
glLinkProgramARB(self.m_program)
self.PrintInfoLog("link", self.m_program)
linked = glGetObjectParameterivARB(self.m_program, GL_OBJECT_LINK_STATUS_ARB)
if not linked:
print "Shader failed to link"
return
glValidateProgramARB(self.m_program)
valid = glGetObjectParameterivARB(self.m_program, GL_OBJECT_VALIDATE_STATUS_ARB)
if not valid:
print "Shader failed to validate"
return
def activate(self, rasty, cachingInfo, mat):
self.pass_no+=1
if (self.pass_no == 1):
glDisable(GL_COLOR_MATERIAL)
glUseProgramObjectARB(self.m_program)
return True
glEnable(GL_COLOR_MATERIAL)
glUseProgramObjectARB(0)
self.pass_no = 0
return False
obj = GameLogic.getCurrentController().getOwner()
mesh = obj.getMesh(0)
for mat in mesh.materials:
mat.setCustomMaterial(MyMaterial())
print mat.texture
Instance Methods
updateTexture(tface,
rasty)
Updates a realtime animation.
triangle
Mesh data with this material is triangles.
boolean
zsort
Transparent polygons in meshes with this material will be sorted back
to front before rendering.
Method Details
updateTexture(tface,
rasty)
Updates a realtime animation.
Parameters:
tface (CObject) - Texture face (eg mat.tface)
rasty (CObject) - Rasterizer
setTexture(tface)
Sets texture render state.
Example:
mat.setTexture(mat.tface)
Parameters:
tface (CObject) - Texture face
activate(rasty,
cachingInfo)
Sets material parameters for this object for rendering.
Material Parameters set:
Texture
Backface culling
Line drawing
Specular Colour
Shininess
Diffuse Colour
Polygon Offset.
Parameters:
rasty (CObject) - Rasterizer instance.
cachingInfo (CObject) - Material cache instance.
setCustomMaterial(material)
Sets the material state setup object.
Using this method, you can extend or completely replace the gameengine
material to do your own advanced multipass effects.
Use this method to register your material class. Instead of the
normal material, your class's activate method will be called just before
rendering the mesh. This should setup the texture, material, and any
other state you would like. It should return True to render the mesh, or
False if you are finished. You should clean up any state Blender does
not set before returning False.
Activate Method Definition:
def activate(self, rasty, cachingInfo, material):
Example:
class PyMaterial:
def __init__(self):
self.pass_no = -1
def activate(self, rasty, cachingInfo, material):
# Activate the material here.
#
# The activate method will be called until it returns False.
# Every time the activate method returns True the mesh will
# be rendered.
#
# rasty is a CObject for passing to material.updateTexture()
# and material.activate()
# cachingInfo is a CObject for passing to material.activate()
# material is the KX_PolygonMaterial instance this material
# was added to
# default material properties:
self.pass_no += 1
if self.pass_no == 0:
material.activate(rasty, cachingInfo)
# Return True to do this pass
return True
# clean up and return False to finish.
self.pass_no = -1
return False
# Create a new Python Material and pass it to the renderer.
mat.setCustomMaterial(PyMaterial())
Parameters:
material (instance) - The material object.
Instance Variable Details
diffuse
The diffuse colour of the material. black = [0.0, 0.0, 0.0] white =
[1.0, 1.0, 1.0]
Type:
list [r, g, b]
drawingmode
Drawing mode for the material.
2 (drawingmode & 4) Textured
4 (drawingmode & 16) Light
14 (drawingmode & 16384) 3d Polygon Text
Type:
bitfield
shininess
The shininess (specular exponent) of the material. 0.0 <= shininess
<= 128.0
Type:
float
specular
The specular colour of the material. black = [0.0, 0.0, 0.0] white =
[1.0, 1.0, 1.0]
Type:
list [r, g, b]
specularity
The amount of specular of the material. 0.0 <= specularity <= 1.0
Type:
float
transparent
This material is transparent. All meshes with this material will be
rendered after non transparent meshes from back to front.
Type:
boolean
triangle
Mesh data with this material is triangles. It's probably not safe to
change this.
Type:
boolean
zsort
Transparent polygons in meshes with this material will be sorted back to
front before rendering. Non-Transparent polygons will be sorted front to
back before rendering.
getTouchMaterial()
DEPRECATED: use the useMaterial property Returns KX_TRUE if this
sensor looks for a specific material, KX_FALSE if it looks for a
specific property.
(Inherited from KX_TouchSensor.KX_TouchSensor)
getUseNegPulseMode()
True if the sensor is in negative pulse mode.
(Inherited from SCA_ISensor.SCA_ISensor)
getUsePosPulseMode()
True if the sensor is in positive pulse mode.
(Inherited from SCA_ISensor.SCA_ISensor)
isPositive()
True if this sensor brick is in a positive state.
(Inherited from SCA_ISensor.SCA_ISensor)
isTriggered()
True if this sensor brick has triggered the current controller.
(Inherited from SCA_ISensor.SCA_ISensor)
reset()
Reset sensor internal state, effect depends on the type of sensor and
settings.
(Inherited from SCA_ISensor.SCA_ISensor)
angle
The angle of the cone (in degrees) with which to test.
int from 0 to 5 KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y,
KX_RADAR_AXIS_POS_Z, KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y,
KX_RADAR_AXIS_NEG_Z
axis
The axis on which the radar cone is cast
list of floats [x, y, z]
coneOrigin
The origin of the cone with which to test.
list of floats [x, y, z]
coneTarget
The center of the bottom face of the cone with which to test.
float
distance
The near sensor activates when an object is within this distance.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
int from 0 to 5 KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y,
KX_RAY_AXIS_POS_Z, KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y,
KX_RAY_AXIS_NEG_Z
axis
The axis the ray is pointing on.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
useMaterial
Whether or not to look for a material (false = property)
boolean
useNegPulseMode
Flag to turn negative pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
boolean
usePosPulseMode
Flag to turn positive pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
boolean
useXRay
Whether or not to use XRay.
Method Details
getHitObject()
DEPRECATED: Use the hitObject property instead. Returns the game
object that was hit by this ray.
Returns: KX_GameObject
getHitPosition()
DEPRECATED: Use the hitPosition property instead. Returns the position
(in worldcoordinates) where the object was hit by this ray.
Returns: list [x, y, z]
getHitNormal()
DEPRECATED: Use the hitNormal property instead. Returns the normal (in
worldcoordinates) of the object at the location where the object was hit
by this ray.
Returns: list [nx, ny, nz]
getRayDirection()
DEPRECATED: Use the rayDirection property instead. Returns the
direction from the ray (in worldcoordinates)
Returns: list [dx, dy, dz]
Instance Variable Details
hitNormal
The normal (in worldcoordinates) of the object at the location where the
object was hit by the ray. (Read-only)
Type:
list [x, y, z]
hitObject
The game object that was hit by the ray. (Read-only)
Type:
KX_GameObject
hitPosition
The position (in worldcoordinates) where the object was hit by the ray.
(Read-only)
Type:
list [x, y, z]
rayDirection
The direction from the ray (in worldcoordinates). (Read-only)
Warning:
An Add Object actuator will be ignored if at game start, the linked
object doesn't exist (or is empty) or the linked object is in an
active layer.
This will genereate a warning in the console:
ERROR: GameObject OBName has a AddObjectActuator
ActuatorName without object (in 'nonactive'
layer)
Instance Methods
setObject(object)
DEPRECATED: use the object property Sets the game object to add.
string, KX_GameObject or None if no object is set
getObject(name_only=0)
DEPRECATED: use the object property Returns the name of the game
object to be added.
setTime(time)
DEPRECATED: use the time property Sets the lifetime of added objects,
in frames.
integer
getTime()
DEPRECATED: use the time property Returns the lifetime of the added
object, in frames.
setLinearVelocity(vx,
vy,
vz)
DEPRECATED: use the linearVelocity property Sets the initial linear
velocity of added objects.
list [vx, vy, vz]
getLinearVelocity()
DEPRECATED: use the linearVelocity property Returns the initial
linear velocity of added objects.
setAngularVelocity(vx,
vy,
vz)
DEPRECATED: use the angularVelocity property Sets the initial angular
velocity of added objects.
list [vx, vy, vz]
getAngularVelocity()
DEPRECATED: use the angularVelocity property Returns the initial
angular velocity of added objects.
angularVelocity
the initial angular velocity of added objects.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
list [vx, vy, vz]
linearVelocity
the initial linear velocity of added objects.
KX_GameObject or None
object
the object this actuator adds.
KX_GameObject or None
objectLastCreated
the last added object from this actuator (read only).
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
float
mass
the mass value for the KX_DYN_SET_MASS operation
integer
operation
the type of operation of the actuator, 0-4 KX_DYN_RESTORE_DYNAMICS,
KX_DYN_DISABLE_DYNAMICS, KX_DYN_ENABLE_RIGID_BODY,
KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
# Level-of-detail
# Switch a game object's mesh based on its depth in the camera view.
# +----------+ +-----------+ +-------------------------------------+
# | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
# +----------+ +-----------+ +-------------------------------------+
import GameLogic
# List detail meshes here
# Mesh (name, near, far)
# Meshes overlap so that they don't 'pop' when on the edge of the distance.
meshes = ((".Hi", 0.0, -20.0),
(".Med", -15.0, -50.0),
(".Lo", -40.0, -100.0)
)
co = GameLogic.getCurrentController()
obj = co.getOwner()
act = co.getActuator("LOD." + obj.name)
cam = GameLogic.getCurrentScene().active_camera
def Depth(pos, plane):
return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
# Depth is negative and decreasing further from the camera
depth = Depth(obj.position, cam.world_to_camera[2])
newmesh = None
curmesh = None
# Find the lowest detail mesh for depth
for mesh in meshes:
if depth < mesh[1] and depth > mesh[2]:
newmesh = mesh
if "ME" + obj.name + mesh[0] == act.getMesh():
curmesh = mesh
if newmesh != None and "ME" + obj.name + newmesh[0] != act.getMesh():
# The mesh is a different mesh - switch it.
# Check the current mesh is not a better fit.
if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
act.setMesh(obj.getName() + newmesh[0])
GameLogic.addActiveActuator(act, True)
Warning:
Replace mesh actuators will be ignored if at game start, the named
mesh doesn't exist.
This will generate a warning in the console:
ERROR: GameObject OBName ReplaceMeshActuator
ActuatorName without object
Instance Methods
setMesh(name)
DEPRECATED: Use the mesh property instead.
string or None
getMesh()
DEPRECATED: Use the mesh property instead.
None
instantReplaceMesh()
Immediately replace mesh without delay.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
DEPRECATED: Use the mesh property instead. Sets the name of the mesh
that will replace the current one. When the name is None it will unset
the mesh value so no action is taken.
Parameters:
name (string or None)
getMesh()
DEPRECATED: Use the mesh property instead. Returns the name of the
mesh that will replace the current one.
Returns None if no mesh has been scheduled to be added.
The activity culling stuff is supposed to disable logic bricks when
their owner gets too far from the active camera. It was taken from some
code lurking at the back of KX_Scene - who knows what it does!
Example:
import GameLogic
# get the scene
scene = GameLogic.getCurrentScene()
# print all the objects in the scene
for obj in scene.objects:
print obj.name
# get an object named 'Cube'
obj = scene.objects["OBCube"]
# get the first object in the scene.
obj = scene.objects[0]
Example:
# Get the depth of an object in the camera view.
import GameLogic
obj = GameLogic.getCurrentController().getOwner()
cam = GameLogic.getCurrentScene().active_camera
# Depth is negative and decreasing further from the camera
depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
The startSound(), pauseSound() and stopSound() do not require the actuator to be activated
- they act instantly provided that the actuator has been activated once
at least.
Instance Methods
setFilename(filename)
DEPRECATED: Use the filename property instead.
string
getFilename()
DEPRECATED: Use the filename property instead.
setGain(gain)
DEPRECATED: Use the volume property instead Sets the gain (volume) of
the sound
float
getGain()
DEPRECATED: Use the volume property instead.
setPitch(pitch)
DEPRECATED: Use the pitch property instead.
float
getPitch()
DEPRECATED: Use the pitch property instead.
setRollOffFactor(rolloff)
DEPRECATED: Use the rollOffFactor property instead.
float
getRollOffFactor()
DEPRECATED: Use the rollOffFactor property instead.
setLooping(loop)
DEPRECATED: Use the looping property instead.
integer
getLooping()
DEPRECATED: Use the looping property instead.
setPosition(x,
y,
z)
DEPRECATED: Use the position property instead.
setVelocity(vx,
vy,
vz)
DEPRECATED: Use the velocity property instead.
setOrientation(o11,
o12,
o13,
o21,
o22,
o23,
o31,
o32,
o33)
DEPRECATED: Use the orientation property instead.
setType(mode)
DEPRECATED: Use the type property instead.
integer
getType()
DEPRECATED: Use the type property instead.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
string
filename
Sets the filename of the sound this actuator plays.
Sets the orientation of the sound. When setting the orientation you can
also use quaternion [float,float,float,float] or euler angles
[float,float,float]
Type:
3x3 matrix [[float]]
rollOffFactor
Sets the roll off factor. Rolloff defines the rate of attenuation as the
sound gets further away.
Type:
float
type
Sets the operation mode of the actuator. You can use one of the following
constant:
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
integer
mask
value that defines the bits that will be modified by the operation.
integer
operation
type of bit operation to be applied on object state mask.
DEPRECATED: Use the operation property instead. Set the type of bit
operation to be applied on object state mask. Use setMask() to specify
the bits that will be modified.
Parameters:
op (integer) - bit operation (0=Copy, 1=Add, 2=Substract, 3=Invert)
setMask(mask)
DEPRECATED: Use the mask property instead. Set the value that defines
the bits that will be modified by the operation. The bits that are 1 in
the value will be updated in the object state, the bits that are 0 are
will be left unmodified expect for the Copy operation which copies the
value to the object state.
Parameters:
mask (integer) - bits that will be modified
Instance Variable Details
mask
value that defines the bits that will be modified by the operation. The
bits that are 1 in the mask will be updated in the object state, the bits
that are 0 are will be left unmodified expect for the Copy operation
which copies the mask to the object state
Type:
integer
operation
type of bit operation to be applied on object state mask. You can use one
of the following constant:
KX_STATE_OP_CPY (0) : Copy state mask
KX_STATE_OP_SET (1) : Add bits to state mask
KX_STATE_OP_CLR (2) : Substract bits to state mask
getHitObjectList()
DEPRECATED: use the objectHitList property Returns a list of all
objects hit in the last frame.
getTouchMaterial()
DEPRECATED: use the useMaterial property Returns KX_TRUE if this
sensor looks for a specific material, KX_FALSE if it looks for a
specific property.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
useMaterial
Determines if the sensor is looking for a property or material.
boolean
useNegPulseMode
Flag to turn negative pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
boolean
usePosPulseMode
Flag to turn positive pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
Method Details
setProperty(name)
DEPRECATED: use the property property Set the property or material to
collide with. Use setTouchMaterial() to switch between properties and
materials.
Parameters:
name (string)
getProperty()
DEPRECATED: use the property property Returns the property or material
to collide with. Use getTouchMaterial() to find out whether this sensor
looks for properties or materials. (deprecated)
Returns: string
getHitObject()
DEPRECATED: use the objectHit property Returns the last object hit by
this touch sensor. (deprecated)
DEPRECATED: use the useMaterial property Returns KX_TRUE if this
sensor looks for a specific material, KX_FALSE if it looks for a specific
property. (deprecated)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
pos (list [x, y, z]) - the new position for this vertex in local coordinates.
getUV()
Gets the UV (texture) coordinates of this vertex.
Returns: list [u, v]
this vertexes UV (texture) coordinates.
setUV(uv)
Sets the UV (texture) coordinates of this vertex.
Parameters:
uv (list [u, v])
getUV2()
Gets the 2nd UV (texture) coordinates of this vertex.
Returns: list [u, v]
this vertexes UV (texture) coordinates.
setUV2(uv)
Sets the 2nd UV (texture) coordinates of this vertex.
Parameters:
uv (list [u, v])
getRGBA()
Gets the colour of this vertex.
The colour is represented as four bytes packed into an integer value.
The colour is packed as RGBA.
Since Python offers no way to get each byte without shifting, you must
use the struct module to access colour in an machine independent way.
Because of this, it is suggested you use the r, g, b and a attributes
or the colour attribute instead.
Example:
import struct;
col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
# col = (r, g, b, a)
# black = ( 0, 0, 0, 255)
# white = (255, 255, 255, 255)
Returns: integer
packed colour. 4 byte integer with one byte per colour channel in
RGBA format.
setRGBA(col)
Sets the colour of this vertex.
See getRGBA() for the format of col, and its relevant problems. Use
the r, g, b and a attributes or the colour attribute instead.
setRGBA() also accepts a four component list as argument col. The
list represents the colour as [r, g, b, a] with black = [0.0, 0.0, 0.0,
1.0] and white = [1.0, 1.0, 1.0, 1.0]
Example:
v.setRGBA(0xff0000ff) # Red
v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
Parameters:
col (integer or list [r, g, b, a]) - the new colour of this vertex in packed RGBA format.
getNormal()
Gets the normal vector of this vertex.
Returns: list [nx, ny, nz]
normalised normal vector.
setNormal(normal)
Sets the normal vector of this vertex.
Parameters:
normal (sequence of floats [r, g, b]) - the new normal of this vertex.
Instance Variable Details
a
The alpha component of the vertex colour. 0.0 <= a <= 1.0
Type:
float
b
The blue component of the vertex colour. 0.0 <= b <= 1.0
Type:
float
colour
The colour of the vertex. Black = [0.0, 0.0, 0.0, 1.0], White = [1.0,
1.0, 1.0, 1.0]
Type:
list [r, g, b, a]
g
The green component of the vertex colour. 0.0 <= g <= 1.0
Type:
float
r
The red component of the vertex colour. 0.0 <= r <= 1.0
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
boolean
occlusion
whether the actuator makes its parent object an occluder or not
# 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
list [x, y]
getScreenPosition(arg)
Gets the position of an object projected on screen space.
3d vector
getScreenVect(x,
y)
Gets the vector from the camera position in the screen coordinate
direction.
the first object hit or None if no object or object does not
match prop
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 .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.
Parameters:
filename (string)
showMouse(visible)
Enables or disables the operating system mouse cursor.
Parameters:
visible (boolean)
setMousePosition(x,
y)
Sets the mouse cursor position.
Parameters:
y (integer)
x (integer)
setBackgroundColor(rgba)
Sets the window background colour.
Parameters:
rgba (list [r, g, b, a])
setMistColor(rgb)
Sets the mist colour.
Parameters:
rgb (list [r, g, b])
setMistStart(start)
Sets the mist start value. Objects further away than start will have
mist applied to them.
Parameters:
start (float)
setMistEnd(end)
Sets the mist end value. Objects further away from this will be
coloured solid with the colour set by setMistColor().
Parameters:
end (float)
setEyeSeparation(eyesep)
Sets the eye separation for stereo mode.
Parameters:
eyesep (float) - The distance between the left and right eye.
setFocalLength(focallength)
Sets the focal length for stereo mode.
Parameters:
focallength (float) - The focal length.
setMaterialMode(mode)
Set the material mode to use for OpenGL rendering.
The following properties don't have an immediate effect. You must
active the actuator to get the result. The actuator is not persistent: it
automatically stops itself after setting up the filter but the filter
remains active. To stop a filter you must activate the actuator with
'type' set to RAS_2DFILTER_DISABLED or RAS_2DFILTER_NOFILTER.
disableMotionBlur
action on motion blur: 0=enable, 1=disable
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
passNb
order number of filter in the stack of 2D filters.
string
shaderText
shader source code for custom shader
integer
type
type of 2D filter, use one of the following constants:
RAS_2DFILTER_ENABLED (-2) : enable the filter that was
previously disabled RAS_2DFILTER_DISABLED (-1) : disable the
filter that is currently active RAS_2DFILTER_NOFILTER (0) :
disable and destroy the filter that is currently active
RAS_2DFILTER_MOTIONBLUR (1) : create and enable preset filters
RAS_2DFILTER_BLUR (2) RAS_2DFILTER_SHARPEN (3)
RAS_2DFILTER_DILATION (4) RAS_2DFILTER_EROSION (5)
RAS_2DFILTER_LAPLACIAN (6) RAS_2DFILTER_SOBEL (7)
RAS_2DFILTER_PREWITT (8) RAS_2DFILTER_GRAYSCALE (9)
RAS_2DFILTER_SEPIA (10) RAS_2DFILTER_INVERT (11)
RAS_2DFILTER_CUSTOMFILTER (12) : customer filter, the code code is
set via shaderText property
float (0.0-100.0)
value
argument for motion blur filter
Instance Variable Details
passNb
order number of filter in the stack of 2D filters. Filters are executed
in increasing order of passNb. Only be one filter can be defined per
passNb.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
Actuator sensor detect change in actuator state of the parent object.
It generates a positive pulse if the corresponding actuator is activated
and a negative pulse if the actuator is deactivated.
Properties:
Instance Methods
string
getActuator()
DEPRECATED: use the actuator property Return the Actuator with which
the sensor operates.
setActuator(name)
DEPRECATED: use the actuator property Sets the Actuator with which to
operate.
actuator
the name of the actuator that the sensor is monitoring.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
The Delay sensor generates positive and negative triggers at precise
time, expressed in number of frames. The delay parameter defines the
length of the initial OFF period. A positive trigger is generated at the
end of this period. The duration parameter defines the length of the ON
period following the OFF period. There is a negative trigger at the end
of the ON period. If duration is 0, the sensor stays ON and there is no
negative trigger. The sensor runs the OFF-ON cycle once unless the repeat
option is set: the OFF-ON cycle repeats indefinately (or the OFF cycle if
duration is 0). Use SCA_ISensor::reset() at any time to restart
sensor.
Properties:
Instance Methods
setDelay(delay)
DEPRECATED: use the delay property Set the initial delay before the
positive trigger.
setDuration(duration)
DEPRECATED: use the duration property Set the duration of the ON
pulse after initial delay and the generation of the positive trigger.
setRepeat(repeat)
DEPRECATED: use the repeat property Set if the sensor repeat mode.
integer
getDelay()
DEPRECATED: use the delay property Return the delay parameter value.
integer
getDuration()
DEPRECATED: use the duration property Return the duration parameter
value
KX_TRUE or KX_FALSE
getRepeat()
DEPRECATED: use the repeat property Return the repeat parameter value
delay
length of the initial OFF period as number of frame, 0 for immediate
trigger.
integer
duration
length of the ON period in number of frame after the initial OFF
period.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
useNegPulseMode
Flag to turn negative pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
boolean
usePosPulseMode
Flag to turn positive pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
Method Details
setDelay(delay)
DEPRECATED: use the delay property Set the initial delay before the
positive trigger.
Parameters:
delay (integer) - length of the initial OFF period as number of frame, 0 for
immediate trigger
setDuration(duration)
DEPRECATED: use the duration property Set the duration of the ON pulse
after initial delay and the generation of the positive trigger. If
duration is greater than 0, a negative trigger is sent at the end of the
ON pulse.
Parameters:
duration (integer) - length of the ON period in number of frame after the initial OFF
period
setRepeat(repeat)
DEPRECATED: use the repeat property Set if the sensor repeat mode.
Parameters:
repeat (integer) - 1 if the OFF-ON cycle should be repeated indefinately, 0 if it
should run once.
Instance Variable Details
duration
length of the ON period in number of frame after the initial OFF period.
If duration is greater than 0, a negative trigger is sent at the end of
the ON pulse.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
int
frequency
The frequency for pulse mode sensors.
boolean
invert
Flag to set if this sensor activates on positive or negative events.
boolean
level
Flag to set whether to detect level or edge transition when entering
a state.
positive
True if this sensor brick is in a positive state.
boolean
triggered
True if this sensor brick is in a positive state.
boolean
useNegPulseMode
Flag to turn negative pulse mode on and off.
boolean
usePosPulseMode
Flag to turn positive pulse mode on and off.
Method Details
getFrequency()
The frequency for pulse mode sensors.
Returns: integer
the pulse frequency in 1/50 sec.
getLevel()
Returns whether this sensor is a level detector or a edge detector. It
makes a difference only in case of logic state transition (state
actuator). A level detector will immediately generate a pulse, negative
or positive depending on the sensor condition, as soon as the state is
activated. A edge detector will wait for a state change before generating
a pulse.
Returns: boolean
true if sensor is level sensitive, false if it is edge sensitive
reset()
Reset sensor internal state, effect depends on the type of sensor and
settings.
The sensor is put in its initial state as if it was just
activated.
setFrequency(freq)
Sets the frequency for pulse mode sensors.
Parameters:
freq (integer)
Returns:
the pulse frequency in 1/50 sec.
setInvert(invert)
Sets if this sensor activates on positive or negative events.
Parameters:
invert (boolean) - true if activates on negative events; false if activates on
positive events.
setLevel(level)
Set whether to detect level or edge transition when entering a
state.
Parameters:
level (boolean) - Detect level instead of edge? (KX_TRUE, KX_FALSE)
setUseNegPulseMode(pulse)
Sets negative pulse mode.
Parameters:
pulse (boolean) - If True, will activate negative pulse mode for this sensor.
setUsePosPulseMode(pulse)
Sets positive pulse mode.
Parameters:
pulse (boolean) - If True, will activate positive pulse mode for this sensor.
Instance Variable Details
level
Flag to set whether to detect level or edge transition when entering a
state. It makes a difference only in case of logic state transition
(state actuator). A level detector will immediately generate a pulse,
negative or positive depending on the sensor condition, as soon as the
state is activated. A edge detector will wait for a state change before
generating a pulse.
Type:
boolean
positive
True if this sensor brick is in a positive state. (Read only)
Type:
boolean
triggered
True if this sensor brick is in a positive state. (Read only)
axis
The axis this sensor reacts to, as a list of two values [axisIndex,
axisDirection] axisIndex: the axis index to use when detecting axis
movement, 1=primary directional control, 2=secondary directional
control.
int
axisSingle
(read-only) like axisValues but returns a single axis value that is
set by the sensor.
list of ints
axisValues
(read-only) The state of the joysticks axis as a list of values numAxis long.
integer
button
The button index the sensor reacts to (first button = 0).
boolean
connected
(read-only) True if a joystick is connected at this joysticks index.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
hat
The hat the sensor reacts to, as a list of two values: [hatIndex,
hatDirection] hatIndex: the hat index to use when detecting hat
movement, 1=primary hat, 2=secondary hat.
useNegPulseMode
Flag to turn negative pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
boolean
usePosPulseMode
Flag to turn positive pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
Method Details
getButtonStatus(buttonIndex)
Returns a bool of the current pressed state of the specified
button.
Parameters:
buttonIndex (integer) - the button index, 0=first button
Returns: bool
getIndex()
DEPRECATED: use the 'index' property. Returns the joystick index to
use (from 1 to 8).
Returns: integer
setIndex(index)
DEPRECATED: use the 'index' property. Sets the joystick index to
use.
Parameters:
index (integer) - The index of this joystick sensor, Clamped between 1 and 8.
Note:
This is only useful when you have more then 1 joystick connected to
your computer - multiplayer games.
getAxis()
DEPRECATED: use the 'axis' property. Returns the current axis this
sensor reacts to. See getAxisValue() for the current axis state.
Returns: list
2 values returned are [axisIndex, axisDirection] - see setAxis() for their purpose.
Note:
When the "All Events" toggle is set, this option has no
effect.
setAxis(axisIndex,
axisDirection)
DEPRECATED: use the 'axis' property.
Parameters:
axisIndex (integer from 1 to 2) - Set the axis index to use when detecting axis movement.
axisDirection (integer from 0 to 3) - Set the axis direction used for detecting motion. 0:right, 1:up,
2:left, 3:down.
Note:
When the "All Events" toggle is set, this option has no
effect.
getAxisValue()
DEPRECATED: use the 'axisPosition' property. Returns the state of the
joysticks axis. See differs to getAxis() returning the current state of the
joystick.
Returns: list
4 values, each spesifying the value of an axis between -32767 and
32767 depending on how far the axis is pushed, 0 for nothing.
The first 2 values are used by most joysticks and gamepads for
directional control. 3rd and 4th values are only on some
joysticks and can be used for arbitary controls.
Note:
Some gamepads only set the axis on and off like a button.
getThreshold()
DEPRECATED: use the 'threshold' property. Get the axis threshold. See
setThreshold() for details.
Returns: integer
setThreshold(threshold)
DEPRECATED: use the 'threshold' property. Set the axis threshold.
Parameters:
threshold (integer) - Joystick axis motion below this threshold wont trigger an event.
Use values between (0 and 32767), lower values are more
sensitive.
getButton()
DEPRECATED: use the 'button' property. Returns the button index the
sensor reacts to. See getButtonValue() for a list of pressed buttons.
Returns: integer
Note:
When the "All Events" toggle is set, this option has no
effect.
setButton(index)
DEPRECATED: use the 'button' property. Sets the button index the
sensor reacts to when the "All Events" option is not set.
Note:
When the "All Events" toggle is set, this option has no
effect.
getButtonValue()
DEPRECATED: use the 'getButtonActiveList' method. Returns a list
containing the indicies of the currently pressed buttons.
Returns: list
getHat()
DEPRECATED: use the 'hat' property. Returns the current hat direction
this sensor is set to. [hatNumber, hatDirection].
Returns: list
Note:
When the "All Events" toggle is set, this option has no
effect.
setHat(index,
direction)
DEPRECATED: use the 'hat' property. Sets the hat index the sensor
reacts to when the "All Events" option is not set.
Parameters:
index (integer)
getNumAxes()
DEPRECATED: use the 'numAxis' property. Returns the number of axes for
the joystick at this index.
Returns: integer
getNumButtons()
DEPRECATED: use the 'numButtons' property. Returns the number of
buttons for the joystick at this index.
Returns: integer
getNumHats()
DEPRECATED: use the 'numHats' property. Returns the number of hats for
the joystick at this index.
Returns: integer
isConnected()
DEPRECATED: use the 'connected' property. Returns True if a joystick
is detected at this joysticks index.
Returns: bool
Instance Variable Details
axis
The axis this sensor reacts to, as a list of two values [axisIndex,
axisDirection] axisIndex: the axis index to use when detecting axis
movement, 1=primary directional control, 2=secondary directional control.
axisDirection: 0=right, 1=up, 2=left, 3=down
Type:
[integer, integer]
axisSingle
(read-only) like axisValues but returns a single axis value that is set
by the sensor. Only use this for "Single Axis" type sensors
otherwise it will raise an error.
Type:
int
axisValues
(read-only) The state of the joysticks axis as a list of values numAxis long. each spesifying the value of an axis
between -32767 and 32767 depending on how far the axis is pushed, 0 for
nothing. The first 2 values are used by most joysticks and gamepads for
directional control. 3rd and 4th values are only on some joysticks and
can be used for arbitary controls. left:[-32767, 0, ...], right:[32767,
0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
Type:
list of ints
button
The button index the sensor reacts to (first button = 0). When the
"All Events" toggle is set, this option has no effect.
Type:
integer
hat
The hat the sensor reacts to, as a list of two values: [hatIndex,
hatDirection] hatIndex: the hat index to use when detecting hat movement,
1=primary hat, 2=secondary hat. hatDirection: 0-11
Type:
[integer, integer]
index
The joystick index to use (from 0 to 7). The first joystick is always 0.
Type:
integer
threshold
Axis threshold. Joystick axis motion below this threshold wont trigger an
event. Use values between (0 and 32767), lower values are more sensitive.
events
a list of pressed keys that have either been pressed, or just
released, or are active this frame.
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
type
type of check on the property: KX_PROPSENSOR_EQUAL(1),
KX_PROPSENSOR_NOTEQUAL(2), KX_PROPSENSOR_INTERVAL(3),
KX_PROPSENSOR_CHANGED(4), KX_PROPSENSOR_EXPRESSION(5)
boolean
useNegPulseMode
Flag to turn negative pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
boolean
usePosPulseMode
Flag to turn positive pulse mode on and off.
(Inherited from SCA_ISensor.SCA_ISensor)
string
value
the value with which the sensor compares to the value of the
property.
Method Details
getType()
DEPRECATED: use the type property Gets when to activate this
sensor.
Returns:
KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED, or
KX_PROPSENSOR_EXPRESSION.
setType(checktype)
DEPRECATED: use the type property Set the type of check to
perform.
Parameters:
checktype (KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED, or
KX_PROPSENSOR_EXPRESSION.)
getProperty()
DEPRECATED: use the property property Return the property with which
the sensor operates.
Returns: string
the name of the property this sensor is watching.
setProperty(name)
DEPRECATED: use the property property Sets the property with which to
operate. If there is no property of that name, this call is ignored.
Parameters:
name (string.)
getValue()
DEPRECATED: use the value property Return the value with which the
sensor compares to the value of the property.
Returns: string
the value of the property this sensor is watching.
setValue(value)
DEPRECATED: use the value property Set the value with which the sensor
operates. If the value is not compatible with the type of the property,
the subsequent action is ignored.
getScript()
DEPRECATED: use the script property Gets the Python script this
controller executes.
setScript(script)
Sets the Python script this controller executes.
int
getState()
DEPRECATED: use the state property Get the controllers state bitmask,
this can be used with the GameObject's state to test if the the
controller is active.
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
DEPRECATED: use the state property Get the controllers state bitmask,
this can be used with the GameObject's state to test if the the
controller is active. This for instance will always be true however you
could compare with a previous state to see when the state was activated.
GameLogic.getCurrentController().getState() &
GameLogic.getCurrentController().getOwner().getState()
Returns: int
Instance Variable Details
state
the controllers state bitmask. This can be used with the GameObject's
state to test if the controller is active.
distribution
distribution type: KX_RANDOMACT_BOOL_CONST,
KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM,
KX_RANDOMACT_INT_POISSON, KX_RANDOMACT_FLOAT_CONST,
KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
int
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
executePriority
This determines the order controllers are evaluated, and actuators
are activated (lower priority is executed first).
(Inherited from SCA_ILogicBrick.SCA_ILogicBrick)
KX_ObjectActuator.KX_ObjectActuator:
The object actuator ("Motion Actuator") applies force,
torque, displacement, angular displacement, velocity, or angular
velocity to an object.
crarr.png 0000644 0000000 0000000 00000000524 11174457205 011402 0 ustar root root ‰PNG
IHDR
e¢E ,tEXtCreation Time Tue 22 Aug 2006 00:43:10 -0500`X tIMEÖ)Ó}Ö pHYs  ÂnÐu> gAMA ±üa EPLTEÿÿÿÍð×ÏÀ€f4sW áÛЊrD`@ bCÜÕÈéäÜ–X{`,¯Ÿ€lN‡o@õóðª™xdEðí螊dÐÆ´”~TÖwÅv tRNS @æØf MIDATxÚc`@¼ì¼0&+š—Šˆ°»(’ˆ€ ;;/ðEXùØ‘?Ðn ƒª†— b;'ª+˜˜YÐ#œ (r<£" IEND®B`‚ epydoc.css 0000644 0000000 0000000 00000037227 11174457205 011572 0 ustar root root
/* Epydoc CSS Stylesheet
*
* This stylesheet can be used to customize the appearance of epydoc's
* HTML output.
*
*/
/* Default Colors & Styles
* - Set the default foreground & background color with 'body'; and
* link colors with 'a:link' and 'a:visited'.
* - Use bold for decision list terms.
* - The heading styles defined here are used for headings *within*
* docstring descriptions. All headings used by epydoc itself use
* either class='epydoc' or class='toc' (CSS styles for both
* defined below).
*/
body { background: #ffffff; color: #000000; }
p { margin-top: 0.5em; margin-bottom: 0.5em; }
a:link { color: #0000ff; }
a:visited { color: #204080; }
dt { font-weight: bold; }
h1 { font-size: +140%; font-style: italic;
font-weight: bold; }
h2 { font-size: +125%; font-style: italic;
font-weight: bold; }
h3 { font-size: +110%; font-style: italic;
font-weight: normal; }
code { font-size: 100%; }
/* N.B.: class, not pseudoclass */
a.link { font-family: monospace; }
/* Page Header & Footer
* - The standard page header consists of a navigation bar (with
* pointers to standard pages such as 'home' and 'trees'); a
* breadcrumbs list, which can be used to navigate to containing
* classes or modules; options links, to show/hide private
* variables and to show/hide frames; and a page title (using
*
). The page title may be followed by a link to the
* corresponding source code (using 'span.codelink').
* - The footer consists of a navigation bar, a timestamp, and a
* pointer to epydoc's homepage.
*/
h1.epydoc { margin: 0; font-size: +140%; font-weight: bold; }
h2.epydoc { font-size: +130%; font-weight: bold; }
h3.epydoc { font-size: +115%; font-weight: bold;
margin-top: 0.2em; }
td h3.epydoc { font-size: +115%; font-weight: bold;
margin-bottom: 0; }
table.navbar { background: #a0c0ff; color: #000000;
border: 2px groove #c0d0d0; }
table.navbar table { color: #000000; }
th.navbar-select { background: #70b0ff;
color: #000000; }
table.navbar a { text-decoration: none; }
table.navbar a:link { color: #0000ff; }
table.navbar a:visited { color: #204080; }
span.breadcrumbs { font-size: 85%; font-weight: bold; }
span.options { font-size: 70%; }
span.codelink { font-size: 85%; }
td.footer { font-size: 85%; }
/* Table Headers
* - Each summary table and details section begins with a 'header'
* row. This row contains a section title (marked by
* 'span.table-header') as well as a show/hide private link
* (marked by 'span.options', defined above).
* - Summary tables that contain user-defined groups mark those
* groups using 'group header' rows.
*/
td.table-header { background: #70b0ff; color: #000000;
border: 1px solid #608090; }
td.table-header table { color: #000000; }
td.table-header table a:link { color: #0000ff; }
td.table-header table a:visited { color: #204080; }
span.table-header { font-size: 120%; font-weight: bold; }
th.group-header { background: #c0e0f8; color: #000000;
text-align: left; font-style: italic;
font-size: 115%;
border: 1px solid #608090; }
/* Summary Tables (functions, variables, etc)
* - Each object is described by a single row of the table with
* two cells. The left cell gives the object's type, and is
* marked with 'code.summary-type'. The right cell gives the
* object's name and a summary description.
* - CSS styles for the table's header and group headers are
* defined above, under 'Table Headers'
*/
table.summary { border-collapse: collapse;
background: #e8f0f8; color: #000000;
border: 1px solid #608090;
margin-bottom: 0.5em; }
td.summary { border: 1px solid #608090; }
code.summary-type { font-size: 85%; }
table.summary a:link { color: #0000ff; }
table.summary a:visited { color: #204080; }
/* Details Tables (functions, variables, etc)
* - Each object is described in its own div.
* - A single-row summary table w/ table-header is used as
* a header for each details section (CSS style for table-header
* is defined above, under 'Table Headers').
*/
table.details { border-collapse: collapse;
background: #e8f0f8; color: #000000;
border: 1px solid #608090;
margin: .2em 0 0 0; }
table.details table { color: #000000; }
table.details a:link { color: #0000ff; }
table.details a:visited { color: #204080; }
/* Fields */
dl.fields { margin-left: 2em; margin-top: 1em;
margin-bottom: 1em; }
dl.fields dd ul { margin-left: 0em; padding-left: 0em; }
dl.fields dd ul li ul { margin-left: 2em; padding-left: 0em; }
div.fields { margin-left: 2em; }
div.fields p { margin-bottom: 0.5em; }
/* Index tables (identifier index, term index, etc)
* - link-index is used for indices containing lists of links
* (namely, the identifier index & term index).
* - index-where is used in link indices for the text indicating
* the container/source for each link.
* - metadata-index is used for indices containing metadata
* extracted from fields (namely, the bug index & todo index).
*/
table.link-index { border-collapse: collapse;
background: #e8f0f8; color: #000000;
border: 1px solid #608090; }
td.link-index { border-width: 0px; }
table.link-index a:link { color: #0000ff; }
table.link-index a:visited { color: #204080; }
span.index-where { font-size: 70%; }
table.metadata-index { border-collapse: collapse;
background: #e8f0f8; color: #000000;
border: 1px solid #608090;
margin: .2em 0 0 0; }
td.metadata-index { border-width: 1px; border-style: solid; }
table.metadata-index a:link { color: #0000ff; }
table.metadata-index a:visited { color: #204080; }
/* Function signatures
* - sig* is used for the signature in the details section.
* - .summary-sig* is used for the signature in the summary
* table, and when listing property accessor functions.
* */
.sig-name { color: #006080; }
.sig-arg { color: #008060; }
.sig-default { color: #602000; }
.summary-sig { font-family: monospace; }
.summary-sig-name { color: #006080; font-weight: bold; }
table.summary a.summary-sig-name:link
{ color: #006080; font-weight: bold; }
table.summary a.summary-sig-name:visited
{ color: #006080; font-weight: bold; }
.summary-sig-arg { color: #006040; }
.summary-sig-default { color: #501800; }
/* Subclass list
*/
ul.subclass-list { display: inline; }
ul.subclass-list li { display: inline; }
/* To render variables, classes etc. like functions */
table.summary .summary-name { color: #006080; font-weight: bold;
font-family: monospace; }
table.summary
a.summary-name:link { color: #006080; font-weight: bold;
font-family: monospace; }
table.summary
a.summary-name:visited { color: #006080; font-weight: bold;
font-family: monospace; }
/* Variable values
* - In the 'variable details' sections, each varaible's value is
* listed in a 'pre.variable' box. The width of this box is
* restricted to 80 chars; if the value's repr is longer than
* this it will be wrapped, using a backslash marked with
* class 'variable-linewrap'. If the value's repr is longer
* than 3 lines, the rest will be ellided; and an ellipsis
* marker ('...' marked with 'variable-ellipsis') will be used.
* - If the value is a string, its quote marks will be marked
* with 'variable-quote'.
* - If the variable is a regexp, it is syntax-highlighted using
* the re* CSS classes.
*/
pre.variable { padding: .5em; margin: 0;
background: #dce4ec; color: #000000;
border: 1px solid #708890; }
.variable-linewrap { color: #604000; font-weight: bold; }
.variable-ellipsis { color: #604000; font-weight: bold; }
.variable-quote { color: #604000; font-weight: bold; }
.variable-group { color: #008000; font-weight: bold; }
.variable-op { color: #604000; font-weight: bold; }
.variable-string { color: #006030; }
.variable-unknown { color: #a00000; font-weight: bold; }
.re { color: #000000; }
.re-char { color: #006030; }
.re-op { color: #600000; }
.re-group { color: #003060; }
.re-ref { color: #404040; }
/* Base tree
* - Used by class pages to display the base class hierarchy.
*/
pre.base-tree { font-size: 80%; margin: 0; }
/* Frames-based table of contents headers
* - Consists of two frames: one for selecting modules; and
* the other listing the contents of the selected module.
* - h1.toc is used for each frame's heading
* - h2.toc is used for subheadings within each frame.
*/
h1.toc { text-align: center; font-size: 105%;
margin: 0; font-weight: bold;
padding: 0; }
h2.toc { font-size: 100%; font-weight: bold;
margin: 0.5em 0 0 -0.3em; }
/* Syntax Highlighting for Source Code
* - doctest examples are displayed in a 'pre.py-doctest' block.
* If the example is in a details table entry, then it will use
* the colors specified by the 'table pre.py-doctest' line.
* - Source code listings are displayed in a 'pre.py-src' block.
* Each line is marked with 'span.py-line' (used to draw a line
* down the left margin, separating the code from the line
* numbers). Line numbers are displayed with 'span.py-lineno'.
* The expand/collapse block toggle button is displayed with
* 'a.py-toggle' (Note: the CSS style for 'a.py-toggle' should not
* modify the font size of the text.)
* - If a source code page is opened with an anchor, then the
* corresponding code block will be highlighted. The code
* block's header is highlighted with 'py-highlight-hdr'; and
* the code block's body is highlighted with 'py-highlight'.
* - The remaining py-* classes are used to perform syntax
* highlighting (py-string for string literals, py-name for names,
* etc.)
*/
pre.py-doctest { padding: .5em; margin: 1em;
background: #e8f0f8; color: #000000;
border: 1px solid #708890; }
table pre.py-doctest { background: #dce4ec;
color: #000000; }
pre.py-src { border: 2px solid #000000;
background: #f0f0f0; color: #000000; }
.py-line { border-left: 2px solid #000000;
margin-left: .2em; padding-left: .4em; }
.py-lineno { font-style: italic; font-size: 90%;
padding-left: .5em; }
a.py-toggle { text-decoration: none; }
div.py-highlight-hdr { border-top: 2px solid #000000;
border-bottom: 2px solid #000000;
background: #d8e8e8; }
div.py-highlight { border-bottom: 2px solid #000000;
background: #d0e0e0; }
.py-prompt { color: #005050; font-weight: bold;}
.py-more { color: #005050; font-weight: bold;}
.py-string { color: #006030; }
.py-comment { color: #003060; }
.py-keyword { color: #600000; }
.py-output { color: #404040; }
.py-name { color: #000050; }
.py-name:link { color: #000050 !important; }
.py-name:visited { color: #000050 !important; }
.py-number { color: #005000; }
.py-defname { color: #000060; font-weight: bold; }
.py-def-name { color: #000060; font-weight: bold; }
.py-base-class { color: #000060; }
.py-param { color: #000060; }
.py-docstring { color: #006030; }
.py-decorator { color: #804020; }
/* Use this if you don't want links to names underlined: */
/*a.py-name { text-decoration: none; }*/
/* Graphs & Diagrams
* - These CSS styles are used for graphs & diagrams generated using
* Graphviz dot. 'img.graph-without-title' is used for bare
* diagrams (to remove the border created by making the image
* clickable).
*/
img.graph-without-title { border: none; }
img.graph-with-title { border: 1px solid #000000; }
span.graph-title { font-weight: bold; }
span.graph-caption { }
/* General-purpose classes
* - 'p.indent-wrapped-lines' defines a paragraph whose first line
* is not indented, but whose subsequent lines are.
* - The 'nomargin-top' class is used to remove the top margin (e.g.
* from lists). The 'nomargin' class is used to remove both the
* top and bottom margin (but not the left or right margin --
* for lists, that would cause the bullets to disappear.)
*/
p.indent-wrapped-lines { padding: 0 0 0 7em; text-indent: -7em;
margin: 0; }
.nomargin-top { margin-top: 0; }
.nomargin { margin-top: 0; margin-bottom: 0; }
/* HTML Log */
div.log-block { padding: 0; margin: .5em 0 .5em 0;
background: #e8f0f8; color: #000000;
border: 1px solid #000000; }
div.log-error { padding: .1em .3em .1em .3em; margin: 4px;
background: #ffb0b0; color: #000000;
border: 1px solid #000000; }
div.log-warning { padding: .1em .3em .1em .3em; margin: 4px;
background: #ffffb0; color: #000000;
border: 1px solid #000000; }
div.log-info { padding: .1em .3em .1em .3em; margin: 4px;
background: #b0ffb0; color: #000000;
border: 1px solid #000000; }
h2.log-hdr { background: #70b0ff; color: #000000;
margin: 0; padding: 0em 0.5em 0em 0.5em;
border-bottom: 1px solid #000000; font-size: 110%; }
p.log { font-weight: bold; margin: .5em 0 .5em 0; }
tr.opt-changed { color: #000000; font-weight: bold; }
tr.opt-default { color: #606060; }
pre.log { margin: 0; padding: 0; padding-left: 1em; }
epydoc.js 0000644 0000000 0000000 00000024525 11174457205 011413 0 ustar root root function toggle_private() {
// Search for any private/public links on this page. Store
// their old text in "cmd," so we will know what action to
// take; and change their text to the opposite action.
var cmd = "?";
var elts = document.getElementsByTagName("a");
for(var i=0; i";
s += " ";
for (var i=0; i... ";
elt.innerHTML = s;
}
}
function toggle(id) {
elt = document.getElementById(id+"-toggle");
if (elt.innerHTML == "-")
collapse(id);
else
expand(id);
return false;
}
function highlight(id) {
var elt = document.getElementById(id+"-def");
if (elt) elt.className = "py-highlight-hdr";
var elt = document.getElementById(id+"-expanded");
if (elt) elt.className = "py-highlight";
var elt = document.getElementById(id+"-collapsed");
if (elt) elt.className = "py-highlight";
}
function num_lines(s) {
var n = 1;
var pos = s.indexOf("\n");
while ( pos > 0) {
n += 1;
pos = s.indexOf("\n", pos+1);
}
return n;
}
// Collapse all blocks that mave more than `min_lines` lines.
function collapse_all(min_lines) {
var elts = document.getElementsByTagName("div");
for (var i=0; i 0)
if (elt.id.substring(split, elt.id.length) == "-expanded")
if (num_lines(elt.innerHTML) > min_lines)
collapse(elt.id.substring(0, split));
}
}
function expandto(href) {
var start = href.indexOf("#")+1;
if (start != 0 && start != href.length) {
if (href.substring(start, href.length) != "-") {
collapse_all(4);
pos = href.indexOf(".", start);
while (pos != -1) {
var id = href.substring(start, pos);
expand(id);
pos = href.indexOf(".", pos+1);
}
var id = href.substring(start, href.length);
expand(id);
highlight(id);
}
}
}
function kill_doclink(id) {
var parent = document.getElementById(id);
parent.removeChild(parent.childNodes.item(0));
}
function auto_kill_doclink(ev) {
if (!ev) var ev = window.event;
if (!this.contains(ev.toElement)) {
var parent = document.getElementById(this.parentID);
parent.removeChild(parent.childNodes.item(0));
}
}
function doclink(id, name, targets_id) {
var elt = document.getElementById(id);
// If we already opened the box, then destroy it.
// (This case should never occur, but leave it in just in case.)
if (elt.childNodes.length > 1) {
elt.removeChild(elt.childNodes.item(0));
}
else {
// The outer box: relative + inline positioning.
var box1 = document.createElement("div");
box1.style.position = "relative";
box1.style.display = "inline";
box1.style.top = 0;
box1.style.left = 0;
// A shadow for fun
var shadow = document.createElement("div");
shadow.style.position = "absolute";
shadow.style.left = "-1.3em";
shadow.style.top = "-1.3em";
shadow.style.background = "#404040";
// The inner box: absolute positioning.
var box2 = document.createElement("div");
box2.style.position = "relative";
box2.style.border = "1px solid #a0a0a0";
box2.style.left = "-.2em";
box2.style.top = "-.2em";
box2.style.background = "white";
box2.style.padding = ".3em .4em .3em .4em";
box2.style.fontStyle = "normal";
box2.onmouseout=auto_kill_doclink;
box2.parentID = id;
// Get the targets
var targets_elt = document.getElementById(targets_id);
var targets = targets_elt.getAttribute("targets");
var links = "";
target_list = targets.split(",");
for (var i=0; i" +
target[0] + "";
}
// Put it all together.
elt.insertBefore(box1, elt.childNodes.item(0));
//box1.appendChild(box2);
box1.appendChild(shadow);
shadow.appendChild(box2);
box2.innerHTML =
"Which "+name+" do you want to see documentation for?" +
"
";
}
return false;
}
function get_anchor() {
var href = location.href;
var start = href.indexOf("#")+1;
if ((start != 0) && (start != href.length))
return href.substring(start, href.length);
}
function redirect_url(dottedName) {
// Scan through each element of the "pages" list, and check
// if "name" matches with any of them.
for (var i=0; i-m" or "-c";
// extract the portion & compare it to dottedName.
var pagename = pages[i].substring(0, pages[i].length-2);
if (pagename == dottedName.substring(0,pagename.length)) {
// We've found a page that matches `dottedName`;
// construct its URL, using leftover `dottedName`
// content to form an anchor.
var pagetype = pages[i].charAt(pages[i].length-1);
var url = pagename + ((pagetype=="m")?"-module.html":
"-class.html");
if (dottedName.length > pagename.length)
url += "#" + dottedName.substring(pagename.length+1,
dottedName.length);
return url;
}
}
}
help.html 0000644 0000000 0000000 00000025174 11174457206 011412 0 ustar root root
Help
This document contains the API (Application Programming Interface)
documentation for Blender GameEngine. Documentation for the Python
objects defined by the project is divided into separate pages for each
package, module, and class. The API documentation also includes two
pages containing information about the project as a whole: a trees
page, and an index page.
Object Documentation
Each Package Documentation page contains:
A description of the package.
A list of the modules and sub-packages contained by the
package.
A summary of the classes defined by the package.
A summary of the functions defined by the package.
A summary of the variables defined by the package.
A detailed description of each function defined by the
package.
A detailed description of each variable defined by the
package.
Each Module Documentation page contains:
A description of the module.
A summary of the classes defined by the module.
A summary of the functions defined by the module.
A summary of the variables defined by the module.
A detailed description of each function defined by the
module.
A detailed description of each variable defined by the
module.
Each Class Documentation page contains:
A class inheritance diagram.
A list of known subclasses.
A description of the class.
A summary of the methods defined by the class.
A summary of the instance variables defined by the class.
A summary of the class (static) variables defined by the
class.
A detailed description of each method defined by the
class.
A detailed description of each instance variable defined by the
class.
A detailed description of each class (static) variable defined
by the class.
Project Documentation
The Trees page contains the module and class hierarchies:
The module hierarchy lists every package and module, with
modules grouped into packages. At the top level, and within each
package, modules and sub-packages are listed alphabetically.
The class hierarchy lists every class, grouped by base
class. If a class has more than one base class, then it will be
listed under each base class. At the top level, and under each base
class, classes are listed alphabetically.
The Index page contains indices of terms and
identifiers:
The term index lists every term indexed by any object's
documentation. For each term, the index provides links to each
place where the term is indexed.
The identifier index lists the (short) name of every package,
module, class, method, function, variable, and parameter. For each
identifier, the index provides a short description, and a link to
its documentation.
The Table of Contents
The table of contents occupies the two frames on the left side of
the window. The upper-left frame displays the project
contents, and the lower-left frame displays the module
contents:
Project Contents...
API Documentation Frame
Module Contents ...
The project contents frame contains a list of all packages
and modules that are defined by the project. Clicking on an entry
will display its contents in the module contents frame. Clicking on a
special entry, labeled "Everything," will display the contents of
the entire project.
The module contents frame contains a list of every
submodule, class, type, exception, function, and variable defined by a
module or package. Clicking on an entry will display its
documentation in the API documentation frame. Clicking on the name of
the module, at the top of the frame, will display the documentation
for the module itself.
The "frames" and "no frames" buttons below the top
navigation bar can be used to control whether the table of contents is
displayed or not.
The Navigation Bar
A navigation bar is located at the top and bottom of every page.
It indicates what type of page you are currently viewing, and allows
you to go to related pages. The following table describes the labels
on the navigation bar. Note that not some labels (such as
[Parent]) are not displayed on all pages.
Label
Highlighted when...
Links to...
[Parent]
(never highlighted)
the parent of the current package
[Package]
viewing a package
the package containing the current object
[Module]
viewing a module
the module containing the current object
[Class]
viewing a class
the class containing the current object
[Trees]
viewing the trees page
the trees page
[Index]
viewing the index page
the index page
[Help]
viewing the help page
the help page
The "show private" and "hide private" buttons below
the top navigation bar can be used to control whether documentation
for private objects is displayed. Private objects are usually defined
as objects whose (short) names begin with a single underscore, but do
not end with an underscore. For example, "_x",
"__pprint", and "epydoc.epytext._tokenize"
are private objects; but "re.sub",
"__init__", and "type_" are not. However,
if a module defines the "__all__" variable, then its
contents are used to decide which objects are private.
A timestamp below the bottom navigation bar indicates when each
page was last updated.
All the other modules are accessible through the methods in
GameLogic.
See WhatsNew for
updates, changes and new functionality in the Game Engine Python
API.
Examples:
# To get the controller thats running this python script:
co = GameLogic.getCurrentController() # GameLogic is automatically imported
# To get the game object this controller is on:
obj = co.getOwner()
# To get a sensor linked to this controller.
# "sensorname" is the name of the sensor as defined in the Blender interface.
# +---------------------+ +--------+
# | Sensor "sensorname" +--+ Python +
# +---------------------+ +--------+
sens = co.getSensor("sensorname")
# To get a list of all sensors:
sensors = co.getSensors()
Most logic brick's methods are accessors for the properties
available in the logic buttons. Consult the logic bricks documentation
for more information on how each logic brick works.
There are also methods to access the current KX_Scene:
# Get the current scene
scene = GameLogic.getCurrentScene()
# Get the current camera
cam = scene.active_camera
Matricies as used by the game engine are row major:
body (string) - The body of the message (optional)
to (string) - The name of the object to send the message to (optional)
message_from (string) - The name of the object that the message is coming from (optional)
setGravity(gravity)
Sets the world gravity.
Parameters:
gravity (list [fx, fy, fz])
getSpectrum()
Returns a 512 point list from the sound card. This only works if the
fmod sound driver is being used.
Returns: list [float], len(getSpectrum()) == 512
stopDSP()
Stops the sound driver using DSP effects.
Only the fmod sound driver supports this. DSP can be computationally
expensive.
getLogicTicRate()
Gets the logic update frequency.
Returns: float
The logic frequency in Hz
setLogicTicRate(ticrate)
Sets the logic update frequency.
The logic update frequency is the number of times logic bricks are
executed every second. The default is 30 Hz.
Parameters:
ticrate (float) - The new logic update frequency (in Hz).
getPhysicsTicRate()
Gets the physics update frequency
Returns: float
The physics update frequency in Hz
setPhysicsTicRate(ticrate)
Sets the physics update frequency
The physics update frequency is the number of times the physics system
is executed every second. The default is 60 Hz.
Parameters:
ticrate (float) - The new update frequency (in Hz).
getAverageFrameRate()
Gets the estimated average framerate
Returns: float
The estimed average framerate in frames per second
expandPath(path)
Converts a blender internal path into a proper file system path.
Use / as directory separator in path You can use '//' at the start of
the string to define a relative path; Blender replaces that string by the
directory of the startup .blend or runtime file to make a full path name
(doesn't change during the game, even if you load other .blend). The
function also converts the directory separator to the local file system
format.
Parameters:
path (string) - The path string to be converted/expanded.
Returns: string
The converted string
getBlendFileList(path='//')
Returns a list of blend files in the same directory as the open blend
file, or from using the option argument.
Parameters:
path (string) - Optional directory argument, will be expanded (like expandPath)
into the full path.
When javascript is enabled, this page will redirect URLs of
the form redirect.html#dotted.name to the
documentation for the object with the given fully-qualified
dotted name.