Xors3d Engine
Joints

Functions

BBDECL IJoint *BBCALL xCreateBallJoint (Entity *firstBody, Entity *secondBody, float pivotX, float pivotY, float pivotZ, bool isGlobal=false)
 Creates a 'ball' joint between two bodies and returns its handle. See description JOINT_BALL.
BBDECL IJoint *BBCALL xCreateD6Joint (Entity *firstBody, Entity *secondBody, float pivot1X, float pivot1Y, float pivot1Z, float pivot2X, float pivot2Y, float pivot2Z, bool isGlobal1=false, bool isGlobal2=false)
 Creates a 'D6' joint between two bodies and returns its handle. See description JOINT_D6.
BBDECL IJoint *BBCALL xCreateD6SpringJoint (Entity *firstBody, Entity *secondBody, float pivot1X, float pivot1Y, float pivot1Z, float pivot2X, float pivot2Y, float pivot2Z, bool isGlobal1=false, bool isGlobal2=false)
 Creates a 'D6Spring' joint between two bodies and returns its handle. See description JOINT_D6SPRING.
BBDECL IJoint *BBCALL xCreateHingeJoint (Entity *firstBody, Entity *secondBody, float pivotX, float pivotY, float pivotZ, float axisX, float axisY, float axisZ, bool isGlobal=false)
 Creates a 'hinge' joint between two bodies and returns its handle. See description JOINT_HINGE.
BBDECL void BBCALL xFreeJoint (IJoint *joint)
 Frees a joint.
BBDECL float BBCALL xJointBallGetPivotX (IJoint *joint, bool isGlobal=false)
 Returns the X coodinate of the pivot A of the 'ball' joint.
BBDECL float BBCALL xJointBallGetPivotY (IJoint *joint, bool isGlobal=false)
 Returns the Y coodinate of the pivot A of the 'ball' joint.
BBDECL float BBCALL xJointBallGetPivotZ (IJoint *joint, bool isGlobal=false)
 Returns the Z coodinate of the pivot A of the 'ball' joint.
BBDECL void BBCALL xJointBallSetPivot (IJoint *joint, float x, float y, float z, bool isGlobal=false)
 Sets the coordinates of the pivot of the 'ball' joint.
BBDECL float BBCALL xJointD6GetAngle (IJoint *joint, int axis=0)
 Retrieves the current angle around specific axis of D6 and D6Spring joints.
BBDECL float BBCALL xJointD6GetAngularLowerX (IJoint *joint)
 Returns the lower angular limit of the X axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetAngularLowerY (IJoint *joint)
 Returns the lower angular limit of the Y axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetAngularLowerZ (IJoint *joint)
 Returns the lower angular limit of the Z axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetAngularUpperX (IJoint *joint)
 Returns the upper angular limit of the X axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetAngularUpperY (IJoint *joint)
 Returns the upper angular limit of the Y axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetAngularUpperZ (IJoint *joint)
 Returns the upper angular limit of the Z axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetLinearLowerX (IJoint *joint)
 Returns the lower linear limit of the X axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetLinearLowerY (IJoint *joint)
 Returns the lower linear limit of the Y axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetLinearLowerZ (IJoint *joint)
 Returns the lower linear limit of the Z axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetLinearUpperX (IJoint *joint)
 Returns the upper linear limit of the X axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetLinearUpperY (IJoint *joint)
 Returns the upper linear limit of the Y axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetLinearUpperZ (IJoint *joint)
 Returns the upper linear limit of the Z axis of D6 or D6Spring joint.
BBDECL float BBCALL xJointD6GetPitchAngle (IJoint *joint)
 Retrieves the current pitch angle of D6 and D6Spring joints.
BBDECL float BBCALL xJointD6GetRollAngle (IJoint *joint)
 Retrieves the current roll angle of D6 and D6Spring joints.
BBDECL float BBCALL xJointD6GetYawAngle (IJoint *joint)
 Retrieves the current yaw angle of D6 and D6Spring joints.
