2 Game Engine bge.types Module
3 =============================
7 .. class:: PyObjectPlus
9 PyObjectPlus base class of most other types in the Game Engine.
11 .. attribute:: invalid
13 Test if the object has been freed by the game engine and is no longer valid.
15 Normally this is not a problem but when storing game engine data in the GameLogic module,
16 KX_Scenes or other KX_GameObjects its possible to hold a reference to invalid data.
17 Calling an attribute or method on an invalid object will raise a SystemError.
19 The invalid attribute allows testing for this case without exception handling.
23 .. method:: isA(game_type)
25 Check if this is a type or a subtype game_type.
27 :arg game_type: the name of the type or the type its self from the :mod:`bge.types` module.
28 :type game_type: string or type
29 :return: True if this object is a type or a subtype of game_type.
32 .. class:: CValue(PyObjectPlus)
34 This class is a basis for other classes.
38 The name of this CValue derived object (read-only).
42 .. class:: CPropValue(CValue)
44 This class has no python functions
46 .. class:: SCA_ILogicBrick(CValue)
48 Base class for all logic bricks.
50 .. attribute:: executePriority
52 This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
54 :type: executePriority: int
58 The game object this logic brick is attached to (read-only).
60 :type: :class:`KX_GameObject` or None in exceptional cases.
64 The name of this logic brick (read-only).
68 .. class:: SCA_PythonKeyboard(PyObjectPlus)
74 A list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
76 :type: list [[:ref:`keycode<keyboard-keys>`, :ref:`status<input-status>`], ...]
78 .. class:: SCA_PythonMouse(PyObjectPlus)
84 a list of pressed buttons that have either been pressed, or just released, or are active this frame. (read-only).
86 :type: list [[:ref:`keycode<mouse-keys>`, :ref:`status<input-status>`], ...]
88 .. attribute:: position
90 The normalized x and y position of the mouse cursor.
94 .. attribute:: visible
96 The visibility of the mouse cursor.
100 .. class:: SCA_IObject(CValue)
102 This class has no python functions
104 .. class:: SCA_ISensor(SCA_ILogicBrick)
106 Base class for all sensor logic bricks.
108 .. attribute:: usePosPulseMode
110 Flag to turn positive pulse mode on and off.
114 .. attribute:: useNegPulseMode
116 Flag to turn negative pulse mode on and off.
120 .. attribute:: frequency
122 The frequency for pulse mode sensors.
128 level Option whether to detect level or edge transition when entering a state.
129 It makes a difference only in case of logic state transition (state actuator).
130 A level detector will immediately generate a pulse, negative or positive
131 depending on the sensor condition, as soon as the state is activated.
132 A edge detector will wait for a state change before generating a pulse.
133 note: mutually exclusive with :data:`tap`, enabling will disable :data:`tap`.
139 When enabled only sensors that are just activated will send a positive event,
140 after this they will be detected as negative by the controllers.
141 This will make a key thats held act as if its only tapped for an instant.
142 note: mutually exclusive with :data:`level`, enabling will disable :data:`level`.
146 .. attribute:: invert
148 Flag to set if this sensor activates on positive or negative events.
152 .. attribute:: triggered
154 True if this sensor brick is in a positive state. (read-only).
158 .. attribute:: positive
160 True if this sensor brick is in a positive state. (read-only).
164 .. attribute:: status
166 The status of the sensor. (read-only).
171 * KX_SENSOR_JUST_ACTIVATED
173 * KX_SENSOR_JUST_DEACTIVATED
177 This convenient attribute combines the values of triggered and positive attributes.
181 Reset sensor internal state, effect depends on the type of sensor and settings.
183 The sensor is put in its initial state as if it was just activated.
185 .. class:: SCA_IController(SCA_ILogicBrick)
187 Base class for all controller logic bricks.
191 The controllers state bitmask. This can be used with the GameObject's state to test if the controller is active.
195 .. attribute:: sensors
197 A list of sensors linked to this controller.
199 :type: sequence supporting index/string lookups and iteration.
203 The sensors are not necessarily owned by the same object.
207 When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
209 .. attribute:: actuators
211 A list of actuators linked to this controller.
213 :type: sequence supporting index/string lookups and iteration.
217 The sensors are not necessarily owned by the same object.
221 When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
223 .. attribute:: useHighPriority
225 When set the controller executes always before all other controllers that dont have this set.
231 Order of execution between high priority controllers is not guaranteed.
233 .. class:: SCA_IActuator(SCA_ILogicBrick)
235 Base class for all actuator logic bricks.
237 .. class:: BL_ActionActuator(SCA_IActuator)
239 Action Actuators apply an action to an actor.
241 .. attribute:: action
243 The name of the action to set as the current action.
247 .. attribute:: channelNames
249 A list of channel names that may be used with :data:`setChannel` and :data:`getChannel`.
251 :type: list of strings
253 .. attribute:: frameStart
255 Specifies the starting frame of the animation.
259 .. attribute:: frameEnd
261 Specifies the ending frame of the animation.
265 .. attribute:: blendIn
267 Specifies the number of frames of animation to generate when making transitions between actions.
271 .. attribute:: priority
273 Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
279 Sets the current frame for the animation.
283 .. attribute:: propName
285 Sets the property to be used in FromProp playback mode.
289 .. attribute:: blendTime
291 Sets the internal frame timer. This property must be in the range from 0.0 to blendIn.
297 The operation mode of the actuator. KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND.
301 .. attribute:: useContinue
303 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.
307 .. attribute:: framePropName
309 The name of the property that is set to the current frame number.
313 .. method:: setChannel(channel, matrix)
315 Alternative to the 2 arguments, 4 arguments (channel, matrix, loc, size, quat) are also supported.
317 :arg channel: A string specifying the name of the bone channel, error raised if not in :data:`channelNames`.
318 :type channel: string
319 :arg matrix: A 4x4 matrix specifying the overriding transformation as an offset from the bone's rest position.
320 :arg matrix: list [[float]]
324 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.
326 .. method:: getChannel(channel)
328 :arg channel: A string specifying the name of the bone channel. error raised if not in :data:`channelNames`.
329 :type channel: string
330 :return: (loc, size, quat)
333 .. class:: BL_Shader(PyObjectPlus)
335 BL_Shader GLSL shaders.
339 .. method:: setUniformfv(name, fList)
341 Set a uniform with a list of float values
343 :arg name: the uniform name
345 :arg fList: a list (2, 3 or 4 elements) of float values
346 :type fList: list[float]
348 .. method:: delSource()
350 Clear the shader. Use this method before the source is changed with :data:`setSource`.
352 .. method:: getFragmentProg()
354 Returns the fragment program.
356 :return: The fragment program.
359 .. method:: getVertexProg()
361 Get the vertex program.
363 :return: The vertex program.
366 .. method:: isValid()
368 Check if the shader is valid.
370 :return: True if the shader is valid
373 .. method:: setAttrib(enum)
375 Set attribute location. (The parameter is ignored a.t.m. and the value of "tangent" is always used.)
377 :arg enum: attribute location value
380 .. method:: setNumberOfPasses( max_pass )
382 Set the maximum number of passes. Not used a.t.m.
384 :arg max_pass: the maximum number of passes
385 :type max_pass: integer
387 .. method:: setSampler(name, index)
389 Set uniform texture sample index.
391 :arg name: Uniform name
393 :arg index: Texture sample index.
396 .. method:: setSource(vertexProgram, fragmentProgram)
398 Set the vertex and fragment programs
400 :arg vertexProgram: Vertex program
401 :type vertexProgram: string
402 :arg fragmentProgram: Fragment program
403 :type fragmentProgram: string
405 .. method:: setUniform1f(name, fx)
407 Set a uniform with 1 float value.
409 :arg name: the uniform name
411 :arg fx: Uniform value
414 .. method:: setUniform1i(name, ix)
416 Set a uniform with an integer value.
418 :arg name: the uniform name
420 :arg ix: the uniform value
423 .. method:: setUniform2f(name, fx, fy)
425 Set a uniform with 2 float values
427 :arg name: the uniform name
429 :arg fx: first float value
432 :arg fy: second float value
435 .. method:: setUniform2i(name, ix, iy)
437 Set a uniform with 2 integer values
439 :arg name: the uniform name
441 :arg ix: first integer value
443 :arg iy: second integer value
446 .. method:: setUniform3f(name, fx, fy, fz)
448 Set a uniform with 3 float values.
450 :arg name: the uniform name
452 :arg fx: first float value
454 :arg fy: second float value
456 :arg fz: third float value
459 .. method:: setUniform3i(name, ix, iy, iz)
461 Set a uniform with 3 integer values
463 :arg name: the uniform name
465 :arg ix: first integer value
467 :arg iy: second integer value
469 :arg iz: third integer value
472 .. method:: setUniform4f(name, fx, fy, fz, fw)
474 Set a uniform with 4 float values.
476 :arg name: the uniform name
478 :arg fx: first float value
480 :arg fy: second float value
482 :arg fz: third float value
484 :arg fw: fourth float value
487 .. method:: setUniform4i(name, ix, iy, iz, iw)
489 Set a uniform with 4 integer values
491 :arg name: the uniform name
493 :arg ix: first integer value
495 :arg iy: second integer value
497 :arg iz: third integer value
499 :arg iw: fourth integer value
502 .. method:: setUniformDef(name, type)
506 :arg name: the uniform name
508 :arg type: uniform type
509 :type type: UNI_NONE, UNI_INT, UNI_FLOAT, UNI_INT2, UNI_FLOAT2, UNI_INT3, UNI_FLOAT3, UNI_INT4, UNI_FLOAT4, UNI_MAT3, UNI_MAT4, UNI_MAX
511 .. method:: setUniformMatrix3(name, mat, transpose)
513 Set a uniform with a 3x3 matrix value
515 :arg name: the uniform name
517 :arg mat: A 3x3 matrix [[f, f, f], [f, f, f], [f, f, f]]
518 :type mat: 3x3 matrix
519 :arg transpose: set to True to transpose the matrix
520 :type transpose: boolean
522 .. method:: setUniformMatrix4(name, mat, transpose)
524 Set a uniform with a 4x4 matrix value
526 :arg name: the uniform name
528 :arg mat: A 4x4 matrix [[f, f, f, f], [f, f, f, f], [f, f, f, f], [f, f, f, f]]
529 :type mat: 4x4 matrix
530 :arg transpose: set to True to transpose the matrix
531 :type transpose: boolean
533 .. method:: setUniformiv(name, iList)
535 Set a uniform with a list of integer values
537 :arg name: the uniform name
539 :arg iList: a list (2, 3 or 4 elements) of integer values
540 :type iList: list[integer]
542 .. method:: validate()
544 Validate the shader object.
546 .. class:: BL_ShapeActionActuator(SCA_IActuator)
548 ShapeAction Actuators apply an shape action to an mesh object.
550 .. attribute:: action
552 The name of the action to set as the current shape action.
556 .. attribute:: frameStart
558 Specifies the starting frame of the shape animation.
562 .. attribute:: frameEnd
564 Specifies the ending frame of the shape animation.
568 .. attribute:: blendIn
570 Specifies the number of frames of animation to generate when making transitions between actions.
574 .. attribute:: priority
576 Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
582 Sets the current frame for the animation.
586 .. attribute:: propName
588 Sets the property to be used in FromProp playback mode.
592 .. attribute:: blendTime
594 Sets the internal frame timer. This property must be in the range from 0.0 to blendin.
600 The operation mode of the actuator in [KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND].
604 .. attribute:: framePropName
606 The name of the property that is set to the current frame number.
610 .. class:: CListValue(CPropValue)
612 This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
614 As well as the normal index lookup (``val= clist[i]``), CListValue supports string lookups (``val= scene.objects["Cube"]``)
616 Other operations such as ``len(clist)``, ``list(clist)``, ``clist[0:10]`` are also supported.
618 .. method:: append(val)
620 Add an item to the list (like pythons append)
624 Appending values to the list can cause crashes when the list is used internally by the game engine.
626 .. method:: count(val)
628 Count the number of instances of a value in the list.
630 :return: number of instances
633 .. method:: index(val)
635 Return the index of a value in the list.
637 :return: The index of the value in the list.
640 .. method:: reverse()
642 Reverse the order of the list.
644 .. method:: get(key, default=None)
646 Return the value matching key, or the default value if its not found.
648 :return: The key value or a default.
650 .. method:: from_id(id)
652 This is a funtion especially for the game engine to return a value with a spesific id.
654 Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
658 ``myObID=id(gameObject)``
659 ``ob= scene.objects.from_id(myObID)``
661 Where myObID is an int or long from the id function.
663 This has the advantage that you can store the id in places you could not store a gameObject.
667 The id is derived from a memory location and will be different each time the game engine starts.
669 .. class:: KX_BlenderMaterial(PyObjectPlus)
673 .. method:: getShader()
675 Returns the material's shader.
677 :return: the material's shader
678 :rtype: :class:`BL_Shader`
680 .. method:: setBlending(src, dest)
682 Set the pixel color arithmetic functions.
684 :arg src: Specifies how the red, green, blue, and alpha source blending factors are computed.
685 :type src: Value in...
690 * GL_ONE_MINUS_SRC_COLOR,
692 * GL_ONE_MINUS_DST_COLOR,
694 * GL_ONE_MINUS_SRC_ALPHA,
696 * GL_ONE_MINUS_DST_ALPHA,
697 * GL_SRC_ALPHA_SATURATE
699 :arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed.
700 :type dest: Value in...
705 * GL_ONE_MINUS_SRC_COLOR
707 * GL_ONE_MINUS_DST_COLOR
709 * GL_ONE_MINUS_SRC_ALPHA
711 * GL_ONE_MINUS_DST_ALPHA
712 * GL_SRC_ALPHA_SATURATE
714 .. method:: getMaterialIndex()
716 Returns the material's index.
718 :return: the material's index
721 .. class:: KX_CameraActuator(SCA_IActuator)
723 Applies changes to a camera.
727 minimum distance to the target object maintained by the actuator.
733 maximum distance to stay from the target object.
737 .. attribute:: height
739 height to stay above the target object.
745 axis this actuator is tracking, True=X, False=Y.
749 .. attribute:: object
751 the object this actuator tracks.
753 :type: :class:`KX_GameObject` or None
757 .. class:: KX_ConstraintActuator(SCA_IActuator)
759 A constraint actuator limits the position, rotation, distance or orientation of an object.
765 Time constant of the constraint expressed in frame (not use by Force field constraint).
769 .. attribute:: rotDamp
771 Time constant for the rotation expressed in frame (only for the distance constraint), 0 = use damp for rotation as well.
775 .. attribute:: direction
777 The reference direction in world coordinate for the orientation constraint.
779 :type: 3-tuple of float: (x, y, z)
781 .. attribute:: option
783 Binary combination of the following values.
787 * Applicable to Distance constraint
788 * KX_ACT_CONSTRAINT_NORMAL ( 64) : Activate alignment to surface
789 * KX_ACT_CONSTRAINT_DISTANCE ( 512) : Activate distance control
790 * KX_ACT_CONSTRAINT_LOCAL (1024) : direction of the ray is along the local axis
791 * Applicable to Force field constraint:
792 * KX_ACT_CONSTRAINT_DOROTFH (2048) : Force field act on rotation as well
793 * Applicable to both:
794 * KX_ACT_CONSTRAINT_MATERIAL ( 128) : Detect material rather than property
795 * KX_ACT_CONSTRAINT_PERMANENT ( 256) : No deactivation if ray does not hit target
799 activation time of the actuator. The actuator disables itself after this many frame. If set to 0, the actuator is not limited in time.
803 .. attribute:: propName
805 the name of the property or material for the ray detection of the distance constraint.
811 The lower bound of the constraint. For the rotation and orientation constraint, it represents radiant.
815 .. attribute:: distance
817 the target distance of the distance constraint.
823 the upper bound of the constraint. For rotation and orientation constraints, it represents radiant.
827 .. attribute:: rayLength
829 the length of the ray of the distance constraint.
837 Use one of the following constant: :data:`~bge.logic.KX_CONSTRAINTACT_LOCX`,
838 :data:`~bge.logic.KX_CONSTRAINTACT_LOCY`, :data:`~bge.logic.KX_CONSTRAINTACT_LOCZ`,
839 :data:`~bge.logic.KX_CONSTRAINTACT_ROTX`, :data:`~bge.logic.KX_CONSTRAINTACT_ROTY`,
840 :data:`~bge.logic.KX_CONSTRAINTACT_ROTZ`, :data:`~bge.logic.KX_CONSTRAINTACT_DIRPX`,
841 :data:`~bge.logic.KX_CONSTRAINTACT_DIRPY`, :data:`~bge.logic.KX_CONSTRAINTACT_DIRPZ`,
842 :data:`~bge.logic.KX_CONSTRAINTACT_DIRNX`, :data:`~bge.logic.KX_CONSTRAINTACT_DIRNY`,
843 :data:`~bge.logic.KX_CONSTRAINTACT_DIRNZ`, :data:`~bge.logic.KX_CONSTRAINTACT_ORIX`,
844 :data:`~bge.logic.KX_CONSTRAINTACT_ORIY`, :data:`~bge.logic.KX_CONSTRAINTACT_ORIZ`,
845 :data:`~bge.logic.KX_ACT_CONSTRAINT_FHPX`, :data:`~bge.logic.KX_ACT_CONSTRAINT_FHPY`,
846 :data:`~bge.logic.KX_ACT_CONSTRAINT_FHPZ`, :data:`~bge.logic.KX_ACT_CONSTRAINT_FHNX`,
847 :data:`~bge.logic.KX_ACT_CONSTRAINT_FHNY`, :data:`~bge.logic.KX_ACT_CONSTRAINT_FHNZ`,
848 :data:`~bge.logic.KX_ACT_CONSTRAINT_DISTANCE`, :data:`~bge.logic.KX_ACT_CONSTRAINT_DOROTFH`,
849 :data:`~bge.logic.KX_ACT_CONSTRAINT_LOCAL`, :data:`~bge.logic.KX_ACT_CONSTRAINT_MATERIAL`,
850 :data:`~bge.logic.KX_ACT_CONSTRAINT_NORMAL`, :data:`~bge.logic.KX_ACT_CONSTRAINT_PERMANENT`
855 .. class:: KX_ConstraintWrapper(PyObjectPlus)
859 .. method:: getConstraintId(val)
861 Returns the contraint's ID
863 :return: the constraint's ID
866 .. class:: KX_GameActuator(SCA_IActuator)
868 The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
872 .. attribute:: fileName
874 the new .blend file to load.
880 The mode of this actuator.
882 :type: Constant in :data:`~bge.logic.KX_GAME_LOAD`, :data:`~bge.logic.KX_GAME_START`,
883 :data:`~bge.logic.KX_GAME_RESTART`, :data:`~bge.logic.KX_GAME_QUIT`,
884 :data:`~bge.logic.KX_GAME_SAVECFG`, :data:`~bge.logic.KX_GAME_LOADCFG`
886 .. class:: KX_GameObject(SCA_IObject)
888 All game objects are derived from this class.
890 Properties assigned to game objects are accessible as attributes of this class.
894 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 :data:`invalid` attribute to check.
898 The object's name. (read-only).
910 The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0.
912 .. attribute:: linVelocityMin
914 Enforces the object keeps moving at a minimum velocity.
920 Applies to dynamic and rigid body objects only.
924 A value of 0.0 disables this option.
928 While objects are stationary the minimum velocity will not be applied.
930 .. attribute:: linVelocityMax
932 Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
938 Applies to dynamic and rigid body objects only.
942 A value of 0.0 disables this option (rather then setting it stationary).
944 .. attribute:: localInertia
946 the object's inertia vector in local coordinates. Read only.
948 :type: list [ix, iy, iz]
950 .. attribute:: parent
952 The object's parent object. (read-only).
954 :type: :class:`KX_GameObject` or None
956 .. attribute:: visible
964 Game logic will still run for invisible objects.
968 The object color of the object.
970 :type: list [r, g, b, a]
972 .. attribute:: occlusion
974 occlusion capability flag.
978 .. attribute:: position
980 The object's position.
982 .. deprecated:: use :data:`localPosition` and :data:`worldPosition`.
984 :type: list [x, y, z] On write: local position, on read: world position
986 .. attribute:: orientation
988 The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
990 .. deprecated:: use :data:`localOrientation` and :data:`worldOrientation`.
992 :type: 3x3 Matrix [[float]] On write: local orientation, on read: world orientation
994 .. attribute:: scaling
996 The object's scaling factor. list [sx, sy, sz]
998 .. deprecated:: use :data:`localScale` and :data:`worldScale`.
1000 :type: list [sx, sy, sz] On write: local scaling, on read: world scaling
1002 .. attribute:: localOrientation
1004 The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
1006 :type: 3x3 Matrix [[float]]
1008 .. attribute:: worldOrientation
1010 The object's world orientation.
1012 :type: 3x3 Matrix [[float]]
1014 .. attribute:: localScale
1016 The object's local scaling factor.
1018 :type: list [sx, sy, sz]
1020 .. attribute:: worldScale
1022 The object's world scaling factor. Read-only.
1024 :type: list [sx, sy, sz]
1026 .. attribute:: localPosition
1028 The object's local position.
1030 :type: list [x, y, z]
1032 .. attribute:: worldPosition
1034 The object's world position.
1036 :type: list [x, y, z]
1038 .. attribute:: timeOffset
1040 adjust the slowparent delay at runtime.
1044 .. attribute:: state
1046 the game object's state bitmask, using the first 30 bits, one bit must always be set.
1050 .. attribute:: meshes
1052 a list meshes for this object.
1054 :type: list of :class:`KX_MeshProxy`
1058 Most objects use only 1 mesh.
1062 Changes to this list will not update the KX_GameObject.
1064 .. attribute:: sensors
1066 a sequence of :class:`SCA_ISensor` objects with string/index lookups and iterator support.
1072 This attribute is experemental and may be removed (but probably wont be).
1076 Changes to this list will not update the KX_GameObject.
1078 .. attribute:: controllers
1080 a sequence of :class:`SCA_IController` objects with string/index lookups and iterator support.
1082 :type: list of :class:`SCA_ISensor`
1086 This attribute is experemental and may be removed (but probably wont be).
1090 Changes to this list will not update the KX_GameObject.
1092 .. attribute:: actuators
1094 a list of :class:`SCA_IActuator` with string/index lookups and iterator support.
1100 This attribute is experemental and may be removed (but probably wont be).
1104 Changes to this list will not update the KX_GameObject.
1106 .. attribute:: attrDict
1108 get the objects internal python attribute dictionary for direct (faster) access.
1112 .. attribute:: children
1114 direct children of this object, (read-only).
1116 :type: :class:`CListValue` of :class:`KX_GameObject`'s
1118 .. attribute:: childrenRecursive
1120 all children of this object including childrens children, (read-only).
1122 :type: :class:`CListValue` of :class:`KX_GameObject`'s
1124 .. method:: endObject()
1126 Delete this object, can be used in place of the EndObject Actuator.
1128 The actual removal of the object from the scene is delayed.
1130 .. method:: replaceMesh(mesh, useDisplayMesh=True, usePhysicsMesh=False)
1132 Replace the mesh of this object with a new mesh. This works the same was as the actuator.
1134 :arg mesh: mesh to replace or the meshes name.
1135 :type mesh: :class:`MeshProxy` or string
1136 :arg useDisplayMesh: when enabled the display mesh will be replaced (optional argument).
1137 :type useDisplayMesh: boolean
1138 :arg usePhysicsMesh: when enabled the physics mesh will be replaced (optional argument).
1139 :type usePhysicsMesh: boolean
1141 .. method:: setVisible(visible, recursive)
1143 Sets the game object's visible flag.
1145 :arg visible: the visible state to set.
1146 :type visible: boolean
1147 :arg recursive: optional argument to set all childrens visibility flag too.
1148 :type recursive: boolean
1150 .. method:: setOcclusion(occlusion, recursive)
1152 Sets the game object's occlusion capability.
1154 :arg occlusion: the state to set the occlusion to.
1155 :type occlusion: boolean
1156 :arg recursive: optional argument to set all childrens occlusion flag too.
1157 :type recursive: boolean
1159 .. method:: alignAxisToVect(vect, axis=2, factor=1.0)
1161 Aligns any of the game object's axis along the given vector.
1164 :arg vect: a vector to align the axis.
1165 :type vect: 3D vector
1166 :arg axis: The axis you want to align
1173 :arg factor: Only rotate a feaction of the distance to the target vector (0.0 - 1.0)
1176 .. method:: getAxisVect(vect)
1178 Returns the axis vector rotates by the objects worldspace orientation.
1179 This is the equivalent of multiplying the vector by the orientation matrix.
1181 :arg vect: a vector to align the axis.
1182 :type vect: 3D Vector
1183 :return: The vector in relation to the objects rotation.
1186 .. method:: applyMovement(movement, local=False)
1188 Sets the game object's movement.
1190 :arg movement: movement vector.
1191 :type movement: 3D Vector
1193 * False: you get the "global" movement ie: relative to world orientation.
1194 * True: you get the "local" movement ie: relative to object orientation.
1197 .. method:: applyRotation(rotation, local=False)
1199 Sets the game object's rotation.
1201 :arg rotation: rotation vector.
1202 :type rotation: 3D Vector
1204 * False: you get the "global" rotation ie: relative to world orientation.
1205 * True: you get the "local" rotation ie: relative to object orientation.
1208 .. method:: applyForce(force, local=False)
1210 Sets the game object's force.
1212 This requires a dynamic object.
1214 :arg force: force vector.
1215 :type force: 3D Vector
1217 * False: you get the "global" force ie: relative to world orientation.
1218 * True: you get the "local" force ie: relative to object orientation.
1219 :type local: boolean
1221 .. method:: applyTorque(torque, local=False)
1223 Sets the game object's torque.
1225 This requires a dynamic object.
1227 :arg torque: torque vector.
1228 :type torque: 3D Vector
1230 * False: you get the "global" torque ie: relative to world orientation.
1231 * True: you get the "local" torque ie: relative to object orientation.
1232 :type local: boolean
1234 .. method:: getLinearVelocity(local=False)
1236 Gets the game object's linear velocity.
1238 This method returns the game object's velocity through it's centre of mass, ie no angular velocity component.
1241 * False: you get the "global" velocity ie: relative to world orientation.
1242 * True: you get the "local" velocity ie: relative to object orientation.
1243 :type local: boolean
1244 :return: the object's linear velocity.
1245 :rtype: list [vx, vy, vz]
1247 .. method:: setLinearVelocity(velocity, local=False)
1249 Sets the game object's linear velocity.
1251 This method sets game object's velocity through it's centre of mass,
1252 ie no angular velocity component.
1254 This requires a dynamic object.
1256 :arg velocity: linear velocity vector.
1257 :type velocity: 3D Vector
1259 * False: you get the "global" velocity ie: relative to world orientation.
1260 * True: you get the "local" velocity ie: relative to object orientation.
1261 :type local: boolean
1263 .. method:: getAngularVelocity(local=False)
1265 Gets the game object's angular velocity.
1268 * False: you get the "global" velocity ie: relative to world orientation.
1269 * True: you get the "local" velocity ie: relative to object orientation.
1270 :type local: boolean
1271 :return: the object's angular velocity.
1272 :rtype: list [vx, vy, vz]
1274 .. method:: setAngularVelocity(velocity, local=False)
1276 Sets the game object's angular velocity.
1278 This requires a dynamic object.
1280 :arg velocity: angular velocity vector.
1281 :type velocity: boolean
1283 * False: you get the "global" velocity ie: relative to world orientation.
1284 * True: you get the "local" velocity ie: relative to object orientation.
1286 .. method:: getVelocity(point=(0, 0, 0))
1288 Gets the game object's velocity at the specified point.
1290 Gets the game object's velocity at the specified point, including angular
1293 :arg point: optional point to return the velocity for, in local coordinates.
1294 :type point: 3D Vector
1295 :return: the velocity at the specified point.
1296 :rtype: list [vx, vy, vz]
1298 .. method:: getReactionForce()
1300 Gets the game object's reaction force.
1302 The reaction force is the force applied to this object over the last simulation timestep.
1303 This also includes impulses, eg from collisions.
1305 :return: the reaction force of this object.
1306 :rtype: list [fx, fy, fz]
1310 This is not implimented at the moment.
1312 .. method:: applyImpulse(point, impulse)
1314 Applies an impulse to the game object.
1316 This will apply the specified impulse to the game object at the specified point.
1317 If point != position, applyImpulse will also change the object's angular momentum.
1318 Otherwise, only linear momentum will change.
1320 :arg point: the point to apply the impulse to (in world coordinates)
1321 :type point: the point to apply the impulse to (in world coordinates)
1323 .. method:: suspendDynamics()
1325 Suspends physics for this object.
1327 .. method:: restoreDynamics()
1329 Resumes physics for this object.
1333 The objects linear velocity will be applied from when the dynamics were suspended.
1335 .. method:: enableRigidBody()
1337 Enables rigid body physics for this object.
1339 Rigid body physics allows the object to roll on collisions.
1343 This is not working with bullet physics yet.
1345 .. method:: disableRigidBody()
1347 Disables rigid body physics for this object.
1351 This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
1353 .. method:: setParent(parent, compound=True, ghost=True)
1355 Sets this object's parent.
1356 Control the shape status with the optional compound and ghost parameters:
1358 In that case you can control if it should be ghost or not:
1360 :arg parent: new parent object.
1361 :type parent: :class:`KX_GameObject`
1362 :arg compound: whether the shape should be added to the parent compound shape.
1364 * True: the object shape should be added to the parent compound shape.
1365 * False: the object should keep its individual shape.
1367 :type compound: boolean
1368 :arg ghost: whether the object should be ghost while parented.
1370 * True: if the object should be made ghost while parented.
1371 * False: if the object should be solid while parented.
1373 :type ghost: boolean
1377 If the object type is sensor, it stays ghost regardless of ghost parameter
1379 .. method:: removeParent()
1381 Removes this objects parent.
1383 .. method:: getPhysicsId()
1385 Returns the user data object associated with this game object's physics controller.
1387 .. method:: getPropertyNames()
1389 Gets a list of all property names.
1391 :return: All property names for this object.
1394 .. method:: getDistanceTo(other)
1396 :arg other: a point or another :class:`KX_GameObject` to measure the distance to.
1397 :type other: :class:`KX_GameObject` or list [x, y, z]
1398 :return: distance to another object or point.
1401 .. method:: getVectTo(other)
1403 Returns the vector and the distance to another object or point.
1404 The vector is normalized unless the distance is 0, in which a zero length vector is returned.
1406 :arg other: a point or another :class:`KX_GameObject` to get the vector and distance to.
1407 :type other: :class:`KX_GameObject` or list [x, y, z]
1408 :return: (distance, globalVector(3), localVector(3))
1409 :rtype: 3-tuple (float, 3-tuple (x, y, z), 3-tuple (x, y, z))
1411 .. method:: rayCastTo(other, dist, prop)
1413 Look towards another point/object and find first object hit within dist that matches prop.
1415 The ray is always casted from the center of the object, ignoring the object itself.
1416 The ray is casted towards the center of another object or an explicit [x, y, z] point.
1417 Use rayCast() if you need to retrieve the hit point
1419 :arg other: [x, y, z] or object towards which the ray is casted
1420 :type other: :class:`KX_GameObject` or 3-tuple
1421 :arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
1423 :arg prop: property name that object must have; can be omitted => detect any object
1425 :return: the first object hit or None if no object or object does not match prop
1426 :rtype: :class:`KX_GameObject`
1428 .. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly)
1430 Look from a point/object to another point/object and find first object hit within dist that matches prop.
1431 if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit.
1432 if poly is 1, returns a 4-tuple with in addition a :class:`KX_PolyProxy` as 4th element.
1433 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.
1435 .. code-block:: python
1437 # shoot along the axis gun-gunAim (gunAim should be collision-free)
1438 obj, point, normal = gun.rayCast(gunAim, None, 50)
1443 The face paremeter determines the orientation of the normal.
1445 * 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
1446 * 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
1448 The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
1449 The prop and xray parameters interact as follow.
1451 * prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
1452 * prop off, xray on : idem.
1453 * prop on, xray off: return closest hit if it matches prop, no hit otherwise.
1454 * 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.
1456 The :class:`KX_PolyProxy` 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
1457 If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
1459 The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
1461 :arg objto: [x, y, z] or object to which the ray is casted
1462 :type objto: :class:`KX_GameObject` or 3-tuple
1463 :arg objfrom: [x, y, z] or object from which the ray is casted; None or omitted => use self object center
1464 :type objfrom: :class:`KX_GameObject` or 3-tuple or None
1465 :arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
1467 :arg prop: property name that object must have; can be omitted or "" => detect any object
1469 :arg face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
1471 :arg xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
1473 :arg poly: polygon option: 0, 1 or 2 to return a 3-, 4- or 5-tuple with information on the face hit.
1475 * 0 or omitted: return value is a 3-tuple (object, hitpoint, hitnormal) or (None, None, None) if no hit
1476 * 1: return value is a 4-tuple and the 4th element is a :class:`KX_PolyProxy` or None if no hit or the object doesn't use a mesh collision shape.
1477 * 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping.
1480 :return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
1482 * object, hitpoint and hitnormal are None if no hit.
1483 * polygon is valid only if the object is valid and is a static object, a dynamic object using mesh collision shape or a soft body object, otherwise it is None
1484 * hituv is valid only if polygon is valid and the object has a UV mapping, otherwise it is None
1488 * 3-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz))
1489 * or 4-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`PolyProxy`)
1490 * or 5-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`PolyProxy`, 2-tuple (u, v))
1494 The ray ignores the object on which the method is called. It is casted from/to object center or explicit [x, y, z] points.
1496 .. method:: setCollisionMargin(margin)
1498 Set the objects collision margin.
1500 :arg margin: the collision margin distance in blender units.
1505 If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
1507 .. method:: sendMessage(subject, body="", to="")
1511 :arg subject: The subject of the message
1512 :type subject: string
1513 :arg body: The body of the message (optional)
1515 :arg to: The name of the object to send the message to (optional)
1518 .. method:: reinstancePhysicsMesh(gameObject, meshObject)
1520 Updates the physics system with the changed mesh.
1522 If no arguments are given the physics mesh will be re-created from the first mesh assigned to the game object.
1524 :arg gameObject: optional argument, set the physics shape from this gameObjets mesh.
1525 :type gameObject: string, :class:`KX_GameObject` or None
1526 :arg meshObject: optional argument, set the physics shape from this mesh.
1527 :type meshObject: string, :class:`MeshProxy` or None
1529 :return: True if reinstance succeeded, False if it failed.
1534 If this object has instances the other instances will be updated too.
1538 The gameObject argument has an advantage that it can convert from a mesh with modifiers applied (such as subsurf).
1542 Only triangle mesh type objects are supported currently (not convex hull)
1546 If the object is a part of a combound object it will fail (parent or child)
1550 Rebuilding the physics mesh can be slow, running many times per second will give a performance hit.
1552 .. method:: get(key, default=None)
1554 Return the value matching key, or the default value if its not found.
1555 :return: The key value or a default.
1557 .. class:: KX_IpoActuator(SCA_IActuator)
1559 IPO actuator activates an animation.
1561 .. attribute:: frameStart
1567 .. attribute:: frameEnd
1573 .. attribute:: propName
1575 Use this property to define the Ipo position.
1579 .. attribute:: framePropName
1581 Assign this property this action current frame number.
1587 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).
1591 .. attribute:: useIpoAsForce
1593 Apply Ipo as a global or local force depending on the local option (dynamic objects only).
1597 .. attribute:: useIpoAdd
1599 Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag.
1603 .. attribute:: useIpoLocal
1605 Let the ipo acts in local coordinates, used in Force and Add mode.
1609 .. attribute:: useChildren
1611 Update IPO on all children Objects as well.
1615 .. class:: KX_LightObject(KX_GameObject)
1619 .. code-block:: python
1621 # Turn on a red alert light.
1624 co = bge.logic.getCurrentController()
1628 light.colour = [1.0, 0.0, 0.0]
1632 A spot light source. See attribute :data:`type`
1636 A point light source with no attenuation. See attribute :data:`type`
1640 A point light source. See attribute :data:`type`
1644 The type of light - must be SPOT, SUN or NORMAL
1646 .. attribute:: layer
1648 The layer mask that this light affects object on.
1652 .. attribute:: energy
1654 The brightness of this light.
1658 .. attribute:: distance
1660 The maximum distance this light can illuminate. (SPOT and NORMAL lights only).
1664 .. attribute:: colour
1666 The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
1668 :type: list [r, g, b]
1670 .. attribute:: color
1674 .. attribute:: lin_attenuation
1676 The linear component of this light's attenuation. (SPOT and NORMAL lights only).
1680 .. attribute:: quad_attenuation
1682 The quadratic component of this light's attenuation (SPOT and NORMAL lights only).
1686 .. attribute:: spotsize
1688 The cone angle of the spot light, in degrees (SPOT lights only).
1690 :type: float in [0 - 180].
1692 .. attribute:: spotblend
1694 Specifies the intensity distribution of the spot light (SPOT lights only).
1696 :type: float in [0 - 1]
1700 Higher values result in a more focused light source.
1702 .. class:: KX_MeshProxy(SCA_IObject)
1706 You can only change the vertex properties of a mesh object, not the mesh topology.
1708 To use mesh objects effectively, you should know a bit about how the game engine handles them.
1710 #. Mesh Objects are converted from Blender at scene load.
1711 #. The Converter groups polygons by Material. This means they can be sent to the renderer efficiently. A material holds:
1714 #. The Blender material.
1715 #. The Tile properties
1716 #. The face properties - (From the "Texture Face" panel)
1717 #. Transparency & z sorting
1719 #. Polygon shape (triangle/quad)
1722 #. Verticies will be split by face if necessary. Verticies can only be shared between faces if:
1724 #. They are at the same position
1725 #. UV coordinates are the same
1726 #. Their normals are the same (both polygons are "Set Smooth")
1727 #. They are the same colour, for example: a cube has 24 verticies: 6 faces with 4 verticies per face.
1729 The correct method of iterating over every :class:`KX_VertexProxy` in a game object
1731 .. code-block:: python
1735 co = GameLogic.getCurrentController()
1739 mesh = obj.getMesh(m_i) # There can be more than one mesh...
1741 for mat in range(mesh.getNumMaterials()):
1742 for v_index in range(mesh.getVertexArrayLength(mat)):
1743 vertex = mesh.getVertex(mat, v_index)
1744 # Do something with vertex here...
1745 # ... eg: colour the vertex red.
1746 vertex.colour = [1.0, 0.0, 0.0, 1.0]
1748 mesh = obj.getMesh(m_i)
1750 .. attribute:: materials
1752 :type: list of :class:`KX_BlenderMaterial` or :class:`KX_PolygonMaterial` types
1754 .. attribute:: numPolygons
1758 .. attribute:: numMaterials
1762 .. method:: getNumMaterials()
1764 :return: number of materials associated with this object
1767 .. method:: getMaterialName(matid)
1769 Gets the name of the specified material.
1771 :arg matid: the specified material.
1772 :type matid: integer
1773 :return: the attached material name.
1776 .. method:: getTextureName(matid)
1778 Gets the name of the specified material's texture.
1780 :arg matid: the specified material
1781 :type matid: integer
1782 :return: the attached material's texture name.
1785 .. method:: getVertexArrayLength(matid)
1787 Gets the length of the vertex array associated with the specified material.
1789 There is one vertex array for each material.
1791 :arg matid: the specified material
1792 :type matid: integer
1793 :return: the number of verticies in the vertex array.
1796 .. method:: getVertex(matid, index)
1798 Gets the specified vertex from the mesh object.
1800 :arg matid: the specified material
1801 :type matid: integer
1802 :arg index: the index into the vertex array.
1803 :type index: integer
1804 :return: a vertex object.
1805 :rtype: :class:`KX_VertexProxy`
1807 .. method:: getNumPolygons()
1809 :return: The number of polygon in the mesh.
1812 .. method:: getPolygon(index)
1814 Gets the specified polygon from the mesh.
1816 :arg index: polygon number
1817 :type index: integer
1818 :return: a polygon object.
1819 :rtype: :class:`PolyProxy`
1821 .. class:: SCA_MouseSensor(SCA_ISensor)
1823 Mouse Sensor logic brick.
1827 .. attribute:: position
1829 current [x, y] coordinates of the mouse, in frame coordinates (pixels).
1831 :type: [integer, interger]
1839 * KX_MOUSESENSORMODE_LEFTBUTTON(1)
1840 * KX_MOUSESENSORMODE_MIDDLEBUTTON(2)
1841 * KX_MOUSESENSORMODE_RIGHTBUTTON(3)
1842 * KX_MOUSESENSORMODE_WHEELUP(4)
1843 * KX_MOUSESENSORMODE_WHEELDOWN(5)
1844 * KX_MOUSESENSORMODE_MOVEMENT(6)
1846 .. method:: getButtonStatus(button)
1848 Get the mouse button status.
1850 :arg button: value in GameLogic members KX_MOUSE_BUT_LEFT, KX_MOUSE_BUT_MIDDLE, KX_MOUSE_BUT_RIGHT
1851 :type button: integer
1852 :return: value in GameLogic members KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED
1855 .. class:: KX_MouseFocusSensor(SCA_MouseSensor)
1857 The mouse focus sensor detects when the mouse is over the current game object.
1859 The mouse focus sensor works by transforming the mouse coordinates from 2d device
1860 space to 3d space then raycasting away from the camera.
1862 .. attribute:: raySource
1864 The worldspace source of the ray (the view position).
1866 :type: list (vector of 3 floats)
1868 .. attribute:: rayTarget
1870 The worldspace target of the ray.
1872 :type: list (vector of 3 floats)
1874 .. attribute:: rayDirection
1876 The :data:`rayTarget` - :class:`raySource` normalized.
1878 :type: list (normalized vector of 3 floats)
1880 .. attribute:: hitObject
1882 the last object the mouse was over.
1884 :type: :class:`KX_GameObject` or None
1886 .. attribute:: hitPosition
1888 The worldspace position of the ray intersecton.
1890 :type: list (vector of 3 floats)
1892 .. attribute:: hitNormal
1894 the worldspace normal from the face at point of intersection.
1896 :type: list (normalized vector of 3 floats)
1898 .. attribute:: hitUV
1900 the UV coordinates at the point of intersection.
1902 :type: list (vector of 2 floats)
1904 If the object has no UV mapping, it returns [0, 0].
1906 The UV coordinates are not normalized, they can be < 0 or > 1 depending on the UV mapping.
1908 .. attribute:: usePulseFocus
1910 When enabled, moving the mouse over a different object generates a pulse. (only used when the 'Mouse Over Any' sensor option is set).
1914 .. class:: KX_TouchSensor(SCA_ISensor)
1916 Touch sensor detects collisions between objects.
1918 .. attribute:: propName
1920 The property or material to collide with.
1924 .. attribute:: useMaterial
1926 Determines if the sensor is looking for a property or material. KX_True = Find material; KX_False = Find property.
1930 .. attribute:: usePulseCollision
1932 When enabled, changes to the set of colliding objects generate a pulse.
1936 .. attribute:: hitObject
1938 The last collided object. (read-only).
1940 :type: :class:`KX_GameObject` or None
1942 .. attribute:: hitObjectList
1944 A list of colliding objects. (read-only).
1946 :type: :class:`CListValue` of :class:`KX_GameObject`
1948 .. class:: KX_NearSensor(KX_TouchSensor)
1950 A near sensor is a specialised form of touch sensor.
1952 .. attribute:: distance
1954 The near sensor activates when an object is within this distance.
1958 .. attribute:: resetDistance
1960 The near sensor deactivates when the object exceeds this distance.
1964 .. class:: KX_NetworkMessageActuator(SCA_IActuator)
1968 .. attribute:: propName
1970 Messages will only be sent to objects with the given property name.
1974 .. attribute:: subject
1976 The subject field of the message.
1982 The body of the message.
1986 .. attribute:: usePropBody
1988 Send a property instead of a regular body message.
1992 .. class:: KX_NetworkMessageSensor(SCA_ISensor)
1994 The Message Sensor logic brick.
1996 Currently only loopback (local) networks are supported.
1998 .. attribute:: subject
2000 The subject the sensor is looking for.
2004 .. attribute:: frameMessageCount
2006 The number of messages received since the last frame. (read-only).
2010 .. attribute:: subjects
2012 The list of message subjects received. (read-only).
2014 :type: list of strings
2016 .. attribute:: bodies
2018 The list of message bodies received. (read-only).
2020 :type: list of strings
2022 .. class:: KX_ObjectActuator(SCA_IActuator)
2024 The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
2025 velocity, or angular velocity to an object.
2026 Servo control allows to regulate force to achieve a certain speed target.
2028 .. attribute:: force
2030 The force applied by the actuator.
2032 :type: list [x, y, z]
2034 .. attribute:: useLocalForce
2036 A flag specifying if the force is local.
2040 .. attribute:: torque
2042 The torque applied by the actuator.
2044 :type: list [x, y, z]
2046 .. attribute:: useLocalTorque
2048 A flag specifying if the torque is local.
2054 The displacement vector applied by the actuator.
2056 :type: list [x, y, z]
2058 .. attribute:: useLocalDLoc
2060 A flag specifying if the dLoc is local.
2066 The angular displacement vector applied by the actuator
2068 :type: list [x, y, z]
2072 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.
2074 .. attribute:: useLocalDRot
2076 A flag specifying if the dRot is local.
2082 The linear velocity applied by the actuator.
2084 :type: list [x, y, z]
2086 .. attribute:: useLocalLinV
2088 A flag specifying if the linear velocity is local.
2094 This is the target speed for servo controllers.
2098 The angular velocity applied by the actuator.
2100 :type: list [x, y, z]
2102 .. attribute:: useLocalAngV
2104 A flag specifying if the angular velocity is local.
2108 .. attribute:: damping
2110 The damping parameter of the servo controller.
2114 .. attribute:: forceLimitX
2116 The min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
2118 :type: list [min(float), max(float), bool]
2120 .. attribute:: forceLimitY
2122 The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
2124 :type: list [min(float), max(float), bool]
2126 .. attribute:: forceLimitZ
2128 The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
2130 :type: list [min(float), max(float), bool]
2134 The PID coefficients of the servo controller.
2136 :type: list of floats [proportional, integral, derivate]
2138 .. attribute:: reference
2140 The object that is used as reference to compute the velocity for the servo controller.
2142 :type: :class:`KX_GameObject` or None
2144 .. class:: KX_ParentActuator(SCA_IActuator)
2146 The parent actuator can set or remove an objects parent object.
2148 .. attribute:: object
2150 the object this actuator sets the parent too.
2152 :type: :class:`KX_GameObject` or None
2156 The mode of this actuator.
2158 :type: integer from 0 to 1.
2160 .. attribute:: compound
2162 Whether the object shape should be added to the parent compound shape when parenting.
2164 Effective only if the parent is already a compound shape.
2168 .. attribute:: ghost
2170 whether the object should be made ghost when parenting
2171 Effective only if the shape is not added to the parent compound shape.
2175 .. class:: KX_PhysicsObjectWrapper(PyObjectPlus)
2177 KX_PhysicsObjectWrapper
2179 .. method:: setActive(active)
2181 Set the object to be active.
2183 :arg active: set to True to be active
2184 :type active: boolean
2186 .. method:: setAngularVelocity(x, y, z, local)
2188 Set the angular velocity of the object.
2190 :arg x: angular velocity for the x-axis
2193 :arg y: angular velocity for the y-axis
2196 :arg z: angular velocity for the z-axis
2199 :arg local: set to True for local axis
2200 :type local: boolean
2202 .. method:: setLinearVelocity(x, y, z, local)
2204 Set the linear velocity of the object.
2206 :arg x: linear velocity for the x-axis
2209 :arg y: linear velocity for the y-axis
2212 :arg z: linear velocity for the z-axis
2215 :arg local: set to True for local axis
2216 :type local: boolean
2218 .. class:: KX_PolyProxy(SCA_IObject)
2220 A polygon holds the index of the vertex forming the poylgon.
2223 The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
2224 to change the vertex settings.
2226 .. attribute:: matname
2228 The name of polygon material, empty if no material.
2232 .. attribute:: material
2234 The material of the polygon.
2236 :type: :class:`KX_PolygonMaterial` or :class:`KX_BlenderMaterial`
2238 .. attribute:: texture
2240 The texture name of the polygon.
2244 .. attribute:: matid
2246 The material index of the polygon, use this to retrieve vertex proxy from mesh proxy.
2252 vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
2258 vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
2264 vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
2270 vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
2271 use this to retrieve vertex proxy from mesh proxy.
2275 .. attribute:: visible
2277 visible state of the polygon: 1=visible, 0=invisible.
2281 .. attribute:: collide
2283 collide state of the polygon: 1=receives collision, 0=collision free.
2287 .. method:: getMaterialName()
2289 Returns the polygon material name with MA prefix
2291 :return: material name
2294 .. method:: getMaterial()
2296 :return: The polygon material
2297 :rtype: :class:`KX_PolygonMaterial` or :class:`KX_BlenderMaterial`
2299 .. method:: getTextureName()
2301 :return: The texture name
2304 .. method:: getMaterialIndex()
2306 Returns the material bucket index of the polygon.
2307 This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from :class:`MeshProxy`.
2309 :return: the material index in the mesh
2312 .. method:: getNumVertex()
2314 Returns the number of vertex of the polygon.
2316 :return: number of vertex, 3 or 4.
2319 .. method:: isVisible()
2321 Returns whether the polygon is visible or not
2323 :return: 0=invisible, 1=visible
2326 .. method:: isCollider()
2328 Returns whether the polygon is receives collision or not
2330 :return: 0=collision free, 1=receives collision
2333 .. method:: getVertexIndex(vertex)
2335 Returns the mesh vertex index of a polygon vertex
2336 This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from :class:`MeshProxy`.
2338 :arg vertex: index of the vertex in the polygon: 0->3
2339 :arg vertex: integer
2340 :return: mesh vertex index
2343 .. method:: getMesh()
2345 Returns a mesh proxy
2348 :rtype: :class:`MeshProxy`
2350 .. class:: KX_PolygonMaterial
2352 This is the interface to materials in the game engine.
2354 Materials define the render state to be applied to mesh objects.
2358 Some of the methods/variables are CObjects. If you mix these up, you will crash blender.
2360 This example requires `PyOpenGL <http://pyopengl.sourceforge.net>`_ and `GLEWPy <http://glewpy.sourceforge.net>`_
2362 .. code-block:: python
2366 from OpenGL.GL import *
2367 from OpenGL.GLU import *
2377 gl_Position = ftransform();
2381 fragment_shader ="""
2385 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
2393 self.m_program = glCreateProgramObjectARB()
2394 # Compile the vertex shader
2395 self.shader(GL_VERTEX_SHADER_ARB, (vertex_shader))
2396 # Compile the fragment shader
2397 self.shader(GL_FRAGMENT_SHADER_ARB, (fragment_shader))
2398 # Link the shaders together
2401 def PrintInfoLog(self, tag, object):
2403 PrintInfoLog prints the GLSL compiler log
2405 print "Tag: def PrintGLError(self, tag = ""):
2407 def PrintGLError(self, tag = ""):
2409 Prints the current GL error status
2414 if err != GL_NO_ERROR:
2415 print "GL Error: %s\\n"%(gluErrorString(err))
2417 def shader(self, type, shaders):
2419 shader compiles a GLSL shader and attaches it to the current
2422 type should be either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB
2423 shaders should be a sequence of shader source to compile.
2425 # Create a shader object
2426 shader_object = glCreateShaderObjectARB(type)
2428 # Add the source code
2429 glShaderSourceARB(shader_object, len(shaders), shaders)
2431 # Compile the shader
2432 glCompileShaderARB(shader_object)
2434 # Print the compiler log
2435 self.PrintInfoLog("vertex shader", shader_object)
2437 # Check if compiled, and attach if it did
2438 compiled = glGetObjectParameterivARB(shader_object, GL_OBJECT_COMPILE_STATUS_ARB)
2440 glAttachObjectARB(self.m_program, shader_object)
2442 # Delete the object (glAttachObjectARB makes a copy)
2443 glDeleteObjectARB(shader_object)
2445 # print the gl error log
2450 Links the shaders together.
2452 # clear error indicator
2455 glLinkProgramARB(self.m_program)
2457 self.PrintInfoLog("link", self.m_program)
2459 linked = glGetObjectParameterivARB(self.m_program, GL_OBJECT_LINK_STATUS_ARB)
2461 print "Shader failed to link"
2464 glValidateProgramARB(self.m_program)
2465 valid = glGetObjectParameterivARB(self.m_program, GL_OBJECT_VALIDATE_STATUS_ARB)
2467 print "Shader failed to validate"
2470 def activate(self, rasty, cachingInfo, mat):
2472 if (self.pass_no == 1):
2473 glDisable(GL_COLOR_MATERIAL)
2474 glUseProgramObjectARB(self.m_program)
2477 glEnable(GL_COLOR_MATERIAL)
2478 glUseProgramObjectARB(0)
2482 obj = GameLogic.getCurrentController().owner
2484 mesh = obj.meshes[0]
2486 for mat in mesh.materials:
2487 mat.setCustomMaterial(MyMaterial())
2490 .. attribute:: texture
2494 :type: string (read-only)
2496 .. attribute:: gl_texture
2498 OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture).
2500 :type: integer (read-only)
2502 .. attribute:: material
2506 :type: string (read-only)
2508 .. attribute:: tface
2510 Texture face properties.
2512 :type: CObject (read-only)
2520 .. attribute:: tilexrep
2522 Number of tile repetitions in x direction.
2526 .. attribute:: tileyrep
2528 Number of tile repetitions in y direction.
2532 .. attribute:: drawingmode
2534 Drawing mode for the material.
2535 - 2 (drawingmode & 4) Textured
2536 - 4 (drawingmode & 16) Light
2537 - 14 (drawingmode & 16384) 3d Polygon Text.
2541 .. attribute:: transparent
2543 This material is transparent. All meshes with this
2544 material will be rendered after non transparent meshes from back
2549 .. attribute:: zsort
2551 Transparent polygons in meshes with this material will be sorted back to
2552 front before rendering.
2553 Non-Transparent polygons will be sorted front to back before rendering.
2557 .. attribute:: lightlayer
2559 Light layers this material affects.
2563 .. attribute:: triangle
2565 Mesh data with this material is triangles. It's probably not safe to change this.
2569 .. attribute:: diffuse
2571 The diffuse colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
2573 :type: list [r, g, b]
2575 .. attribute:: specular
2577 The specular colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
2579 :type: list [r, g, b]
2581 .. attribute:: shininess
2583 The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0.
2587 .. attribute:: specularity
2589 The amount of specular of the material. 0.0 <= specularity <= 1.0.
2593 .. method:: updateTexture(tface, rasty)
2595 Updates a realtime animation.
2597 :arg tface: Texture face (eg mat.tface)
2598 :type tface: CObject
2599 :arg rasty: Rasterizer
2600 :type rasty: CObject
2602 .. method:: setTexture(tface)
2604 Sets texture render state.
2606 .. code-block:: python
2608 mat.setTexture(mat.tface)
2610 :arg tface: Texture face
2611 :type tface: CObject
2613 .. method:: activate(rasty, cachingInfo)
2615 Sets material parameters for this object for rendering.
2617 Material Parameters set:
2627 :arg rasty: Rasterizer instance.
2628 :type rasty: CObject
2629 :arg cachingInfo: Material cache instance.
2630 :type cachingInfo: CObject
2632 .. method:: setCustomMaterial(material)
2634 Sets the material state setup object.
2636 Using this method, you can extend or completely replace the gameengine material
2637 to do your own advanced multipass effects.
2639 Use this method to register your material class. Instead of the normal material,
2640 your class's activate method will be called just before rendering the mesh.
2641 This should setup the texture, material, and any other state you would like.
2642 It should return True to render the mesh, or False if you are finished. You should
2643 clean up any state Blender does not set before returning False.
2645 Activate Method Definition::
2646 `def activate(self, rasty, cachingInfo, material):`
2648 .. code-block:: python
2654 def activate(self, rasty, cachingInfo, material):
2655 # Activate the material here.
2657 # The activate method will be called until it returns False.
2658 # Every time the activate method returns True the mesh will
2661 # rasty is a CObject for passing to material.updateTexture()
2662 # and material.activate()
2663 # cachingInfo is a CObject for passing to material.activate()
2664 # material is the KX_PolygonMaterial instance this material
2667 # default material properties:
2669 if self.pass_no == 0:
2670 material.activate(rasty, cachingInfo)
2671 # Return True to do this pass
2674 # clean up and return False to finish.
2678 # Create a new Python Material and pass it to the renderer.
2679 mat.setCustomMaterial(PyMaterial())
2681 :arg material: The material object.
2682 :type material: instance
2684 .. class:: KX_RadarSensor(KX_NearSensor)
2686 Radar sensor is a near sensor with a conical sensor object.
2688 .. attribute:: coneOrigin
2690 The origin of the cone with which to test. The origin is in the middle of the cone. (read-only).
2692 :type: list of floats [x, y, z]
2694 .. attribute:: coneTarget
2696 The center of the bottom face of the cone with which to test. (read-only).
2698 :type: list of floats [x, y, z]
2700 .. attribute:: distance
2702 The height of the cone with which to test.
2706 .. attribute:: angle
2708 The angle of the cone (in degrees) with which to test.
2710 :type: float from 0 to 360
2714 The axis on which the radar cone is cast.
2716 :type: integer from 0 to 5
2718 KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z,
2719 KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
2721 .. method:: getConeHeight()
2723 :return: The height of the cone with which to test.
2726 .. class:: KX_RaySensor(SCA_ISensor)
2728 A ray sensor detects the first object in a given direction.
2730 .. attribute:: propName
2732 The property the ray is looking for.
2736 .. attribute:: range
2738 The distance of the ray.
2742 .. attribute:: useMaterial
2744 Whether or not to look for a material (false = property).
2748 .. attribute:: useXRay
2750 Whether or not to use XRay.
2754 .. attribute:: hitObject
2756 The game object that was hit by the ray. (read-only).
2758 :type: :class:`KX_GameObject`
2760 .. attribute:: hitPosition
2762 The position (in worldcoordinates) where the object was hit by the ray. (read-only).
2764 :type: list [x, y, z]
2766 .. attribute:: hitNormal
2768 The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (read-only).
2770 :type: list [x, y, z]
2772 .. attribute:: rayDirection
2774 The direction from the ray (in worldcoordinates). (read-only).
2776 :type: list [x, y, z]
2780 The axis the ray is pointing on.
2782 :type: integer from 0 to 5
2791 .. class:: KX_SCA_AddObjectActuator(SCA_IActuator)
2793 Edit Object Actuator (in Add Object Mode)
2797 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.
2799 This will genereate a warning in the console:
2801 ``Error: GameObject 'Name' has a AddObjectActuator 'ActuatorName' without object (in 'nonactive' layer)``
2803 .. attribute:: object
2805 the object this actuator adds.
2807 :type: :class:`KX_GameObject` or None
2809 .. attribute:: objectLastCreated
2811 the last added object from this actuator (read-only).
2813 :type: :class:`KX_GameObject` or None
2817 the lifetime of added objects, in frames. Set to 0 to disable automatic deletion.
2821 .. attribute:: linearVelocity
2823 the initial linear velocity of added objects.
2825 :type: list [vx, vy, vz]
2827 .. attribute:: angularVelocity
2829 the initial angular velocity of added objects.
2831 :type: list [vx, vy, vz]
2833 .. method:: instantAddObject()
2835 :return: The last object created by this actuator. The object can then be accessed from :data:`objectLastCreated`.
2838 .. class:: KX_SCA_DynamicActuator(SCA_IActuator)
2846 the type of operation of the actuator, 0-4
2848 * KX_DYN_RESTORE_DYNAMICS(0)
2849 * KX_DYN_DISABLE_DYNAMICS(1)
2850 * KX_DYN_ENABLE_RIGID_BODY(2)
2851 * KX_DYN_DISABLE_RIGID_BODY(3)
2852 * KX_DYN_SET_MASS(4)
2856 the mass value for the KX_DYN_SET_MASS operation.
2860 .. class:: KX_SCA_EndObjectActuator(SCA_IActuator)
2862 Edit Object Actuator (in End Object mode)
2864 This actuator has no python methods.
2866 .. class:: KX_SCA_ReplaceMeshActuator(SCA_IActuator)
2868 Edit Object actuator, in Replace Mesh mode.
2872 Replace mesh actuators will be ignored if at game start, the named mesh doesn't exist.
2874 This will generate a warning in the console
2876 ``Error: GameObject 'Name' ReplaceMeshActuator 'ActuatorName' without object``
2878 .. code-block:: python
2881 # Switch a game object's mesh based on its depth in the camera view.
2882 # +----------+ +-----------+ +-------------------------------------+
2883 # | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
2884 # +----------+ +-----------+ +-------------------------------------+
2887 # List detail meshes here
2888 # Mesh (name, near, far)
2889 # Meshes overlap so that they don't 'pop' when on the edge of the distance.
2890 meshes = ((".Hi", 0.0, -20.0),
2891 (".Med", -15.0, -50.0),
2892 (".Lo", -40.0, -100.0)
2895 co = GameLogic.getCurrentController()
2897 act = co.actuators["LOD." + obj.name]
2898 cam = GameLogic.getCurrentScene().active_camera
2900 def Depth(pos, plane):
2901 return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
2903 # Depth is negative and decreasing further from the camera
2904 depth = Depth(obj.position, cam.world_to_camera[2])
2908 # Find the lowest detail mesh for depth
2910 if depth < mesh[1] and depth > mesh[2]:
2912 if "ME" + obj.name + mesh[0] == act.getMesh():
2915 if newmesh != None and "ME" + obj.name + newmesh[0] != act.getMesh():
2916 # The mesh is a different mesh - switch it.
2917 # Check the current mesh is not a better fit.
2918 if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
2919 act.mesh = obj.getName() + newmesh[0]
2920 GameLogic.addActiveActuator(act, True)
2924 :class:`MeshProxy` or the name of the mesh that will replace the current one.
2926 Set to None to disable actuator.
2928 :type: :class:`MeshProxy` or None if no mesh is set
2930 .. attribute:: useDisplayMesh
2932 when true the displayed mesh is replaced.
2936 .. attribute:: usePhysicsMesh
2938 when true the physics mesh is replaced.
2942 .. method:: instantReplaceMesh()
2944 Immediately replace mesh without delay.
2946 .. class:: KX_Scene(PyObjectPlus)
2948 An active scene that gives access to objects, cameras, lights and scene attributes.
2950 The activity culling stuff is supposed to disable logic bricks when their owner gets too far
2951 from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
2954 .. code-block:: python
2959 scene = GameLogic.getCurrentScene()
2961 # print all the objects in the scene
2962 for obj in scene.objects:
2965 # get an object named 'Cube'
2966 obj = scene.objects["Cube"]
2968 # get the first object in the scene.
2969 obj = scene.objects[0]
2971 .. code-block:: python
2973 # Get the depth of an object in the camera view.
2976 obj = GameLogic.getCurrentController().owner
2977 cam = GameLogic.getCurrentScene().active_camera
2979 # Depth is negative and decreasing further from the camera
2980 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]
2982 @bug: All attributes are read only at the moment.
2986 The scene's name, (read-only).
2990 .. attribute:: objects
2992 A list of objects in the scene, (read-only).
2994 :type: :class:`CListValue` of :class:`KX_GameObject`
2996 .. attribute:: objectsInactive
2998 A list of objects on background layers (used for the addObject actuator), (read-only).
3000 :type: :class:`CListValue` of :class:`KX_GameObject`
3002 .. attribute:: lights
3004 A list of lights in the scene, (read-only).
3006 :type: :class:`CListValue` of :class:`KX_LightObject`
3008 .. attribute:: cameras
3010 A list of cameras in the scene, (read-only).
3012 :type: :class:`CListValue` of :class:`KX_Camera`
3014 .. attribute:: active_camera
3016 The current active camera.
3018 :type: :class:`KX_Camera`
3022 This can be set directly from python to avoid using the :class:`KX_SceneActuator`.
3024 .. attribute:: suspended
3026 True if the scene is suspended, (read-only).
3030 .. attribute:: activity_culling
3032 True if the scene is activity culling.
3036 .. attribute:: activity_culling_radius
3038 The distance outside which to do activity culling. Measured in manhattan distance.
3042 .. attribute:: dbvt_culling
3044 True when Dynamic Bounding box Volume Tree is set (read-only).
3048 .. attribute:: pre_draw
3050 A list of callables to be run before the render step.
3054 .. attribute:: post_draw
3056 A list of callables to be run after the render step.
3060 .. method:: addObject(object, other, time=0)
3062 Adds an object to the scene like the Add Object Actuator would.
3064 :arg object: The object to add
3065 :type object: :class:`KX_GameObject` or string
3066 :arg other: The object's center to use when adding the object
3067 :type other: :class:`KX_GameObject` or string
3068 :arg time: The lifetime of the added object, in frames. A time of 0 means the object will last forever.
3070 :return: The newly added object.
3071 :rtype: :class:`KX_GameObject`
3075 Removes the scene from the game.
3077 .. method:: restart()
3081 .. method:: replace(scene)
3083 Replaces this scene with another one.
3085 :arg scene: The name of the scene to replace this scene with.
3088 .. method:: suspend()
3090 Suspends this scene.
3092 .. method:: resume()
3096 .. method:: get(key, default=None)
3098 Return the value matching key, or the default value if its not found.
3099 :return: The key value or a default.
3101 .. class:: KX_SceneActuator(SCA_IActuator)
3103 Scene Actuator logic brick.
3107 Scene actuators that use a scene name will be ignored if at game start, the named scene doesn't exist or is empty
3109 This will generate a warning in the console:
3111 ``Error: GameObject 'Name' has a SceneActuator 'ActuatorName' (SetScene) without scene``
3113 .. attribute:: scene
3115 the name of the scene to change to/overlay/underlay/remove/suspend/resume.
3119 .. attribute:: camera
3121 the camera to change to.
3123 :type: :class:`KX_Camera` on read, string or :class:`KX_Camera` on write
3127 When setting the attribute, you can use either a :class:`KX_Camera` or the name of the camera.
3129 .. attribute:: useRestart
3131 Set flag to True to restart the sene.
3137 The mode of the actuator.
3139 :type: integer from 0 to 5.
3141 .. class:: KX_SoundActuator(SCA_IActuator)
3145 The :data:`startSound`, :data:`pauseSound` and :data:`stopSound` do not requirethe actuator to be activated - they act instantly provided that the actuator has been activated once at least.
3147 .. attribute:: fileName
3149 The filename of the sound this actuator plays.
3153 .. attribute:: volume
3155 The volume (gain) of the sound.
3159 .. attribute:: pitch
3161 The pitch of the sound.
3165 .. attribute:: rollOffFactor
3167 The roll off factor. Rolloff defines the rate of attenuation as the sound gets further away.
3171 .. attribute:: looping
3173 The loop mode of the actuator.
3177 .. attribute:: position
3179 The position of the sound as a list: [x, y, z].
3183 .. attribute:: velocity
3185 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].
3189 .. attribute:: orientation
3191 The orientation of the sound. When setting the orientation you can also use quaternion [float, float, float, float] or euler angles [float, float, float].
3193 :type: 3x3 matrix [[float]]
3197 The operation mode of the actuator.
3201 You can use one of the following constants:
3202 * KX_SOUNDACT_PLAYSTOP (1)
3203 * KX_SOUNDACT_PLAYEND (2)
3204 * KX_SOUNDACT_LOOPSTOP (3)
3205 * KX_SOUNDACT_LOOPEND (4)
3206 * KX_SOUNDACT_LOOPBIDIRECTIONAL (5)
3207 * KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP (6)
3209 .. class:: KX_StateActuator(SCA_IActuator)
3211 State actuator changes the state mask of parent object.
3215 .. attribute:: operation
3217 type of bit operation to be applied on object state mask.
3219 You can use one of the following constant:
3221 * KX_STATE_OP_CPY (0) : Copy state mask
3222 * KX_STATE_OP_SET (1) : Add bits to state mask
3223 * KX_STATE_OP_CLR (2) : Substract bits to state mask
3224 * KX_STATE_OP_NEG (3) : Invert bits to state mask.
3230 value that defines the bits that will be modified by the operation.
3231 The bits that are 1 in the mask will be updated in the object state,
3232 the bits that are 0 are will be left unmodified expect for the Copy operation
3233 which copies the mask to the object state.
3237 .. class:: KX_TrackToActuator(SCA_IActuator)
3239 Edit Object actuator in Track To mode.
3243 Track To Actuators will be ignored if at game start, the object to track to is invalid.
3245 This will generate a warning in the console:
3247 ``Error: GameObject 'Name' no object in EditObjectActuator 'ActuatorName'``
3249 .. attribute:: object
3251 the object this actuator tracks.
3253 :type: :class:`KX_GameObject` or None
3257 the time in frames with which to delay the tracking motion.
3261 .. attribute:: use3D
3263 the tracking motion to use 3D.
3267 .. class:: KX_VehicleWrapper(PyObjectPlus)
3273 .. method:: addWheel(wheel, attachPos, attachDir, axleDir, suspensionRestLength, wheelRadius, hasSteering)
3275 Add a wheel to the vehicle
3277 :arg wheel: The object to use as a wheel.
3278 :type wheel: :class:`KX_GameObject` or a KX_GameObject name
3279 :arg attachPos: The position that this wheel will attach to.
3280 :type attachPos: vector of 3 floats
3281 :arg attachDir: The direction this wheel points.
3282 :type attachDir: vector of 3 floats
3283 :arg axleDir: The direction of this wheels axle.
3284 :type axleDir: vector of 3 floats
3285 :arg suspensionRestLength: TODO - Description
3286 :type suspensionRestLength: float
3287 :arg wheelRadius: The size of the wheel.
3288 :type wheelRadius: float
3290 .. method:: applyBraking(force, wheelIndex)
3292 Apply a braking force to the specified wheel
3294 :arg force: the brake force
3297 :arg wheelIndex: index of the wheel where the force needs to be applied
3298 :type wheelIndex: integer
3300 .. method:: applyEngineForce(force, wheelIndex)
3302 Apply an engine force to the specified wheel
3304 :arg force: the engine force
3307 :arg wheelIndex: index of the wheel where the force needs to be applied
3308 :type wheelIndex: integer
3310 .. method:: getConstraintId()
3312 Get the constraint ID
3314 :return: the constraint id
3317 .. method:: getConstraintType()
3319 Returns the constraint type.
3321 :return: constraint type
3324 .. method:: getNumWheels()
3326 Returns the number of wheels.
3328 :return: the number of wheels for this vehicle
3331 .. method:: getWheelOrientationQuaternion(wheelIndex)
3333 Returns the wheel orientation as a quaternion.
3335 :arg wheelIndex: the wheel index
3336 :type wheelIndex: integer
3338 :return: TODO Description
3339 :rtype: TODO - type should be quat as per method name but from the code it looks like a matrix
3341 .. method:: getWheelPosition(wheelIndex)
3343 Returns the position of the specified wheel
3345 :arg wheelIndex: the wheel index
3346 :type wheelIndex: integer
3347 :return: position vector
3348 :rtype: list[x, y, z]
3350 .. method:: getWheelRotation(wheelIndex)
3352 Returns the rotation of the specified wheel
3354 :arg wheelIndex: the wheel index
3355 :type wheelIndex: integer
3357 :return: the wheel rotation
3360 .. method:: setRollInfluence(rollInfluece, wheelIndex)
3362 Set the specified wheel's roll influence.
3363 The higher the roll influence the more the vehicle will tend to roll over in corners.
3365 :arg rollInfluece: the wheel roll influence
3366 :type rollInfluece: float
3368 :arg wheelIndex: the wheel index
3369 :type wheelIndex: integer
3371 .. method:: setSteeringValue(steering, wheelIndex)
3373 Set the specified wheel's steering
3375 :arg steering: the wheel steering
3376 :type steering: float
3378 :arg wheelIndex: the wheel index
3379 :type wheelIndex: integer
3381 .. method:: setSuspensionCompression(compression, wheelIndex)
3383 Set the specified wheel's compression
3385 :arg compression: the wheel compression
3386 :type compression: float
3388 :arg wheelIndex: the wheel index
3389 :type wheelIndex: integer
3391 .. method:: setSuspensionDamping(damping, wheelIndex)
3393 Set the specified wheel's damping
3395 :arg damping: the wheel damping
3396 :type damping: float
3398 :arg wheelIndex: the wheel index
3399 :type wheelIndex: integer
3401 .. method:: setSuspensionStiffness(stiffness, wheelIndex)
3403 Set the specified wheel's stiffness
3405 :arg stiffness: the wheel stiffness
3406 :type stiffness: float
3408 :arg wheelIndex: the wheel index
3409 :type wheelIndex: integer
3411 .. method:: setTyreFriction(friction, wheelIndex)
3413 Set the specified wheel's tyre friction
3415 :arg friction: the tyre friction
3416 :type friction: float
3418 :arg wheelIndex: the wheel index
3419 :type wheelIndex: integer
3421 .. class:: KX_VertexProxy(SCA_IObject)
3423 A vertex holds position, UV, colour and normal information.
3426 The physics simulation is NOT currently updated - physics will not respond
3427 to changes in the vertex position.
3431 The position of the vertex.
3433 :type: list [x, y, z]
3437 The texture coordinates of the vertex.
3441 .. attribute:: normal
3443 The normal of the vertex.
3445 :type: list [nx, ny, nz]
3447 .. attribute:: colour
3449 The colour of the vertex.
3451 :type: list [r, g, b, a]
3453 Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
3455 .. attribute:: color
3461 The x coordinate of the vertex.
3467 The y coordinate of the vertex.
3473 The z coordinate of the vertex.
3479 The u texture coordinate of the vertex.
3485 The v texture coordinate of the vertex.
3491 The second u texture coordinate of the vertex.
3497 The second v texture coordinate of the vertex.
3503 The red component of the vertex colour. 0.0 <= r <= 1.0.
3509 The green component of the vertex colour. 0.0 <= g <= 1.0.
3515 The blue component of the vertex colour. 0.0 <= b <= 1.0.
3521 The alpha component of the vertex colour. 0.0 <= a <= 1.0.
3525 .. method:: getXYZ()
3527 Gets the position of this vertex.
3529 :return: this vertexes position in local coordinates.
3530 :rtype: list [x, y, z]
3532 .. method:: setXYZ(pos)
3534 Sets the position of this vertex.
3536 :type: list [x, y, z]
3538 :arg pos: the new position for this vertex in local coordinates.
3542 Gets the UV (texture) coordinates of this vertex.
3544 :return: this vertexes UV (texture) coordinates.
3547 .. method:: setUV(uv)
3549 Sets the UV (texture) coordinates of this vertex.
3553 .. method:: getUV2()
3555 Gets the 2nd UV (texture) coordinates of this vertex.
3557 :return: this vertexes UV (texture) coordinates.
3560 .. method:: setUV2(uv, unit)
3562 Sets the 2nd UV (texture) coordinates of this vertex.
3566 :arg unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
3569 .. method:: getRGBA()
3571 Gets the colour of this vertex.
3573 The colour is represented as four bytes packed into an integer value. The colour is
3576 Since Python offers no way to get each byte without shifting, you must use the struct module to
3577 access colour in an machine independent way.
3579 Because of this, it is suggested you use the r, g, b and a attributes or the colour attribute instead.
3581 .. code-block:: python
3584 col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
3585 # col = (r, g, b, a)
3586 # black = ( 0, 0, 0, 255)
3587 # white = (255, 255, 255, 255)
3589 :return: packed colour. 4 byte integer with one byte per colour channel in RGBA format.
3592 .. method:: setRGBA(col)
3594 Sets the colour of this vertex.
3596 See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes
3597 or the colour attribute instead.
3599 setRGBA() also accepts a four component list as argument col. The list represents the colour as [r, g, b, a]
3600 with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0]
3602 .. code-block:: python
3604 v.setRGBA(0xff0000ff) # Red
3605 v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
3606 v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
3607 v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
3609 :arg col: the new colour of this vertex in packed RGBA format.
3610 :type col: integer or list [r, g, b, a]
3612 .. method:: getNormal()
3614 Gets the normal vector of this vertex.
3616 :return: normalised normal vector.
3617 :rtype: list [nx, ny, nz]
3619 .. method:: setNormal(normal)
3621 Sets the normal vector of this vertex.
3623 :type: sequence of floats [r, g, b]
3625 :arg normal: the new normal of this vertex.
3627 .. class:: KX_VisibilityActuator(SCA_IActuator)
3629 Visibility Actuator.
3631 .. attribute:: visibility
3633 whether the actuator makes its parent object visible or invisible.
3637 .. attribute:: useOcclusion
3639 whether the actuator makes its parent object an occluder or not.
3643 .. attribute:: useRecursion
3645 whether the visibility/occlusion should be propagated to all children of the object.
3649 .. class:: SCA_2DFilterActuator(SCA_IActuator)
3651 Create, enable and disable 2D filters
3655 The following properties don't have an immediate effect.
3656 You must active the actuator to get the result.
3657 The actuator is not persistent: it automatically stops itself after setting up the filter
3658 but the filter remains active. To stop a filter you must activate the actuator with 'type'
3659 set to RAS_2DFILTER_DISABLED or RAS_2DFILTER_NOFILTER.
3661 .. attribute:: shaderText
3663 shader source code for custom shader.
3667 .. attribute:: disableMotionBlur
3669 action on motion blur: 0=enable, 1=disable.
3675 type of 2D filter, use one of the following constants:
3677 * RAS_2DFILTER_ENABLED (-2) : enable the filter that was previously disabled
3678 * RAS_2DFILTER_DISABLED (-1) : disable the filter that is currently active
3679 * RAS_2DFILTER_NOFILTER (0) : disable and destroy the filter that is currently active
3680 * RAS_2DFILTER_MOTIONBLUR (1) : create and enable preset filters
3681 * RAS_2DFILTER_BLUR (2)
3682 * RAS_2DFILTER_SHARPEN (3)
3683 * RAS_2DFILTER_DILATION (4)
3684 * RAS_2DFILTER_EROSION (5)
3685 * RAS_2DFILTER_LAPLACIAN (6)
3686 * RAS_2DFILTER_SOBEL (7)
3687 * RAS_2DFILTER_PREWITT (8)
3688 * RAS_2DFILTER_GRAYSCALE (9)
3689 * RAS_2DFILTER_SEPIA (10)
3690 * RAS_2DFILTER_INVERT (11)
3691 * RAS_2DFILTER_CUSTOMFILTER (12) : customer filter, the code code is set via shaderText property.
3695 .. attribute:: passNumber
3697 order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
3699 Only be one filter can be defined per passNb.
3701 :type: integer (0-100)
3703 .. attribute:: value
3705 argument for motion blur filter.
3707 :type: float (0.0-100.0)
3709 .. class:: SCA_ANDController(SCA_IController)
3711 An AND controller activates only when all linked sensors are activated.
3713 There are no special python methods for this controller.
3715 .. class:: SCA_ActuatorSensor(SCA_ISensor)
3717 Actuator sensor detect change in actuator state of the parent object.
3718 It generates a positive pulse if the corresponding actuator is activated
3719 and a negative pulse if the actuator is deactivated.
3723 .. attribute:: actuator
3725 the name of the actuator that the sensor is monitoring.
3729 .. class:: SCA_AlwaysSensor(SCA_ISensor)
3731 This sensor is always activated.
3733 .. class:: SCA_DelaySensor(SCA_ISensor)
3735 The Delay sensor generates positive and negative triggers at precise time,
3736 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.
3738 The duration parameter defines the length of the ON period following the OFF period.
3739 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.
3741 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).
3743 Use :class:`SCA_ISensor.reset` at any time to restart sensor.
3747 .. attribute:: delay
3749 length of the initial OFF period as number of frame, 0 for immediate trigger.
3753 .. attribute:: duration
3755 length of the ON period in number of frame after the initial OFF period.
3757 If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
3761 .. attribute:: repeat
3763 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
3767 .. class:: SCA_JoystickSensor(SCA_ISensor)
3769 This sensor detects player joystick events.
3773 .. attribute:: axisValues
3775 The state of the joysticks axis as a list of values :data:`numAxis` long. (read-only).
3777 :type: list of ints.
3779 Each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
3780 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.
3782 * left:[-32767, 0, ...]
3783 * right:[32767, 0, ...]
3784 * up:[0, -32767, ...]
3785 * down:[0, 32767, ...]
3787 .. attribute:: axisSingle
3789 like :data:`axisValues` but returns a single axis value that is set by the sensor. (read-only).
3795 Only use this for "Single Axis" type sensors otherwise it will raise an error.
3797 .. attribute:: hatValues
3799 The state of the joysticks hats as a list of values :data:`numHats` long. (read-only).
3803 Each spesifying the direction of the hat from 1 to 12, 0 when inactive.
3805 Hat directions are as follows...