2011-07-08 02:59:25 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Physics Constraints (bge.constraints)
|
2011-07-31 03:15:37 +00:00
|
|
|
=====================================
|
2011-07-08 02:59:25 +00:00
|
|
|
|
2011-08-04 09:47:40 +00:00
|
|
|
.. module:: bge.constraints
|
|
|
|
|
2015-06-23 11:58:08 +00:00
|
|
|
|
|
|
|
Examples
|
|
|
|
--------
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
.. include:: ../examples/bge.constraints.py
|
|
|
|
:start-line: 1
|
|
|
|
:end-line: 4
|
2012-01-23 19:53:23 +00:00
|
|
|
|
|
|
|
.. literalinclude:: ../examples/bge.constraints.py
|
|
|
|
:lines: 6-
|
2011-08-04 09:47:40 +00:00
|
|
|
|
2015-06-23 11:58:08 +00:00
|
|
|
|
|
|
|
Functions
|
|
|
|
---------
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
.. function:: createConstraint( \
|
|
|
|
physicsid_1, physicsid_2, constraint_type, \
|
|
|
|
pivot_x=0.0, pivot_y=0.0, pivot_z=0.0, \
|
|
|
|
axis_x=0.0, axis_y=0.0, axis_z=0.0, flag=0)
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
Creates a constraint.
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg physicsid_1: The physics id of the first object in constraint.
|
|
|
|
:type physicsid_1: int
|
|
|
|
|
|
|
|
:arg physicsid_2: The physics id of the second object in constraint.
|
|
|
|
:type physicsid_2: int
|
|
|
|
|
|
|
|
:arg constraint_type: The type of the constraint, one of...
|
|
|
|
|
2015-05-12 07:59:37 +00:00
|
|
|
- :class:`POINTTOPOINT_CONSTRAINT`
|
|
|
|
- :class:`LINEHINGE_CONSTRAINT`
|
|
|
|
- :class:`ANGULAR_CONSTRAINT`
|
|
|
|
- :class:`CONETWIST_CONSTRAINT`
|
|
|
|
- :class:`VEHICLE_CONSTRAINT`
|
2015-06-23 11:29:37 +00:00
|
|
|
- :class:`GENERIC_6DOF_CONSTRAINT`
|
2015-05-20 16:49:18 +00:00
|
|
|
|
2015-06-16 11:22:41 +00:00
|
|
|
:type constraint_type: int
|
2015-05-20 16:49:18 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg pivot_x: Pivot X position. (optional)
|
2015-06-16 11:22:41 +00:00
|
|
|
:type pivot_x: float
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg pivot_y: Pivot Y position. (optional)
|
2015-06-16 11:22:41 +00:00
|
|
|
:type pivot_y: float
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg pivot_z: Pivot Z position. (optional)
|
2015-06-16 11:22:41 +00:00
|
|
|
:type pivot_z: float
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg axis_x: X axis angle in degrees. (optional)
|
2015-06-16 11:22:41 +00:00
|
|
|
:type axis_x: float
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg axis_y: Y axis angle in degrees. (optional)
|
2015-06-16 11:22:41 +00:00
|
|
|
:type axis_y: float
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg axis_z: Z axis angle in degrees. (optional)
|
2015-06-16 11:22:41 +00:00
|
|
|
:type axis_z: float
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg flag: 128 to disable collision between linked bodies. (optional)
|
2015-05-20 16:49:18 +00:00
|
|
|
:type flag: int
|
2011-07-08 02:59:25 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:return: A constraint wrapper.
|
|
|
|
:rtype: :class:`~bge.types.KX_ConstraintWrapper`
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
.. function:: exportBulletFile(filename)
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
Exports a file representing the dynamics world (usually using ``.bullet`` extension).
|
|
|
|
|
|
|
|
See `Bullet binary serialization <http://bulletphysics.org/mediawiki-1.5.8/index.php/Bullet_binary_serialization>`__.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
2015-06-23 11:58:08 +00:00
|
|
|
:arg filename: File path.
|
2015-06-23 11:29:37 +00:00
|
|
|
:type filename: str
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
.. function:: getAppliedImpulse(constraintId)
|
|
|
|
|
|
|
|
:arg constraintId: The id of the constraint.
|
|
|
|
:type constraintId: int
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:return: The most recent applied impulse.
|
2011-07-08 02:59:25 +00:00
|
|
|
:rtype: float
|
|
|
|
|
|
|
|
.. function:: getVehicleConstraint(constraintId)
|
|
|
|
|
|
|
|
:arg constraintId: The id of the vehicle constraint.
|
|
|
|
:type constraintId: int
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:return: A vehicle constraint object.
|
|
|
|
:rtype: :class:`~bge.types.KX_VehicleWrapper`
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2012-11-04 20:56:02 +00:00
|
|
|
.. function:: getCharacter(gameobj)
|
|
|
|
|
|
|
|
:arg gameobj: The game object with the character physics.
|
2015-06-23 11:29:37 +00:00
|
|
|
:type gameobj: :class:`~bge.types.KX_GameObject`
|
2012-11-04 20:56:02 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:return: Character wrapper.
|
|
|
|
:rtype: :class:`~bge.types.KX_CharacterWrapper`
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
.. function:: removeConstraint(constraintId)
|
|
|
|
|
|
|
|
Removes a constraint.
|
|
|
|
|
|
|
|
:arg constraintId: The id of the constraint to be removed.
|
|
|
|
:type constraintId: int
|
|
|
|
|
|
|
|
.. function:: setCcdMode(ccdMode)
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
.. note::
|
2011-07-08 02:59:25 +00:00
|
|
|
Very experimental, not recommended
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets the CCD (Continous Colision Detection) mode in the Physics Environment.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg ccdMode: The new CCD mode.
|
|
|
|
:type ccdMode: int
|
|
|
|
|
|
|
|
.. function:: setContactBreakingTreshold(breakingTreshold)
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
Reasonable default is 0.02 (if units are meters)
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets tresholds to do with contact point management.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg breakingTreshold: The new contact breaking treshold.
|
|
|
|
:type breakingTreshold: float
|
|
|
|
|
|
|
|
.. function:: setDeactivationAngularTreshold(angularTreshold)
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets the angular velocity treshold.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg angularTreshold: New deactivation angular treshold.
|
|
|
|
:type angularTreshold: float
|
|
|
|
|
|
|
|
.. function:: setDeactivationLinearTreshold(linearTreshold)
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets the linear velocity treshold.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg linearTreshold: New deactivation linear treshold.
|
|
|
|
:type linearTreshold: float
|
|
|
|
|
|
|
|
.. function:: setDeactivationTime(time)
|
|
|
|
|
|
|
|
Sets the time after which a resting rigidbody gets deactived.
|
|
|
|
|
|
|
|
:arg time: The deactivation time.
|
|
|
|
:type time: float
|
|
|
|
|
|
|
|
.. function:: setDebugMode(mode)
|
|
|
|
|
|
|
|
Sets the debug mode.
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
:arg mode: The new debug mode.
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
- :class:`DBG_NODEBUG`
|
|
|
|
- :class:`DBG_DRAWWIREFRAME`
|
|
|
|
- :class:`DBG_DRAWAABB`
|
|
|
|
- :class:`DBG_DRAWFREATURESTEXT`
|
|
|
|
- :class:`DBG_DRAWCONTACTPOINTS`
|
|
|
|
- :class:`DBG_NOHELPTEXT`
|
|
|
|
- :class:`DBG_DRAWTEXT`
|
|
|
|
- :class:`DBG_PROFILETIMINGS`
|
|
|
|
- :class:`DBG_ENABLESATCOMPARISION`
|
|
|
|
- :class:`DBG_DISABLEBULLETLCP`
|
|
|
|
- :class:`DBG_ENABLECCD`
|
|
|
|
- :class:`DBG_DRAWCONSTRAINTS`
|
|
|
|
- :class:`DBG_DRAWCONSTRAINTLIMITS`
|
|
|
|
- :class:`DBG_FASTWIREFRAME`
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:type mode: int
|
|
|
|
|
|
|
|
.. function:: setGravity(x, y, z)
|
|
|
|
|
|
|
|
Sets the gravity force.
|
|
|
|
|
|
|
|
:arg x: Gravity X force.
|
|
|
|
:type x: float
|
|
|
|
|
|
|
|
:arg y: Gravity Y force.
|
|
|
|
:type y: float
|
|
|
|
|
|
|
|
:arg z: Gravity Z force.
|
|
|
|
:type z: float
|
|
|
|
|
|
|
|
.. function:: setLinearAirDamping(damping)
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
.. note::
|
2015-06-23 11:29:37 +00:00
|
|
|
|
|
|
|
Not implemented
|
2011-07-30 23:16:22 +00:00
|
|
|
|
|
|
|
Sets the linear air damping for rigidbodies.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
.. function:: setNumIterations(numiter)
|
|
|
|
|
|
|
|
Sets the number of iterations for an iterative constraint solver.
|
|
|
|
|
|
|
|
:arg numiter: New number of iterations.
|
|
|
|
:type numiter: int
|
|
|
|
|
|
|
|
.. function:: setNumTimeSubSteps(numsubstep)
|
|
|
|
|
|
|
|
Sets the number of substeps for each physics proceed. Tradeoff quality for performance.
|
|
|
|
|
|
|
|
:arg numsubstep: New number of substeps.
|
|
|
|
:type numsubstep: int
|
|
|
|
|
|
|
|
.. function:: setSolverDamping(damping)
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
.. note::
|
2011-07-08 02:59:25 +00:00
|
|
|
Very experimental, not recommended
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets the damper constant of a penalty based solver.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg damping: New damping for the solver.
|
|
|
|
:type damping: float
|
|
|
|
|
|
|
|
.. function:: setSolverTau(tau)
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
Very experimental, not recommended
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets the spring constant of a penalty based solver.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg tau: New tau for the solver.
|
|
|
|
:type tau: float
|
|
|
|
|
|
|
|
.. function:: setSolverType(solverType)
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
Very experimental, not recommended
|
|
|
|
|
|
|
|
Sets the solver type.
|
|
|
|
|
|
|
|
:arg solverType: The new type of the solver.
|
|
|
|
:type solverType: int
|
|
|
|
|
|
|
|
.. function:: setSorConstant(sor)
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
Very experimental, not recommended
|
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Sets the successive overrelaxation constant.
|
2011-07-08 02:59:25 +00:00
|
|
|
|
|
|
|
:arg sor: New sor value.
|
|
|
|
:type sor: float
|
|
|
|
|
|
|
|
.. function:: setUseEpa(epa)
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
.. note::
|
2011-07-30 23:16:22 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
Not implemented
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
|
|
|
|
Constants
|
|
|
|
+++++++++
|
|
|
|
|
|
|
|
.. attribute:: error
|
|
|
|
|
|
|
|
Symbolic constant string that indicates error.
|
|
|
|
|
|
|
|
:type: str
|
|
|
|
|
|
|
|
|
|
|
|
Debug Mode Constants
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2015-06-23 12:57:38 +00:00
|
|
|
Debug mode to be used with :func:`setDebugMode`.
|
2015-06-23 11:29:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
.. data:: DBG_NODEBUG
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
No debug.
|
|
|
|
|
|
|
|
.. data:: DBG_DRAWWIREFRAME
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw wireframe in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_DRAWAABB
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw Axis Aligned Bounding Box in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_DRAWFREATURESTEXT
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
Draw features text in debug.
|
2011-07-30 23:16:22 +00:00
|
|
|
|
|
|
|
.. data:: DBG_DRAWCONTACTPOINTS
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw contact points in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_NOHELPTEXT
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Debug without help text.
|
|
|
|
|
|
|
|
.. data:: DBG_DRAWTEXT
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw text in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_PROFILETIMINGS
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw profile timings in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_ENABLESATCOMPARISION
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Enable sat comparision in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_DISABLEBULLETLCP
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Disable Bullet LCP.
|
|
|
|
|
|
|
|
.. data:: DBG_ENABLECCD
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
Enable Continous Collision Detection in debug.
|
2011-07-30 23:16:22 +00:00
|
|
|
|
|
|
|
.. data:: DBG_DRAWCONSTRAINTS
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw constraints in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_DRAWCONSTRAINTLIMITS
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw constraint limits in debug.
|
|
|
|
|
|
|
|
.. data:: DBG_FASTWIREFRAME
|
2014-04-01 05:20:03 +00:00
|
|
|
|
2011-07-30 23:16:22 +00:00
|
|
|
Draw a fast wireframe in debug.
|
|
|
|
|
|
|
|
|
2015-06-23 11:29:37 +00:00
|
|
|
Create Constraint Constants
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2015-06-23 12:57:38 +00:00
|
|
|
Constraint type to be used with :func:`createConstraint`.
|
2015-06-23 11:29:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
.. data:: POINTTOPOINT_CONSTRAINT
|
2011-07-30 23:16:22 +00:00
|
|
|
|
|
|
|
.. to do
|
|
|
|
|
|
|
|
.. data:: LINEHINGE_CONSTRAINT
|
|
|
|
|
|
|
|
.. to do
|
|
|
|
|
|
|
|
.. data:: ANGULAR_CONSTRAINT
|
|
|
|
|
|
|
|
.. to do
|
|
|
|
|
|
|
|
.. data:: CONETWIST_CONSTRAINT
|
|
|
|
|
|
|
|
.. to do
|
|
|
|
|
|
|
|
.. data:: VEHICLE_CONSTRAINT
|
|
|
|
|
|
|
|
.. to do
|
2014-07-18 05:50:51 +00:00
|
|
|
|
|
|
|
.. data:: GENERIC_6DOF_CONSTRAINT
|
|
|
|
|
|
|
|
.. to do
|
2015-06-23 11:29:37 +00:00
|
|
|
|