BBDECL void BBCALL xJointD6SetAngularLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
 Sets the angular limits of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SetLimits (IJoint *joint, int axis, float lower, float upper)
 Sets the limits of the specific axis of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SetLinearLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
 Sets the linear limits of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SetLowerAngularLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ)
 Sets the lower angular limits of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SetLowerLinearLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ)
 Sets the lower linear limits of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SetUpperAngularLimits (IJoint *joint, float upperX, float upperY, float upperZ)
 Sets the upper angular limits of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SetUpperLinearLimits (IJoint *joint, float upperX, float upperY, float upperZ)
 Sets the upper limits of D6 or D6Spring joint.
BBDECL void BBCALL xJointD6SpringSetParam (IJoint *joint, int index, int enabled, float damping=1.0f, float stiffness=1.0f)
 Enables or disables a spring on a specific DOF of D6Spring joint.
BBDECL void BBCALL xJointDisableCollisions (IJoint *joint, int state)
 Disables or enables collision between two bodies connected with the joint. Initially collisions are enabled.
BBDECL void BBCALL xJointEnable (IJoint *joint, int state)
 Disables or enables the joint. Initially joint is enabled.
BBDECL void BBCALL xJointEnableMotor (IJoint *joint, int enabled, float targetVelocity, float maxForce, int index=0)
 Enables a motor on a specific DOF of D6, D6Spring or hinge joints.
BBDECL Entity *BBCALL xJointGetEntityA (IJoint *joint)
 Returns handle of the first entity.
BBDECL Entity *BBCALL xJointGetEntityB (IJoint *joint)
 Returns handle of the second entity.
BBDECL float BBCALL xJointGetImpulse (IJoint *joint)
 Retrieves an estimated total applied impulse.
BBDECL float BBCALL xJointHingeGetAngle (IJoint *joint)
 Retrieves the current hinge angle.
BBDECL float BBCALL xJointHingeGetLowerLimit (IJoint *joint)
 Returns the lower limit of the hinge joint.
BBDECL float BBCALL xJointHingeGetUpperLimit (IJoint *joint)
 Returns the upper limit of the hinge joint.
BBDECL void BBCALL xJointHingeSetAxis (IJoint *joint, float x, float y, float z)
 Sets the axis of the hinge joint.
BBDECL void BBCALL xJointHingeSetLimits (IJoint *joint, float lowerLimit, float upperLimit, float softness=0.9f, float biasFactor=0.3f, float relaxationFactor=1.0f)
 Sets the limits and other parameters of the hinge joint.
BBDECL void BBCALL xJointHingeSetMotorTarget (IJoint *joint, float targetAngle, float deltaTime)
 Sets the motor target of the hinge joint.
BBDECL int BBCALL xJointIsEnabled (IJoint *joint)
 Returns the state of the joint.

Function Documentation

BBDECL IJoint* BBCALL xCreateHingeJoint ( Entity *  firstBody,
Entity *  secondBody,
float  pivotX,
float  pivotY,
float  pivotZ,
float  axisX,
float  axisY,
float  axisZ,
bool  isGlobal = false 
)

Creates a 'hinge' joint between two bodies and returns its handle. See description JOINT_HINGE.

One of two bodies may be zero. In this case another body will be jointed to a static world.

Parameters:
firstBodyThe handle of the first entity
secondBodyThe handle of the second entity
pivotXX coordinate of the joint's pivot
pivotYY coordinate of the joint's pivot
pivotZZ coordinate of the joint's pivot
axisXX coordinate of the joint's axis
axisYY coordinate of the joint's axis
axisZZ coordinate of the joint's axis
isGlobal1 (true) to use global pivot coodinates. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL IJoint* BBCALL xCreateBallJoint ( Entity *  firstBody,
Entity *  secondBody,
float  pivotX,
float  pivotY,
float  pivotZ,
bool  isGlobal = false 
)

Creates a 'ball' joint between two bodies and returns its handle. See description JOINT_BALL.

One of two bodies may be zero. In this case another body will be jointed to a static world.

