PyObjectPlus base class of most other types in the Game Engine.
Test if the object has been freed by the game engine and is no longer valid.
Normally this is not a problem but when storing game engine data in the GameLogic module, KX_Scenes or other KX_GameObjects its possible to hold a reference to invalid data. Calling an attribute or method on an invalid object will raise a SystemError.
The invalid attribute allows testing for this case without exception handling.
Type : | boolean |
---|
This class is a basis for other classes.
The name of this CValue derived object (read-only).
Type : | string |
---|
This class has no python functions
Base class for all logic bricks.
This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
Type : | executePriority: int |
---|
The game object this logic brick is attached to (read-only).
Type : | KX_GameObject or None in exceptional cases. |
---|
The name of this logic brick (read-only).
Type : | string |
---|
The current keyboard.
The current mouse.
a dictionary containing the status of each mouse event. (read-only).
Type : | dictionary {keycode:status, ...} |
---|
The normalized x and y position of the mouse cursor.
Type : | list [x, y] |
---|
The visibility of the mouse cursor.
Type : | boolean |
---|
This class has no python functions
Base class for all sensor logic bricks.
Flag to turn positive pulse mode on and off.
Type : | boolean |
---|
Flag to turn negative pulse mode on and off.
Type : | boolean |
---|
The frequency for pulse mode sensors.
Type : | integer |
---|
level Option 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. note: mutually exclusive with tap, enabling will disable tap.
Type : | boolean |
---|
When enabled only sensors that are just activated will send a positive event, after this they will be detected as negative by the controllers. This will make a key thats held act as if its only tapped for an instant. note: mutually exclusive with level, enabling will disable level.
Type : | boolean |
---|
Flag to set if this sensor activates on positive or negative events.
Type : | boolean |
---|
True if this sensor brick is in a positive state. (read-only).
Type : | boolean |
---|
True if this sensor brick is in a positive state. (read-only).
Type : | boolean |
---|
The status of the sensor (read-only): can be one of these constants.
Type : | int |
---|
Note
This convenient attribute combines the values of triggered and positive attributes.
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.
Base class for all controller logic bricks.
The controllers state bitmask. This can be used with the GameObject’s state to test if the controller is active.
Type : | int bitmask |
---|
A list of sensors linked to this controller.
Type : | sequence supporting index/string lookups and iteration. |
---|
Note
The sensors are not necessarily owned by the same object.
Note
When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
A list of actuators linked to this controller.
Type : | sequence supporting index/string lookups and iteration. |
---|
Note
The sensors are not necessarily owned by the same object.
Note
When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
When set the controller executes always before all other controllers that dont have this set.
Type : | boolen |
---|
Note
Order of execution between high priority controllers is not guaranteed.
Base class for all actuator logic bricks.
Action Actuators apply an action to an actor.
The name of the action to set as the current action.
Type : | string |
---|
A list of channel names that may be used with setChannel and getChannel.
Type : | list of strings |
---|
Specifies the starting frame of the animation.
Type : | float |
---|
Specifies the ending frame of the animation.
Type : | float |
---|
Specifies the number of frames of animation to generate when making transitions between actions.
Type : | float |
---|
Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
Type : | integer |
---|
Sets the current frame for the animation.
Type : | float |
---|
Sets the property to be used in FromProp playback mode.
Type : | string |
---|
Sets the internal frame timer. This property must be in the range from 0.0 to blendIn.
Type : | float |
---|
The operation mode of the actuator. Can be one of these constants.
Type : | integer |
---|
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.
Type : | boolean |
---|
The name of the property that is set to the current frame number.
Type : | string |
---|
Alternative to the 2 arguments, 4 arguments (channel, matrix, loc, size, quat) are also supported.
Parameters: |
|
---|
Note
These values are relative to the bones rest position, currently the api has no way to get this info (which is annoying), but can be worked around by using bones with a rest pose that has no translation.
Parameters: | channel (string) – A string specifying the name of the bone channel. error raised if not in channelNames. |
---|---|
Returns: | (loc, size, quat) |
Return type: | tuple |
BL_Shader GLSL shaders.
TODO - Description
Set a uniform with a list of float values
Parameters: |
|
---|
Returns the fragment program.
Returns: | The fragment program. |
---|---|
Return type: | string |
Get the vertex program.
Returns: | The vertex program. |
---|---|
Return type: | string |
Check if the shader is valid.
Returns: | True if the shader is valid |
---|---|
Return type: | boolean |
Set attribute location. (The parameter is ignored a.t.m. and the value of “tangent” is always used.)
Parameters: | enum (integer) – attribute location value |
---|
Set the maximum number of passes. Not used a.t.m.
Parameters: | max_pass (integer) – the maximum number of passes |
---|
Set uniform texture sample index.
Parameters: |
|
---|
Set the vertex and fragment programs
Parameters: |
|
---|
Set a uniform with 1 float value.
Parameters: |
|
---|
Set a uniform with an integer value.
Parameters: |
|
---|
Set a uniform with 2 float values
Parameters: |
|
---|
Set a uniform with 2 integer values
Parameters: |
|
---|
Set a uniform with 3 float values.
Parameters: |
|
---|
Set a uniform with 3 integer values
Parameters: |
|
---|
Set a uniform with 4 float values.
Parameters: |
|
---|
Set a uniform with 4 integer values
Parameters: |
|
---|
Define a new uniform
Parameters: |
|
---|
Set a uniform with a 3x3 matrix value
Parameters: |
|
---|
Set a uniform with a 4x4 matrix value
Parameters: |
|
---|
Set a uniform with a list of integer values
Parameters: |
|
---|
Validate the shader object.
ShapeAction Actuators apply an shape action to an mesh object.
The name of the action to set as the current shape action.
Type : | string |
---|
Specifies the starting frame of the shape animation.
Type : | float |
---|
Specifies the ending frame of the shape animation.
Type : | float |
---|
Specifies the number of frames of animation to generate when making transitions between actions.
Type : | float |
---|
Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
Type : | integer |
---|
Sets the current frame for the animation.
Type : | float |
---|
Sets the property to be used in FromProp playback mode.
Type : | string |
---|
Sets the internal frame timer. This property must be in the range from 0.0 to blendin.
Type : | float |
---|
The operation mode of the actuator. Can be one of these constants.
Type : | integer |
---|
The name of the property that is set to the current frame number.
Type : | string |
---|
This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
As well as the normal index lookup (val= clist[i]), CListValue supports string lookups (val= scene.objects["Cube"])
Other operations such as len(clist), list(clist), clist[0:10] are also supported.
Add an item to the list (like pythons append)
Warning
Appending values to the list can cause crashes when the list is used internally by the game engine.
Count the number of instances of a value in the list.
Returns: | number of instances |
---|---|
Return type: | integer |
Return the index of a value in the list.
Returns: | The index of the value in the list. |
---|---|
Return type: | integer |
Reverse the order of the list.
Return the value matching key, or the default value if its not found.
Returns: | The key value or a default. |
---|
This is a funtion especially for the game engine to return a value with a spesific id.
Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
Example:
myObID=id(gameObject)
ob= scene.objects.from_id(myObID)
Where myObID is an int or long from the id function.
This has the advantage that you can store the id in places you could not store a gameObject.
Warning
The id is derived from a memory location and will be different each time the game engine starts.
KX_BlenderMaterial
Set the pixel color arithmetic functions.
Parameters: |
|
---|
Returns the material’s index.
Returns: | the material’s index |
---|---|
Return type: | integer |
Applies changes to a camera.
strength of of the camera following movement.
Type : | float |
---|
minimum distance to the target object maintained by the actuator.
Type : | float |
---|
maximum distance to stay from the target object.
Type : | float |
---|
height to stay above the target object.
Type : | float |
---|
axis this actuator is tracking, True=X, False=Y.
Type : | boolean |
---|
the object this actuator tracks.
Type : | KX_GameObject or None |
---|
A constraint actuator limits the position, rotation, distance or orientation of an object.
Time constant of the constraint expressed in frame (not use by Force field constraint).
Type : | integer |
---|
Time constant for the rotation expressed in frame (only for the distance constraint), 0 = use damp for rotation as well.
Type : | integer |
---|
The reference direction in world coordinate for the orientation constraint.
Type : | 3-tuple of float: (x, y, z) |
---|
Binary combination of these constants
Type : | integer |
---|
activation time of the actuator. The actuator disables itself after this many frame. If set to 0, the actuator is not limited in time.
Type : | integer |
---|
the name of the property or material for the ray detection of the distance constraint.
Type : | string |
---|
The lower bound of the constraint. For the rotation and orientation constraint, it represents radiant.
Type : | float |
---|
the target distance of the distance constraint.
Type : | float |
---|
the upper bound of the constraint. For rotation and orientation constraints, it represents radiant.
Type : | float |
---|
the length of the ray of the distance constraint.
Type : | float |
---|
type of constraint. Use one of the these constants
Type : | integer. |
---|
KX_ConstraintWrapper
Returns the contraint’s ID
Returns: | the constraint’s ID |
---|---|
Return type: | integer |
The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
the new .blend file to load.
Type : | string |
---|
The mode of this actuator. Can be on of these constants
Type : | Int |
---|
All game objects are derived from this class.
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 SystemError, if an object may have been removed since last accessing it use the invalid attribute to check.
The object’s name. (read-only).
Type : | string |
---|
The object’s mass
Type : | float |
---|
Note
The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0.
Enforces the object keeps moving at a minimum velocity.
Type : | float |
---|
Note
Applies to dynamic and rigid body objects only.
Note
A value of 0.0 disables this option.
Note
While objects are stationary the minimum velocity will not be applied.
Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
Type : | float |
---|
Note
Applies to dynamic and rigid body objects only.
Note
A value of 0.0 disables this option (rather then setting it stationary).
the object’s inertia vector in local coordinates. Read only.
Type : | list [ix, iy, iz] |
---|
The object’s parent object. (read-only).
Type : | KX_GameObject or None |
---|
visibility flag.
Type : | boolean |
---|
Note
Game logic will still run for invisible objects.
The object color of the object. [r, g, b, a]
Type : | mathutils.Vector |
---|
occlusion capability flag.
Type : | boolean |
---|
The object’s position. [x, y, z] On write: local position, on read: world position
Deprecated since version use: localPosition and worldPosition.
Type : | mathurils.Vector |
---|
The object’s orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector. On write: local orientation, on read: world orientation
Deprecated since version use: localOrientation and worldOrientation.
Type : | mathutils.Matrix |
---|
The object’s scaling factor. [sx, sy, sz] On write: local scaling, on read: world scaling
Deprecated since version use: localScale and worldScale.
Type : | mathutils.Vector |
---|
The object’s local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
Type : | mathutils.Matrix |
---|
The object’s world orientation. 3x3 Matrix.
Type : | mathutils.Matrix |
---|
The object’s local scaling factor. [sx, sy, sz]
Type : | mathutils.Vector |
---|
The object’s world scaling factor. Read-only. [sx, sy, sz]
Type : | mathutils.Vector |
---|
The object’s local position. [x, y, z]
Type : | mathutils.Vector |
---|
The object’s world position. [x, y, z]
Type : | mathutils.Vector |
---|
The object’s local linear velocity. [x, y, z]
Type : | mathutils.Vector |
---|
The object’s world linear velocity. [x, y, z]
type: mathutils.Vector
The object’s local angular velocity. [x, y, z]
type: mathutils.Vector
The object’s world angular velocity. [x, y, z]
type: mathutils.Vector
adjust the slowparent delay at runtime.
Type : | float |
---|
the game object’s state bitmask, using the first 30 bits, one bit must always be set.
Type : | int |
---|
a list meshes for this object.
Type : | list of KX_MeshProxy |
---|
Note
Most objects use only 1 mesh.
Note
Changes to this list will not update the KX_GameObject.
a sequence of SCA_ISensor objects with string/index lookups and iterator support.
Type : | list |
---|
Note
This attribute is experemental and may be removed (but probably wont be).
Note
Changes to this list will not update the KX_GameObject.
a sequence of SCA_IController objects with string/index lookups and iterator support.
Type : | list of SCA_ISensor |
---|
Note
This attribute is experemental and may be removed (but probably wont be).
Note
Changes to this list will not update the KX_GameObject.
a list of SCA_IActuator with string/index lookups and iterator support.
Type : | list |
---|
Note
This attribute is experemental and may be removed (but probably wont be).
Note
Changes to this list will not update the KX_GameObject.
get the objects internal python attribute dictionary for direct (faster) access.
Type : | dict |
---|
direct children of this object, (read-only).
Type : | CListValue of KX_GameObject‘s |
---|
all children of this object including childrens children, (read-only).
Type : | CListValue of KX_GameObject‘s |
---|
Delete this object, can be used in place of the EndObject Actuator.
The actual removal of the object from the scene is delayed.
Replace the mesh of this object with a new mesh. This works the same was as the actuator.
Parameters: |
|
---|
Sets the game object’s visible flag.
Parameters: |
|
---|
Sets the game object’s occlusion capability.
Parameters: |
|
---|
Aligns any of the game object’s axis along the given vector.
Parameters: |
|
---|
Returns the axis vector rotates by the objects worldspace orientation. This is the equivalent of multiplying the vector by the orientation matrix.
Parameters: | vect (3D Vector) – a vector to align the axis. |
---|---|
Returns: | The vector in relation to the objects rotation. |
Return type: | 3d vector. |
Sets the game object’s movement.
Parameters: |
|
---|
Sets the game object’s rotation.
Parameters: |
|
---|
Sets the game object’s force.
This requires a dynamic object.
Parameters: |
|
---|
Sets the game object’s torque.
This requires a dynamic object.
Parameters: |
|
---|
Gets the game object’s linear velocity.
This method returns the game object’s velocity through it’s centre of mass, ie no angular velocity component.
Parameters: | local (boolean) –
|
---|---|
Returns: | the object’s linear velocity. |
Return type: | list [vx, vy, vz] |
Sets the game object’s linear velocity.
This method sets game object’s velocity through it’s centre of mass, ie no angular velocity component.
This requires a dynamic object.
Parameters: |
|
---|
Gets the game object’s angular velocity.
Parameters: | local (boolean) –
|
---|---|
Returns: | the object’s angular velocity. |
Return type: | list [vx, vy, vz] |
Sets the game object’s angular velocity.
This requires a dynamic object.
Parameters: |
|
---|
Gets the game object’s velocity at the specified point.
Gets the game object’s velocity at the specified point, including angular components.
Parameters: | point (3D Vector) – optional point to return the velocity for, in local coordinates. |
---|---|
Returns: | the velocity at the specified point. |
Return type: | list [vx, vy, vz] |
Gets the game object’s reaction force.
The reaction force is the force applied to this object over the last simulation timestep. This also includes impulses, eg from collisions.
Returns: | the reaction force of this object. |
---|---|
Return type: | list [fx, fy, fz] |
Note
This is not implimented at the moment.
Applies an impulse to the game object.
This will apply the specified impulse to the game object at the specified point. If point != position, applyImpulse will also change the object’s angular momentum. Otherwise, only linear momentum will change.
Parameters: | point (the point to apply the impulse to (in world coordinates)) – the point to apply the impulse to (in world coordinates) |
---|
Suspends physics for this object.
Resumes physics for this object.
Note
The objects linear velocity will be applied from when the dynamics were suspended.
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.
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.
Sets this object’s parent. Control the shape status with the optional compound and ghost parameters:
In that case you can control if it should be ghost or not:
Parameters: |
|
---|
Note
If the object type is sensor, it stays ghost regardless of ghost parameter
Removes this objects parent.
Returns the user data object associated with this game object’s physics controller.
Gets a list of all property names.
Returns: | All property names for this object. |
---|---|
Return type: | list |
Parameters: | other (KX_GameObject or list [x, y, z]) – a point or another KX_GameObject to measure the distance to. |
---|---|
Returns: | distance to another object or point. |
Return type: | float |
Returns the vector and the distance to another object or point. The vector is normalized unless the distance is 0, in which a zero length vector is returned.
Parameters: | other (KX_GameObject or list [x, y, z]) – a point or another KX_GameObject to get the vector and distance to. |
---|---|
Returns: | (distance, globalVector(3), localVector(3)) |
Return type: | 3-tuple (float, 3-tuple (x, y, z), 3-tuple (x, y, z)) |
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: |
|
---|---|
Returns: | the first object hit or None if no object or object does not match prop |
Return type: |
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. if poly is 2, returns a 5-tuple with in addition a 2D vector with the UV mapping of the hit point as 5th element.
# shoot along the axis gun-gunAim (gunAim should be collision-free)
obj, point, normal = gun.rayCast(gunAim, None, 50)
if obj:
# do something
pass
The face paremeter determines the orientation of the normal.
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.
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: |
|
---|---|
Returns: | (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
|
Return type: |
|
Note
The ray ignores the object on which the method is called. It is casted from/to object center or explicit [x, y, z] points.
Set the objects collision margin.
Parameters: | margin (float) – the collision margin distance in blender units. |
---|
Note
If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
Sends a message.
Parameters: |
|
---|
Updates the physics system with the changed mesh.
If no arguments are given the physics mesh will be re-created from the first mesh assigned to the game object.
Parameters: |
|
---|---|
Returns: | True if reinstance succeeded, False if it failed. |
Return type: | boolean |
Note
If this object has instances the other instances will be updated too.
Note
The gameObject argument has an advantage that it can convert from a mesh with modifiers applied (such as subsurf).
Warning
Only triangle mesh type objects are supported currently (not convex hull)
Warning
If the object is a part of a combound object it will fail (parent or child)
Warning
Rebuilding the physics mesh can be slow, running many times per second will give a performance hit.
Return the value matching key, or the default value if its not found. :return: The key value or a default.
Plays an action.
Parameters: |
|
---|
Stop playing the action on the given layer.
Parameters: | layer (integer) – The layer to stop playing. |
---|
Gets the current frame of the action playing in the supplied layer.
Parameters: | layer (integer) – The layer that you want to get the frame from. |
---|---|
Returns: | The current frame of the action |
Return type: | float |
Set the current frame of the action playing in the supplied layer.
Parameters: |
|
---|
Checks to see if there is an action playing in the given layer.
Parameters: | layer (integer) – The layer to check for a playing action. |
---|---|
Returns: | Whether or not the action is playing |
Return type: | boolean |
IPO actuator activates an animation.
Start frame.
Type : | float |
---|
End frame.
Type : | float |
---|
Use this property to define the Ipo position.
Type : | string |
---|
Assign this property this action current frame number.
Type : | string |
---|
Play mode for the ipo. Can be on of these constants
Type : | integer |
---|
Apply Ipo as a global or local force depending on the local option (dynamic objects only).
Type : | boolean |
---|
Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag.
Type : | boolean |
---|
Let the ipo acts in local coordinates, used in Force and Add mode.
Type : | boolean |
---|
Update IPO on all children Objects as well.
Type : | boolean |
---|
A Light object.
# Turn on a red alert light.
import bge
co = bge.logic.getCurrentController()
light = co.owner
light.energy = 1.0
light.colour = [1.0, 0.0, 0.0]
The type of light - must be SPOT, SUN or NORMAL
The layer mask that this light affects object on.
Type : | bitfield |
---|
The brightness of this light.
Type : | float |
---|
The maximum distance this light can illuminate. (SPOT and NORMAL lights only).
Type : | float |
---|
The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Type : | list [r, g, b] |
---|
Synonym for colour.
The linear component of this light’s attenuation. (SPOT and NORMAL lights only).
Type : | float |
---|
The quadratic component of this light’s attenuation (SPOT and NORMAL lights only).
Type : | float |
---|
The cone angle of the spot light, in degrees (SPOT lights only).
Type : | float in [0 - 180]. |
---|
Specifies the intensity distribution of the spot light (SPOT lights only).
Type : | float in [0 - 1] |
---|
Note
Higher values result in a more focused light source.
A mesh object.
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.
The correct method of iterating over every KX_VertexProxy in a game object
from bge import logic
cont = logic.getCurrentController()
object = cont.owner
for mesh in object.meshes:
for material in mesh.materials:
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]
Type : | list of KX_BlenderMaterial or KX_PolygonMaterial types |
---|
Type : | integer |
---|
Type : | integer |
---|
Returns: | number of materials associated with this object |
---|---|
Return type: | integer |
Gets the name of the specified material.
Parameters: | matid (integer) – the specified material. |
---|---|
Returns: | the attached material name. |
Return type: | string |
Gets the name of the specified material’s texture.
Parameters: | matid (integer) – the specified material |
---|---|
Returns: | the attached material’s texture name. |
Return type: | string |
Gets the length of the vertex array associated with the specified material.
There is one vertex array for each material.
Parameters: | matid (integer) – the specified material |
---|---|
Returns: | the number of verticies in the vertex array. |
Return type: | integer |
Gets the specified vertex from the mesh object.
Parameters: |
|
---|---|
Returns: | a vertex object. |
Return type: |
Returns: | The number of polygon in the mesh. |
---|---|
Return type: | integer |
Gets the specified polygon from the mesh.
Parameters: | index (integer) – polygon number |
---|---|
Returns: | a polygon object. |
Return type: | PolyProxy |
Mouse Sensor logic brick.
current [x, y] coordinates of the mouse, in frame coordinates (pixels).
Type : | [integer, interger] |
---|
sensor mode.
Type : | integer
|
---|
Get the mouse button status.
Parameters: | button (int) – The code that represents the key you want to get the state of, use one of these constants |
---|---|
Returns: | The state of the given key, can be one of these constants |
Return type: | int |
The mouse focus sensor detects when the mouse is over the current game object.
The mouse focus sensor works by transforming the mouse coordinates from 2d device space to 3d space then raycasting away from the camera.
The worldspace source of the ray (the view position).
Type : | list (vector of 3 floats) |
---|
The worldspace target of the ray.
Type : | list (vector of 3 floats) |
---|
the last object the mouse was over.
Type : | KX_GameObject or None |
---|
The worldspace position of the ray intersecton.
Type : | list (vector of 3 floats) |
---|
the worldspace normal from the face at point of intersection.
Type : | list (normalized vector of 3 floats) |
---|
the UV coordinates at the point of intersection.
Type : | list (vector of 2 floats) |
---|
If the object has no UV mapping, it returns [0, 0].
The UV coordinates are not normalized, they can be < 0 or > 1 depending on the UV mapping.
When enabled, moving the mouse over a different object generates a pulse. (only used when the ‘Mouse Over Any’ sensor option is set).
Type : | boolean |
---|
Touch sensor detects collisions between objects.
The property or material to collide with.
Type : | string |
---|
Determines if the sensor is looking for a property or material. KX_True = Find material; KX_False = Find property.
Type : | boolean |
---|
When enabled, changes to the set of colliding objects generate a pulse.
Type : | boolean |
---|
The last collided object. (read-only).
Type : | KX_GameObject or None |
---|
A list of colliding objects. (read-only).
Type : | CListValue of KX_GameObject |
---|
A near sensor is a specialised form of touch sensor.
The near sensor activates when an object is within this distance.
Type : | float |
---|
The near sensor deactivates when the object exceeds this distance.
Type : | float |
---|
Message Actuator
Messages will only be sent to objects with the given property name.
Type : | string |
---|
The subject field of the message.
Type : | string |
---|
The body of the message.
Type : | string |
---|
Send a property instead of a regular body message.
Type : | boolean |
---|
The Message Sensor logic brick.
Currently only loopback (local) networks are supported.
The subject the sensor is looking for.
Type : | string |
---|
The number of messages received since the last frame. (read-only).
Type : | integer |
---|
The list of message subjects received. (read-only).
Type : | list of strings |
---|
The list of message bodies received. (read-only).
Type : | list of strings |
---|
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.
The force applied by the actuator.
Type : | list [x, y, z] |
---|
A flag specifying if the force is local.
Type : | boolean |
---|
The torque applied by the actuator.
Type : | list [x, y, z] |
---|
A flag specifying if the torque is local.
Type : | boolean |
---|
The displacement vector applied by the actuator.
Type : | list [x, y, z] |
---|
A flag specifying if the dLoc is local.
Type : | boolean |
---|
The angular displacement vector applied by the actuator
Type : | list [x, y, z] |
---|
Note
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.
A flag specifying if the dRot is local.
Type : | boolean |
---|
The linear velocity applied by the actuator.
Type : | list [x, y, z] |
---|
A flag specifying if the linear velocity is local.
Type : | boolean |
---|
Note
This is the target speed for servo controllers.
The angular velocity applied by the actuator.
Type : | list [x, y, z] |
---|
A flag specifying if the angular velocity is local.
Type : | boolean |
---|
The damping parameter of the servo controller.
Type : | short |
---|
The min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
Type : | list [min(float), max(float), bool] |
---|
The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
Type : | list [min(float), max(float), bool] |
---|
The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
Type : | list [min(float), max(float), bool] |
---|
The PID coefficients of the servo controller.
Type : | list of floats [proportional, integral, derivate] |
---|
The object that is used as reference to compute the velocity for the servo controller.
Type : | KX_GameObject or None |
---|
The parent actuator can set or remove an objects parent object.
the object this actuator sets the parent too.
Type : | KX_GameObject or None |
---|
The mode of this actuator.
Type : | integer from 0 to 1. |
---|
Whether the object shape should be added to the parent compound shape when parenting.
Effective only if the parent is already a compound shape.
Type : | boolean |
---|
Whether the object should be made ghost when parenting Effective only if the shape is not added to the parent compound shape.
Type : | boolean |
---|
KX_PhysicsObjectWrapper
Set the object to be active.
Parameters: | active (boolean) – set to True to be active |
---|
Set the angular velocity of the object.
Parameters: |
|
---|
Set the linear velocity of the object.
Parameters: |
|
---|
A polygon holds the index of the vertex forming the poylgon.
Note: The polygon attributes are read-only, you need to retrieve the vertex proxy if you want to change the vertex settings.
The name of polygon material, empty if no material.
Type : | string |
---|
The material of the polygon.
Type : | KX_PolygonMaterial or KX_BlenderMaterial |
---|
The texture name of the polygon.
Type : | string |
---|
The material index of the polygon, use this to retrieve vertex proxy from mesh proxy.
Type : | integer |
---|
vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
Type : | integer |
---|
vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
Type : | integer |
---|
vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
Type : | integer |
---|
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.
Type : | integer |
---|
visible state of the polygon: 1=visible, 0=invisible.
Type : | integer |
---|
collide state of the polygon: 1=receives collision, 0=collision free.
Type : | integer |
---|
Returns the polygon material name with MA prefix
Returns: | material name |
---|---|
Return type: | string |
Returns: | The polygon material |
---|---|
Return type: | KX_PolygonMaterial or KX_BlenderMaterial |
Returns: | The texture name |
---|---|
Return type: | string |
Returns the material bucket index of the polygon. This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from MeshProxy.
Returns: | the material index in the mesh |
---|---|
Return type: | integer |
Returns the number of vertex of the polygon.
Returns: | number of vertex, 3 or 4. |
---|---|
Return type: | integer |
Returns whether the polygon is visible or not
Returns: | 0=invisible, 1=visible |
---|---|
Return type: | boolean |
Returns whether the polygon is receives collision or not
Returns: | 0=collision free, 1=receives collision |
---|---|
Return type: | integer |
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 MeshProxy.
Parameters: |
|
---|---|
Returns: | mesh vertex index |
Return type: | integer |
Returns a mesh proxy
Returns: | mesh proxy |
---|---|
Return type: | MeshProxy |
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.
from bge import logic
vertex_shader = """
void main(void)
{
// original vertex position, no changes
gl_Position = ftransform();
// coordinate of the 1st texture channel
gl_TexCoord[0] = gl_MultiTexCoord0;
// coordinate of the 2nd texture channel
gl_TexCoord[1] = gl_MultiTexCoord1;
}
"""
fragment_shader ="""
uniform sampler2D color_0;
uniform sampler2D color_1;
uniform float factor;
void main(void)
{
vec4 color_0 = texture2D(color_0, gl_TexCoord[0].st);
vec4 color_1 = texture2D(color_1, gl_TexCoord[1].st);
gl_FragColor = mix(color_0, color_1, factor);
}
"""
object = logic.getCurrentController().owner
object = cont.owner
for mesh in object.meshes:
for material in mesh.materials:
shader = material.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(vertex_shader, fragment_shader, True)
# get the first texture channel of the material
shader.setSampler('color_0', 0)
# get the second texture channel of the material
shader.setSampler('color_1', 1)
# pass another uniform to the shader
shader.setUniform1f('factor', 0.3)
Texture name.
Type : | string (read-only) |
---|
OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture).
Type : | integer (read-only) |
---|
Material name.
Type : | string (read-only) |
---|
Texture face properties.
Type : | CObject (read-only) |
---|
Texture is tiling.
Type : | boolean |
---|
Number of tile repetitions in x direction.
Type : | integer |
---|
Number of tile repetitions in y direction.
Type : | integer |
---|
Drawing mode for the material. - 2 (drawingmode & 4) Textured - 4 (drawingmode & 16) Light - 14 (drawingmode & 16384) 3d Polygon Text.
Type : | bitfield |
---|
This material is transparent. All meshes with this material will be rendered after non transparent meshes from back to front.
Type : | boolean |
---|
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.
Type : | boolean |
---|
Light layers this material affects.
Type : | bitfield. |
---|
Mesh data with this material is triangles. It’s probably not safe to change this.
Type : | boolean |
---|
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] |
---|
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] |
---|
The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0.
Type : | float |
---|
The amount of specular of the material. 0.0 <= specularity <= 1.0.
Type : | float |
---|
Updates a realtime animation.
Parameters: |
|
---|
Sets texture render state.
Parameters: | tface (CObject) – Texture face |
---|
mat.setTexture(mat.tface)
Sets material parameters for this object for rendering.
Material Parameters set:
Parameters: |
|
---|
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):
Parameters: | material (instance) – The material object. |
---|
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())
Radar sensor is a near sensor with a conical sensor object.
The origin of the cone with which to test. The origin is in the middle of the cone. (read-only).
Type : | list of floats [x, y, z] |
---|
The center of the bottom face of the cone with which to test. (read-only).
Type : | list of floats [x, y, z] |
---|
The height of the cone with which to test.
Type : | float |
---|
The angle of the cone (in degrees) with which to test.
Type : | float from 0 to 360 |
---|
The axis on which the radar cone is cast.
Type : | integer 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
Returns: | The height of the cone with which to test. |
---|---|
Return type: | float |
A ray sensor detects the first object in a given direction.
The property the ray is looking for.
Type : | string |
---|
The distance of the ray.
Type : | float |
---|
Whether or not to look for a material (false = property).
Type : | boolean |
---|
Whether or not to use XRay.
Type : | boolean |
---|
The game object that was hit by the ray. (read-only).
Type : | KX_GameObject |
---|
The position (in worldcoordinates) where the object was hit by the ray. (read-only).
Type : | list [x, y, z] |
---|
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] |
---|
The direction from the ray (in worldcoordinates). (read-only).
Type : | list [x, y, z] |
---|
The axis the ray is pointing on.
Type : | integer from 0 to 5 |
---|
Edit Object Actuator (in Add Object Mode)
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.
Error: GameObject 'Name' has a AddObjectActuator 'ActuatorName' without object (in 'nonactive' layer)
the object this actuator adds.
Type : | KX_GameObject or None |
---|
the last added object from this actuator (read-only).
Type : | KX_GameObject or None |
---|
the lifetime of added objects, in frames. Set to 0 to disable automatic deletion.
Type : | integer |
---|
the initial linear velocity of added objects.
Type : | list [vx, vy, vz] |
---|
the initial angular velocity of added objects.
Type : | list [vx, vy, vz] |
---|
adds the object without needing to calling SCA_PythonController.activate()
Note
Use objectLastCreated to get the newly created object.
Dynamic Actuator.
Type : | integer |
---|
the type of operation of the actuator, 0-4
the mass value for the KX_DYN_SET_MASS operation.
Type : | float |
---|
Edit Object Actuator (in End Object mode)
This actuator has no python methods.
Edit Object actuator, in Replace Mesh mode.
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 'Name' ReplaceMeshActuator 'ActuatorName' without object
# 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 |
# +----------+ +-----------+ +-------------------------------------+
from bge import logic
# 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)
)
cont = logic.getCurrentController()
object = cont.owner
actuator = cont.actuators["LOD." + obj.name]
camera = logic.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(object.position, camera.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" + object.name + mesh[0] == actuator.getMesh():
curmesh = mesh
if newmesh != None and "ME" + object.name + newmesh[0] != actuator.mesh:
# 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:
actuator.mesh = object.name + newmesh[0]
cont.activate(actuator)
MeshProxy or the name of the mesh that will replace the current one.
Set to None to disable actuator.
Type : | MeshProxy or None if no mesh is set |
---|
when true the displayed mesh is replaced.
Type : | boolean |
---|
when true the physics mesh is replaced.
Type : | boolean |
---|
Immediately replace mesh without delay.
An active scene that gives access to objects, cameras, lights and scene attributes.
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!
from bge import logic
# get the scene
scene = logic.getCurrentScene()
# print all the objects in the scene
for object in scene.objects:
print(object.name)
# get an object named 'Cube'
object = scene.objects["Cube"]
# get the first object in the scene.
object = scene.objects[0]
# Get the depth of an object in the camera view.
from bge import logic
object = logic.getCurrentController().owner
cam = logic.getCurrentScene().active_camera
# Depth is negative and decreasing further from the camera
depth = object.position[0]*cam.world_to_camera[2][0] + object.position[1]*cam.world_to_camera[2][1] + object.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
@bug: All attributes are read only at the moment.
The scene’s name, (read-only).
Type : | string |
---|
A list of objects in the scene, (read-only).
Type : | CListValue of KX_GameObject |
---|
A list of objects on background layers (used for the addObject actuator), (read-only).
Type : | CListValue of KX_GameObject |
---|
A list of lights in the scene, (read-only).
Type : | CListValue of KX_LightObject |
---|
A list of cameras in the scene, (read-only).
Type : | CListValue of KX_Camera |
---|
The current active camera.
Type : | KX_Camera |
---|
Note
This can be set directly from python to avoid using the KX_SceneActuator.
True if the scene is suspended, (read-only).
Type : | boolean |
---|
True if the scene is activity culling.
Type : | boolean |
---|
The distance outside which to do activity culling. Measured in manhattan distance.
Type : | float |
---|
True when Dynamic Bounding box Volume Tree is set (read-only).
Type : | boolean |
---|
A list of callables to be run before the render step.
Type : | list |
---|
A list of callables to be run after the render step.
Type : | list |
---|
Adds an object to the scene like the Add Object Actuator would.
Parameters: |
|
---|---|
Returns: | The newly added object. |
Return type: |
Removes the scene from the game.
Restarts the scene.
Replaces this scene with another one.
Parameters: | scene (string) – The name of the scene to replace this scene with. |
---|
Suspends this scene.
Resume this scene.
Return the value matching key, or the default value if its not found. :return: The key value or a default.
Scene Actuator logic brick.
Warning
Scene actuators that use a scene name will be ignored if at game start, the named scene doesn’t exist or is empty
This will generate a warning in the console:
Error: GameObject 'Name' has a SceneActuator 'ActuatorName' (SetScene) without scene
the name of the scene to change to/overlay/underlay/remove/suspend/resume.
Type : | string |
---|
the camera to change to.
Type : | KX_Camera on read, string or KX_Camera on write |
---|
Note
When setting the attribute, you can use either a KX_Camera or the name of the camera.
Set flag to True to restart the sene.
Type : | boolean |
---|
The mode of the actuator.
Type : | integer from 0 to 5. |
---|
Sound Actuator.
The startSound, pauseSound and stopSound do not requirethe actuator to be activated - they act instantly provided that the actuator has been activated once at least.
The filename of the sound this actuator plays.
Type : | string |
---|
The volume (gain) of the sound.
Type : | float |
---|
The pitch of the sound.
Type : | float |
---|
The roll off factor. Rolloff defines the rate of attenuation as the sound gets further away.
Type : | float |
---|
The loop mode of the actuator.
Type : | integer |
---|
The position of the sound as a list: [x, y, z].
Type : | float array |
---|
The velocity of the emitter as a list: [x, y, z]. The relative velocity to the observer determines the pitch. List of 3 floats: [x, y, z].
Type : | float array |
---|
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]] |
---|
The operation mode of the actuator. Can be one of these constants
Type : | integer |
---|
State actuator changes the state mask of parent object.
Type of bit operation to be applied on object state mask.
You can use one of these constants
Type : | integer |
---|
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 |
---|
Edit Object actuator in Track To mode.
Warning
Track To Actuators will be ignored if at game start, the object to track to is invalid.
This will generate a warning in the console:
GameObject 'Name' no object in EditObjectActuator 'ActuatorName'
the object this actuator tracks.
Type : | KX_GameObject or None |
---|
the time in frames with which to delay the tracking motion.
Type : | integer |
---|
the tracking motion to use 3D.
Type : | boolean |
---|
KX_VehicleWrapper
TODO - description
Add a wheel to the vehicle
Parameters: |
|
---|
Apply a braking force to the specified wheel
Parameters: |
|
---|
Apply an engine force to the specified wheel
Parameters: |
|
---|
Get the constraint ID
Returns: | the constraint id |
---|---|
Return type: | integer |
Returns the constraint type.
Returns: | constraint type |
---|---|
Return type: | integer |
Returns the number of wheels.
Returns: | the number of wheels for this vehicle |
---|---|
Return type: | integer |
Returns the wheel orientation as a quaternion.
Parameters: | wheelIndex (integer) – the wheel index |
---|---|
Returns: | TODO Description |
Return type: | TODO - type should be quat as per method name but from the code it looks like a matrix |
Returns the position of the specified wheel
Parameters: | wheelIndex (integer) – the wheel index |
---|---|
Returns: | position vector |
Return type: | list[x, y, z] |
Returns the rotation of the specified wheel
Parameters: | wheelIndex (integer) – the wheel index |
---|---|
Returns: | the wheel rotation |
Return type: | float |
Set the specified wheel’s roll influence. The higher the roll influence the more the vehicle will tend to roll over in corners.
Parameters: |
|
---|
Set the specified wheel’s steering
Parameters: |
|
---|
Set the specified wheel’s compression
Parameters: |
|
---|
Set the specified wheel’s damping
Parameters: |
|
---|
Set the specified wheel’s stiffness
Parameters: |
|
---|
Set the specified wheel’s tyre friction
Parameters: |
|
---|
A vertex holds position, UV, colour and normal information.
Note: The physics simulation is NOT currently updated - physics will not respond to changes in the vertex position.
The position of the vertex.
Type : | list [x, y, z] |
---|
The texture coordinates of the vertex.
Type : | list [u, v] |
---|
The normal of the vertex.
Type : | list [nx, ny, nz] |
---|
The colour of the vertex.
Type : | list [r, g, b, a] |
---|
Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
Synonym for colour.
The x coordinate of the vertex.
Type : | float |
---|
The y coordinate of the vertex.
Type : | float |
---|
The z coordinate of the vertex.
Type : | float |
---|
The u texture coordinate of the vertex.
Type : | float |
---|
The v texture coordinate of the vertex.
Type : | float |
---|
The second u texture coordinate of the vertex.
Type : | float |
---|
The second v texture coordinate of the vertex.
Type : | float |
---|
The red component of the vertex colour. 0.0 <= r <= 1.0.
Type : | float |
---|
The green component of the vertex colour. 0.0 <= g <= 1.0.
Type : | float |
---|
The blue component of the vertex colour. 0.0 <= b <= 1.0.
Type : | float |
---|
The alpha component of the vertex colour. 0.0 <= a <= 1.0.
Type : | float |
---|
Gets the position of this vertex.
Returns: | this vertexes position in local coordinates. |
---|---|
Return type: | list [x, y, z] |
Sets the position of this vertex.
Type : | list [x, y, z] |
---|---|
Parameters: | pos – the new position for this vertex in local coordinates. |
Gets the UV (texture) coordinates of this vertex.
Returns: | this vertexes UV (texture) coordinates. |
---|---|
Return type: | list [u, v] |
Sets the UV (texture) coordinates of this vertex.
Type : | list [u, v] |
---|
Gets the 2nd UV (texture) coordinates of this vertex.
Returns: | this vertexes UV (texture) coordinates. |
---|---|
Return type: | list [u, v] |
Sets the 2nd UV (texture) coordinates of this vertex.
Type : | list [u, v] |
---|---|
Parameters: |
|
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.
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: | packed colour. 4 byte integer with one byte per colour channel in RGBA format. |
---|---|
Return type: | integer |
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]
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. |
---|
Gets the normal vector of this vertex.
Returns: | normalised normal vector. |
---|---|
Return type: | list [nx, ny, nz] |
Sets the normal vector of this vertex.
Type : | sequence of floats [r, g, b] |
---|---|
Parameters: | normal – the new normal of this vertex. |
Visibility Actuator.
whether the actuator makes its parent object visible or invisible.
Type : | boolean |
---|
whether the actuator makes its parent object an occluder or not.
Type : | boolean |
---|
whether the visibility/occlusion should be propagated to all children of the object.
Type : | boolean |
---|
Create, enable and disable 2D filters
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.
shader source code for custom shader.
Type : | string |
---|
action on motion blur: 0=enable, 1=disable.
Type : | integer |
---|
Type of 2D filter, use one of these constants
Type : | integer |
---|
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.
Type : | integer (0-100) |
---|
argument for motion blur filter.
Type : | float (0.0-100.0) |
---|
An AND controller activates only when all linked sensors are activated.
There are no special python methods for this controller.
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.
the name of the actuator that the sensor is monitoring.
Type : | string |
---|
This sensor is always activated.
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.
length of the initial OFF period as number of frame, 0 for immediate trigger.
Type : | integer. |
---|
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.
Type : | integer |
---|
1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
Type : | integer |
---|
This sensor detects player joystick events.
The state of the joysticks axis as a list of values numAxis long. (read-only).
Type : | list of ints. |
---|
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.
like axisValues but returns a single axis value that is set by the sensor. (read-only).
Type : | integer |
---|
Note
Only use this for “Single Axis” type sensors otherwise it will raise an error.
The state of the joysticks hats as a list of values numHats long. (read-only).
Type : | list of ints |
---|
Each spesifying the direction of the hat from 1 to 12, 0 when inactive.
Hat directions are as follows...
Like hatValues but returns a single hat direction value that is set by the sensor. (read-only).
Type : | integer |
---|
The number of axes for the joystick at this index. (read-only).
Type : | integer |
---|
The number of buttons for the joystick at this index. (read-only).
Type : | integer |
---|
The number of hats for the joystick at this index. (read-only).
Type : | integer |
---|
True if a joystick is connected at this joysticks index. (read-only).
Type : | boolean |
---|
The joystick index to use (from 0 to 7). The first joystick is always 0.
Type : | integer |
---|
Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
Type : | integer |
---|
The button index the sensor reacts to (first button = 0). When the “All Events” toggle is set, this option has no effect.
Type : | integer |
---|
The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
Type : | [integer, integer] |
---|
The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
Type : | [integer, integer] |
---|
Returns: | A list containing the indicies of the currently pressed buttons. |
---|---|
Return type: | list |
Parameters: | buttonIndex (integer) – the button index, 0=first button |
---|---|
Returns: | The current pressed state of the specified button. |
Return type: | boolean |
A keyboard sensor detects player key presses.
See module bge.keys for keycode values.
The key code this sensor is looking for.
Type : | keycode from bge.keys module |
---|
The key code for the first modifier this sensor is looking for.
Type : | keycode from bge.keys module |
---|
The key code for the second modifier this sensor is looking for.
Type : | keycode from bge.keys module |
---|
The name of the property that indicates whether or not to log keystrokes as a string.
Type : | string |
---|
The name of the property that receives keystrokes in case in case a string is logged.
Type : | string |
---|
Flag to determine whether or not to accept all keys.
Type : | boolean |
---|
a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
Type : | list [[keycode, status], ...] |
---|
Get the status of a key.
Parameters: | keycode (integer) – The code that represents the key you want to get the state of, use one of these constants |
---|---|
Returns: | The state of the given key, can be one of these constants |
Return type: | int |
An NAND controller activates when all linked sensors are not active.
There are no special python methods for this controller.
An NOR controller activates only when all linked sensors are de-activated.
There are no special python methods for this controller.
An OR controller activates when any connected sensor activates.
There are no special python methods for this controller.
Property Actuator
the property on which to operate.
Type : | string |
---|
the value with which the actuator operates.
Type : | string |
---|
TODO - add constants to game logic dict!.
Type : | integer |
---|
Activates when the game object property matches.
Type of check on the property. Can be one of these constants
Type : | integer. |
---|
the property the sensor operates.
Type : | string |
---|
the value with which the sensor compares to the value of the property.
Type : | string |
---|
the minimum value of the range used to evaluate the property when in interval mode.
Type : | string |
---|
the maximum value of the range used to evaluate the property when in interval mode.
Type : | string |
---|
A Python controller uses a Python script to activate it’s actuators, based on it’s sensors.
The value of this variable depends on the execution methid.
Type : | string |
---|
Note
Once this is set the script name given for warnings will remain unchanged.
the execution mode for this controller (read-only).
Type : | integer |
---|
Activates an actuator attached to this controller.
Parameters: | actuator (actuator or the actuator name as a string) – The actuator to operate on. |
---|
Deactivates an actuator attached to this controller.
Parameters: | actuator (actuator or the actuator name as a string) – The actuator to operate on. |
---|
Random Actuator
Seed of the random number generator.
Type : | integer. |
---|
Equal seeds produce equal series. If the seed is 0, the generator will produce the same value on every call.
the first parameter of the active distribution.
Type : | float, read-only. |
---|
Refer to the documentation of the generator types for the meaning of this value.
the second parameter of the active distribution.
Type : | float, read-only |
---|
Refer to the documentation of the generator types for the meaning of this value.
Distribution type. (read-only). Can be one of these constants
Type : | integer |
---|
the name of the property to set with the random value.
Type : | string |
---|
If the generator and property types do not match, the assignment is ignored.
Sets this generator to produce a constant boolean value.
Parameters: | value (boolean) – The value to return. |
---|
Sets this generator to produce a uniform boolean distribution.
The generator will generate True or False with 50% chance.
Sets this generator to produce a Bernouilli distribution.
Parameters: | value (float) – Specifies the proportion of False values to produce.
|
---|
Sets this generator to always produce the given value.
Parameters: | value (integer) – the value this generator produces. |
---|
Sets this generator to produce a random value between the given lower and upper bounds (inclusive).
Generate a Poisson-distributed number.
This performs a series of Bernouilli tests with parameter value. It returns the number of tries needed to achieve succes.
Always generate the given value.
Generates a random float between lower_bound and upper_bound with a uniform distribution.
Generates a random float from the given normal distribution.
Parameters: |
|
---|
Generate negative-exponentially distributed numbers.
The half-life ‘time’ is characterized by half_life.
This sensor activates randomly.
The seed of the random number generator.
Type : | integer |
---|
The seed of the random number generator.
Type : | integer |
---|
Sets the seed of the random number generator.
If the seed is 0, the generator will produce the same value on every call.
Returns: | The initial seed of the generator. Equal seeds produce equal random series. |
---|---|
Return type: | integer |
Returns: | The last random number generated. |
---|---|
Return type: | integer |
An XNOR controller activates when all linked sensors are the same (activated or inative).
There are no special python methods for this controller.
An XOR controller activates when there is the input is mixed, but not when all are on or off.
There are no special python methods for this controller.
A Camera object.
See sphereInsideFrustum and boxInsideFrustum
See sphereInsideFrustum and boxInsideFrustum
See sphereInsideFrustum and boxInsideFrustum
The camera’s lens value.
Type : | float |
---|
The camera’s view scale when in orthographic mode.
Type : | float |
---|
The camera’s near clip distance.
Type : | float |
---|
The camera’s far clip distance.
Type : | float |
---|
True if this camera has a perspective transform, False for an orthographic projection.
Type : | boolean |
---|
True if this camera is frustum culling.
Type : | boolean |
---|
This camera’s 4x4 projection matrix.
Type : | 4x4 Matrix [[float]] |
---|
This camera’s 4x4 model view matrix. (read-only).
Type : | 4x4 Matrix [[float]] |
---|
Note
This matrix is regenerated every frame from the camera’s position and orientation.
This camera’s camera to world transform. (read-only).
Type : | 4x4 Matrix [[float]] |
---|
Note
This matrix is regenerated every frame from the camera’s position and orientation.
This camera’s world to camera transform. (read-only).
Type : | 4x4 Matrix [[float]] |
---|
Note
Regenerated every frame from the camera’s position and orientation.
Note
This is camera_to_world inverted.
True when the camera is used as a viewport, set True to enable a viewport for this camera.
Type : | boolean |
---|
Tests the given sphere against the view frustum.
Parameters: |
|
---|---|
Returns: | |
Return type: | integer |
Note
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# 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
Tests the given box against the view frustum.
Parameters: | box (list of lists) – Eight (8) corner points of the box (in world coordinates.) |
---|---|
Returns: | INSIDE, OUTSIDE or INTERSECT |
Note
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# 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 !
Tests the given point against the view frustum.
Parameters: | point (3D Vector) – The point to test (in world coordinates.) |
---|---|
Returns: | True if the given point is inside this camera’s viewing frustum. |
Return type: | boolean |
Note
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# 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 !
Returns the camera-to-world transform.
Returns: | the camera-to-world transform matrix. |
---|---|
Return type: | matrix (4x4 list) |
Returns the world-to-camera transform.
This returns the inverse matrix of getCameraToWorld().
Returns: | the world-to-camera transform matrix. |
---|---|
Return type: | matrix (4x4 list) |
Set this cameras viewport ontop of all other viewport.
Sets the region of this viewport on the screen in pixels.
Use bge.render.getWindowHeight and bge.render.getWindowWidth to calculate values relative to the entire display.
Parameters: |
|
---|
Gets the position of an object projected on screen space.
# For an object in the middle of the screen, coord = [0.5, 0.5]
coord = camera.getScreenPosition(object)
Parameters: | object (KX_GameObject or 3D Vector) – object name or list [x, y, z] |
---|---|
Returns: | the object’s position in screen coordinates. |
Return type: | list [x, y] |
Gets the vector from the camera position in the screen coordinate direction.
Parameters: |
|
---|---|
Return type: | 3D Vector |
Returns: | The vector from screen coordinate. |
# Gets the vector of the camera front direction:
m_vect = camera.getScreenVect(0.5, 0.5)
Look towards a screen coordinate (x, y) and find first object hit within dist that matches prop. The ray is similar to KX_GameObject->rayCastTo.
Parameters: |
|
---|---|
Return type: | |
Returns: | the first object hit or None if no object or object does not match prop |
# Gets an object with a property "wall" in front of the camera within a distance of 100:
target = camera.getScreenRay(0.5, 0.5, 100, "wall")
An armature object.
The list of armature constraint defined on this armature. Elements of the list can be accessed by index or string. The key format for string access is ‘<bone_name>:<constraint_name>’.
Type : | list of BL_ArmatureConstraint |
---|
The list of armature channels. Elements of the list can be accessed by index or name the bone.
Type : | list of BL_ArmatureChannel |
---|
Ensures that the armature will be updated on next graphic frame.
This action is unecessary if a KX_ArmatureActuator with mode run is active or if an action is playing. Use this function in other cases. It must be called on each frame to ensure that the armature is updated continously.
Armature Actuators change constraint condition on armatures.
Constants related to type
Just make sure the armature will be updated on the next graphic frame. This is the only persistent mode of the actuator: it executes automatically once per frame until stopped by a controller
Value : | 0 |
---|
Enable the constraint.
Value : | 1 |
---|
Disable the constraint (runtime constraint values are not updated).
Value : | 2 |
---|
Change target and subtarget of constraint.
Value : | 3 |
---|
Change weight of (only for IK constraint).
Value : | 4 |
---|
The type of action that the actuator executes when it is active.
Can be one of these constants
Type : | integer |
---|
The constraint object this actuator is controlling.
Type : | BL_ArmatureConstraint |
---|
The object that this actuator will set as primary target to the constraint it controls.
Type : | KX_GameObject |
---|
The object that this actuator will set as secondary target to the constraint it controls.
Type : | KX_GameObject. |
---|
Note
Currently, the only secondary target is the pole target for IK constraint.
The weight this actuator will set on the constraint it controls.
Type : | float. |
---|
Note
Currently only the IK constraint has a weight. It must be a value between 0 and 1.
Note
A weight of 0 disables a constraint while still updating constraint runtime values (see BL_ArmatureConstraint)
Armature sensor detect conditions on armatures.
Constants related to type
Detect that the constraint is changing state (active/inactive)
Value : | 0 |
---|
Detect that the constraint linear error is above a threshold
Value : | 1 |
---|
Detect that the constraint linear error is below a threshold
Value : | 2 |
---|
Detect that the constraint rotation error is above a threshold
Value : | 3 |
---|
Detect that the constraint rotation error is below a threshold
Value : | 4 |
---|
The type of measurement that the sensor make when it is active.
Can be one of these constants
Type : | integer. |
---|
The constraint object this sensor is watching.
Type : | BL_ArmatureConstraint |
---|
The threshold used in the comparison with the constraint error The linear error is only updated on CopyPose/Distance IK constraint with iTaSC solver The rotation error is only updated on CopyPose+rotation IK constraint with iTaSC solver The linear error on CopyPose is always >= 0: it is the norm of the distance between the target and the bone The rotation error on CopyPose is always >= 0: it is the norm of the equivalent rotation vector between the bone and the target orientations The linear error on Distance can be positive if the distance between the bone and the target is greater than the desired distance, and negative if the distance is smaller.
Type : | float |
---|
Proxy to Armature Constraint. Allows to change constraint on the fly. Obtained through BL_ArmatureObject.constraints.
Note
Not all armature constraints are supported in the GE.
Constants related to type
Constants related to ik_type
constraint is trying to match the position and eventually the rotation of the target.
Value : | 0 |
---|
Constraint is maintaining a certain distance to target subject to ik_mode
Value : | 1 |
---|
Constants related to ik_flag
Set when the constraint operates on the head of the bone and not the tail
Value : | 1 |
---|
Set when the constraint tries to match the orientation of the target
Value : | 2 |
---|
Set when the armature is allowed to stretch (only the bones with stretch factor > 0.0)
Value : | 16 |
---|
Set when the constraint tries to match the position of the target.
Value : | 32 |
---|
Constants related to ik_mode
The constraint tries to keep the bone within ik_dist of target
Value : | 0 |
---|
The constraint tries to keep the bone outside ik_dist of the target
Value : | 1 |
---|
The constraint tries to keep the bone exactly at ik_dist of the target.
Value : | 2 |
---|
Type of constraint, (read-only).
Use one of these constants.
Type : | integer, one of CONSTRAINT_TYPE_* constants |
---|
Name of constraint constructed as <bone_name>:<constraint_name>. constraints list.
Type : | string |
---|
This name is also the key subscript on BL_ArmatureObject.
fraction of constraint effect that is enforced. Between 0 and 1.
Type : | float |
---|
Position of target between head and tail of the target bone: 0=head, 1=tail.
Type : | float. |
---|
Note
Only used if the target is a bone (i.e target object is an armature.
runtime linear error (in Blender units) on constraint at the current frame.
This is a runtime value updated on each frame by the IK solver. Only available on IK constraint and iTaSC solver.
Type : | float |
---|
Runtime rotation error (in radiant) on constraint at the current frame.
Type : | float. |
---|
This is a runtime value updated on each frame by the IK solver. Only available on IK constraint and iTaSC solver.
It is only set if the constraint has a rotation part, for example, a CopyPose+Rotation IK constraint.
Primary target object for the constraint. The position of this object in the GE will be used as target for the constraint.
Type : | KX_GameObject. |
---|
Secondary target object for the constraint. The position of this object in the GE will be used as secondary target for the constraint.
Type : | KX_GameObject. |
---|
Currently this is only used for pole target on IK constraint.
True if the constraint is active.
Type : | boolean |
---|
Note
An inactive constraint does not update lin_error and rot_error.
Weight of the IK constraint between 0 and 1.
Only defined for IK constraint.
Type : | float |
---|
Type of IK constraint, (read-only).
Use one of these constants.
Type : | integer. |
---|
Combination of IK constraint option flags, read-only.
Use one of these constants.
Type : | integer |
---|
Distance the constraint is trying to maintain with target, only used when ik_type=CONSTRAINT_IK_DISTANCE.
Type : | float |
---|
Use one of these constants.
Additional mode for IK constraint. Currently only used for Distance constraint:
Type : | integer |
---|
Proxy to armature pose channel. Allows to read and set armature pose. The attributes are identical to RNA attributes, but mostly in read-only mode.
See rotation_mode
channel name (=bone name), read-only.
Type : | string |
---|
return the bone object corresponding to this pose channel, read-only.
Type : | BL_ArmatureBone |
---|
return the parent channel object, None if root channel, read-only.
Type : | BL_ArmatureChannel |
---|
true if the bone is part of an active IK chain, read-only. This flag is not set when an IK constraint is defined but not enabled (miss target information for example).
Type : | boolean |
---|
true if the bone is free to rotation in the X axis, read-only.
Type : | boolean |
---|
true if the bone is free to rotation in the Y axis, read-only.
Type : | boolean |
---|
true if the bone is free to rotation in the Z axis, read-only.
Type : | boolean |
---|
true if a limit is imposed on X rotation, read-only.
Type : | boolean |
---|
true if a limit is imposed on Y rotation, read-only.
Type : | boolean |
---|
true if a limit is imposed on Z rotation, read-only.
Type : | boolean |
---|
true if channel rotation should applied as IK constraint, read-only.
Type : | boolean |
---|
true if channel size should applied as IK constraint, read-only.
Type : | boolean |
---|
displacement of the bone head in armature local space, read-write.
Type : | vector [X, Y, Z]. |
---|
Note
You can only move a bone if it is unconnected to its parent. An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
Note
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see BL_ArmatureObject.update).
scale of the bone relative to its parent, read-write.
Type : | vector [sizeX, sizeY, sizeZ]. |
---|
Note
An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
Note
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see BL_ArmatureObject.update)
rotation of the bone relative to its parent expressed as a quaternion, read-write.
Type : | vector [qr, qi, qj, qk]. |
---|
Note
This field is only used if rotation_mode is 0. An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
Note
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see BL_ArmatureObject.update)
rotation of the bone relative to its parent expressed as a set of euler angles, read-write.
Type : | vector [X, Y, Z]. |
---|
Note
This field is only used if rotation_mode is > 0. You must always pass the angles in [X, Y, Z] order; the order of applying the angles to the bone depends on rotation_mode. An action playing on the armature may change this field. An IK chain does not update this value, see joint_rotation.
Note
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see BL_ArmatureObject.update)
Method of updating the bone rotation, read-write.
Type : | integer |
---|
Use the following constants (euler mode are named as in Blender UI but the actual axis order is reversed).
pose matrix in bone space (deformation of the bone due to action, constraint, etc), Read-only. This field is updated after the graphic render, it represents the current pose.
Type : | matrix [4][4] |
---|
pose matrix in armature space, read-only, This field is updated after the graphic render, it represents the current pose.
Type : | matrix [4][4] |
---|
position of bone head in armature space, read-only.
Type : | vector [x, y, z] |
---|
position of bone tail in armature space, read-only.
Type : | vector [x, y, z] |
---|
minimum value of X rotation in degree (<= 0) when X rotation is limited (see ik_limit_x), read-only.
Type : | float |
---|
maximum value of X rotation in degree (>= 0) when X rotation is limited (see ik_limit_x), read-only.
Type : | float |
---|
minimum value of Y rotation in degree (<= 0) when Y rotation is limited (see ik_limit_y), read-only.
Type : | float |
---|
maximum value of Y rotation in degree (>= 0) when Y rotation is limited (see ik_limit_y), read-only.
Type : | float |
---|
minimum value of Z rotation in degree (<= 0) when Z rotation is limited (see ik_limit_z), read-only.
Type : | float |
---|
maximum value of Z rotation in degree (>= 0) when Z rotation is limited (see ik_limit_z), read-only.
Type : | float |
---|
bone rotation stiffness in X axis, read-only.
Type : | float between 0 and 1 |
---|
bone rotation stiffness in Y axis, read-only.
Type : | float between 0 and 1 |
---|
bone rotation stiffness in Z axis, read-only.
Type : | float between 0 and 1 |
---|
ratio of scale change that is allowed, 0=bone can’t change size, read-only.
Type : | float |
---|
weight of rotation constraint when ik_rot_control is set, read-write.
Type : | float between 0 and 1 |
---|
weight of size constraint when ik_lin_control is set, read-write.
Type : | float between 0 and 1 |
---|
Control bone rotation in term of joint angle (for robotic applications), read-write.
When writing to this attribute, you pass a [x, y, z] vector and an appropriate set of euler angles or quaternion is calculated according to the rotation_mode.
When you read this attribute, the current pose matrix is converted into a [x, y, z] vector representing the joint angles.
The value and the meaning of the x, y, z depends on the ik_dof_x/ik_dof_y/ik_dof_z attributes:
Type : | vector [x, y, z] |
---|
Note
The bone must be part of an IK chain if you want to set the ik_dof_x/ik_dof_y/ik_dof_z attributes via the UI, but this will interfere with this attribute since the IK solver will overwrite the pose. You can stay in control of the armature if you create an IK constraint but do not finalize it (e.g. don’t set a target) the IK solver will not run but the IK panel will show up on the UI for each bone in the chain.
Note
[0, 0, 0] always corresponds to the rest pose.
Note
You must request the armature pose to update and wait for the next graphic frame to see the effect of setting this attribute (see BL_ArmatureObject.update).
Note
You can read the result of the calculation in rotation or euler_rotation attributes after setting this attribute.
Proxy to Blender bone structure. All fields are read-only and comply to RNA names. All space attribute correspond to the rest pose.
bone name.
Type : | string |
---|
true when the bone head is struck to the parent’s tail.
Type : | boolean |
---|
true when bone doesn’t inherit rotation or scale from parent bone.
Type : | boolean |
---|
true when bone inherits scaling from parent bone.
Type : | boolean |
---|
number of B-bone segments.
Type : | integer |
---|
bone rotation around head-tail axis.
Type : | float |
---|
location of head end of the bone in parent bone space.
Type : | vector [x, y, z] |
---|
location of head end of the bone in parent bone space.
Type : | vector [x, y, z] |
---|
bone length.
Type : | float |
---|
location of head end of the bone in armature space.
Type : | vector [x, y, z] |
---|
location of tail end of the bone in armature space.
Type : | vector [x, y, z] |
---|
matrix of the bone head in armature space.
Type : | matrix [4][4] |
---|
Note
This matrix has no scale part.
rotation matrix of the bone in parent bone space.
Type : | matrix [3][3] |
---|
parent bone, or None for root bone.
Type : | BL_ArmatureBone |
---|
list of bone’s children.
Type : | list of BL_ArmatureBone |
---|