Parameters:
firstBodyThe handle of the first entity
secondBodyThe handle of the second entity
pivotXX coordinate of the joint's pivot
pivotYY coordinate of the joint's pivot
pivotZZ coordinate of the joint's pivot
isGlobal1 (true) to use global pivot coodinates. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL IJoint* BBCALL xCreateD6Joint ( Entity *  firstBody,
Entity *  secondBody,
float  pivot1X,
float  pivot1Y,
float  pivot1Z,
float  pivot2X,
float  pivot2Y,
float  pivot2Z,
bool  isGlobal1 = false,
bool  isGlobal2 = false 
)

Creates a 'D6' joint between two bodies and returns its handle. See description JOINT_D6.

One of two bodies may be zero. In this case another body will be jointed to a static world.

Parameters:
firstBodyThe handle of the first entity
secondBodyThe handle of the second entity
pivot1XX coordinate of the first joint's pivot
pivot1YY coordinate of the first joint's pivot
pivot1ZZ coordinate of the first joint's pivot
pivot2XX coordinate of the second joint's pivot
pivot2YY coordinate of the second joint's pivot
pivot2ZZ coordinate of the second joint's pivot
isGlobal11 (true) to use global coodinates of the first pivot. 0 (false) to use local coordinates. Default is 0 (false)
isGlobal21 (true) to use global coodinates of the second pivot. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL IJoint* BBCALL xCreateD6SpringJoint ( Entity *  firstBody,
Entity *  secondBody,
float  pivot1X,
float  pivot1Y,
float  pivot1Z,
float  pivot2X,
float  pivot2Y,
float  pivot2Z,
bool  isGlobal1 = false,
bool  isGlobal2 = false 
)

Creates a 'D6Spring' joint between two bodies and returns its handle. See description JOINT_D6SPRING.

Parameters:
firstBodyThe handle of the first entity
secondBodyThe handle of the second entity
pivot1XX coordinate of the first joint's pivot
pivot1YY coordinate of the first joint's pivot
pivot1ZZ coordinate of the first joint's pivot
pivot2XX coordinate of the second joint's pivot
pivot2YY coordinate of the second joint's pivot
pivot2ZZ coordinate of the second joint's pivot
isGlobal11 (true) to use global coodinates of the first pivot. 0 (false) to use local coordinates. Default is 0 (false)
isGlobal21 (true) to use global coodinates of the second pivot. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL float BBCALL xJointHingeGetAngle ( IJoint *  joint)

Retrieves the current hinge angle.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetPitchAngle ( IJoint *  joint)

Retrieves the current pitch angle of D6 and D6Spring joints.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetYawAngle ( IJoint *  joint)

Retrieves the current yaw angle of D6 and D6Spring joints.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetRollAngle ( IJoint *  joint)

Retrieves the current roll angle of D6 and D6Spring joints.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngle ( IJoint *  joint,
int  axis = 0 
)

Retrieves the current angle around specific axis of D6 and D6Spring joints.

Parameters:
jointJoint handle
axisAxis. 0 - X axis
1 - Y axis
2 - Z axis
Default is 0
BBDECL void BBCALL xJointDisableCollisions ( IJoint *  joint,
int  state 
)

Disables or enables collision between two bodies connected with the joint. Initially collisions are enabled.

Parameters:
jointJoint handle
state1 (true) to disable collision. 0 (false) to enable collision.
BBDECL void BBCALL xJointEnable ( IJoint *  joint,
int  state 
)

Disables or enables the joint. Initially joint is enabled.

Parameters:
jointJoint handle
state1 (true) to disable joint. 0 (false) to enable joint.
BBDECL int BBCALL xJointIsEnabled ( IJoint *  joint)

Returns the state of the joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointGetImpulse ( IJoint *  joint)

Retrieves an estimated total applied impulse.

Parameters:
jointJoint handle
BBDECL void BBCALL xFreeJoint ( IJoint *  joint)

Frees a joint.

Parameters:
jointJoint handle
BBDECL void BBCALL xJointBallSetPivot ( IJoint *  joint,
float  x,
float  y,
float  z,
bool  isGlobal = false 
)

Sets the coordinates of the pivot of the 'ball' joint.

Pivot A is a pivot of the first body connected to the second body by the given joint.

Parameters:
jointJoint handle
xX coordinate of the joint's pivot
yY coordinate of the joint's pivot
zZ coordinate of the joint's pivot
isGlobal1 (true) to use global coordinates. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL float BBCALL xJointBallGetPivotX ( IJoint *  joint,
bool  isGlobal = false 
)

Returns the X coodinate of the pivot A of the 'ball' joint.

Parameters:
jointJoint handle
isGlobal1 (true) to use global coordinates. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL float BBCALL xJointBallGetPivotY ( IJoint *  joint,
bool  isGlobal = false 
)

Returns the Y coodinate of the pivot A of the 'ball' joint.

Parameters:
jointJoint handle
isGlobal1 (true) to use global coordinates. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL float BBCALL xJointBallGetPivotZ ( IJoint *  joint,
bool  isGlobal = false 
)

Returns the Z coodinate of the pivot A of the 'ball' joint.

Parameters:
jointJoint handle
isGlobal1 (true) to use global coordinates. 0 (false) to use local coordinates. Default is 0 (false)
BBDECL void BBCALL xJointD6SetLimits ( IJoint *  joint,
int  axis,
float  lower,
float  upper 
)

Sets the limits of the specific axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
axisJoint axis. 0 - linear X axis
1 - linear Y axis
2 - linear Z axis
3 - angular X axis
4 - angular Y axis
5 - angular Z axis
lowerLower limit
upperUpper limit
BBDECL void BBCALL xJointD6SetLowerLinearLimits ( IJoint *  joint,
float  lowerX,
float  lowerY,
float  lowerZ 
)

Sets the lower linear limits of D6 or D6Spring joint.

Parameters:
jointJoint handle
lowerXLower linear limit of X axis
lowerYLower linear limit of Y axis
lowerZLower linear limit of Z axis
BBDECL void BBCALL xJointD6SetUpperLinearLimits ( IJoint *  joint,
float  upperX,
float  upperY,
float  upperZ 
)

Sets the upper limits of D6 or D6Spring joint.

Parameters:
jointJoint handle
upperXUpper linear limit of X axis
upperYUpper linear limit of Y axis
upperZUpper linear limit of Z axis
BBDECL void BBCALL xJointD6SetLowerAngularLimits ( IJoint *  joint,
float  lowerX,
float  lowerY,
float  lowerZ 
)

Sets the lower angular limits of D6 or D6Spring joint.

Parameters:
jointJoint handle
lowerXLower angular limit of X axis
lowerYLower angular limit of Y axis
lowerZLower angular limit of Z axis
BBDECL void BBCALL xJointD6SetUpperAngularLimits ( IJoint *  joint,
float  upperX,
float  upperY,
float  upperZ 
)

Sets the upper angular limits of D6 or D6Spring joint.

Parameters:
jointJoint handle
upperXUpper angular limit of X axis
upperYUpper angular limit of Y axis
upperZUpper angular limit of Z axis
BBDECL void BBCALL xJointD6SetLinearLimits ( IJoint *  joint,
float  lowerX,
float  lowerY,
float  lowerZ,
float  upperX,
float  upperY,
float  upperZ 
)

Sets the linear limits of D6 or D6Spring joint.

Parameters:
jointJoint handle
lowerXLower linear limit of X axis
lowerYLower linear limit of Y axis
lowerZLower linear limit of Z axis
upperXUpper linear limit of X axis
upperYUpper linear limit of Y axis
upperZUpper linear limit of Z axis
BBDECL void BBCALL xJointD6SetAngularLimits ( IJoint *  joint,
float  lowerX,
float  lowerY,
float  lowerZ,
float  upperX,
float  upperY,
float  upperZ 
)

Sets the angular limits of D6 or D6Spring joint.

Parameters:
jointJoint handle
lowerXLower angular limit of X axis
lowerYLower angular limit of Y axis
lowerZLower angular limit of Z axis
upperXUpper angular limit of X axis
upperYUpper angular limit of Y axis
upperZUpper angular limit of Z axis
BBDECL float BBCALL xJointD6GetLinearLowerX ( IJoint *  joint)

Returns the lower linear limit of the X axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetLinearLowerY ( IJoint *  joint)

Returns the lower linear limit of the Y axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetLinearLowerZ ( IJoint *  joint)

Returns the lower linear limit of the Z axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetLinearUpperX ( IJoint *  joint)

Returns the upper linear limit of the X axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetLinearUpperY ( IJoint *  joint)

Returns the upper linear limit of the Y axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetLinearUpperZ ( IJoint *  joint)

Returns the upper linear limit of the Z axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngularLowerX ( IJoint *  joint)

Returns the lower angular limit of the X axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngularLowerY ( IJoint *  joint)

Returns the lower angular limit of the Y axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngularLowerZ ( IJoint *  joint)

Returns the lower angular limit of the Z axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngularUpperX ( IJoint *  joint)

Returns the upper angular limit of the X axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngularUpperY ( IJoint *  joint)

Returns the upper angular limit of the Y axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointD6GetAngularUpperZ ( IJoint *  joint)

Returns the upper angular limit of the Z axis of D6 or D6Spring joint.

Parameters:
jointJoint handle
BBDECL void BBCALL xJointD6SpringSetParam ( IJoint *  joint,
int  index,
int  enabled,
float  damping = 1.0f,
float  stiffness = 1.0f 
)

Enables or disables a spring on a specific DOF of D6Spring joint.

If spring is enabled, the coefficients of damping and stiffness can be set.

Parameters:
jointJoint handle
indexDOF index (see 'Joint types')
enabledEnable or disable the spring
dampingThe coefficient of damping
stiffnessThe coefficient of stiffness
BBDECL void BBCALL xJointHingeSetAxis ( IJoint *  joint,
float  x,
float  y,
float  z 
)

Sets the axis of the hinge joint.

Warning:
This function is not complete. Ignore it please.
Parameters:
jointJoint handle
xX-component of the axis vector
yY-component of the axis vector
zZ-component of the axis vector
BBDECL void BBCALL xJointHingeSetLimits ( IJoint *  joint,
float  lowerLimit,
float  upperLimit,
float  softness = 0.9f,
float  biasFactor = 0.3f,
float  relaxationFactor = 1.0f 
)

Sets the limits and other parameters of the hinge joint.

Sets the lower and upper limits, the softness, the bias factor and the relaxation factor of the hinge joint.

Parameters:
jointJoint handle
lowerLimitThe lower limit
upperLimitThe upper limit
softnessThe coefficient of softness
biasFactorThe bias factor
relaxationFactorThe relaxation factor
BBDECL float BBCALL xJointHingeGetLowerLimit ( IJoint *  joint)

Returns the lower limit of the hinge joint.

Parameters:
jointJoint handle
BBDECL float BBCALL xJointHingeGetUpperLimit ( IJoint *  joint)

Returns the upper limit of the hinge joint.

Parameters:
jointJoint handle
BBDECL void BBCALL xJointEnableMotor ( IJoint *  joint,
int  enabled,
float  targetVelocity,
float  maxForce,
int  index = 0 
)

Enables a motor on a specific DOF of D6, D6Spring or hinge joints.

The last parameter 'index' is used only for D6 and D6Spring joints. See 'Joint types'.

Parameters:
jointJoint handle
enabledEnable or disable the motor
targetVelocityThe target angular velocity
maxForceThe maximum force of the motor
indexDOF index (see 'Joint types')
BBDECL void BBCALL xJointHingeSetMotorTarget ( IJoint *  joint,
float  targetAngle,
float  deltaTime 
)

Sets the motor target of the hinge joint.

xJointHingeMotorTarget sets target angular velocity ( (targetAngle - currentAngle) / deltaTime ) under the hood.

Parameters:
jointJoint handle
targetAngleThe target angle
deltaTimeThe delta time
BBDECL Entity* BBCALL xJointGetEntityA ( IJoint *  joint)

Returns handle of the first entity.

Parameters:
jointJoint handle
BBDECL Entity* BBCALL xJointGetEntityB ( IJoint *  joint)

Returns handle of the second entity.

Parameters:
jointJoint handle