Xors3d Engine
Joints

Functions

IJoint * 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.
IJoint * 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.
IJoint * 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.
IJoint * 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.
void xFreeJoint (IJoint *joint)
 Frees a joint.
float xJointBallGetPivotX (IJoint *joint, bool isGlobal=false)
 Returns the X coodinate of the pivot A of the 'ball' joint.
float xJointBallGetPivotY (IJoint *joint, bool isGlobal=false)
 Returns the Y coodinate of the pivot A of the 'ball' joint.
float xJointBallGetPivotZ (IJoint *joint, bool isGlobal=false)
 Returns the Z coodinate of the pivot A of the 'ball' joint.
void xJointBallSetPivot (IJoint *joint, float x, float y, float z, bool isGlobal=false)
 Sets the coordinates of the pivot of the 'ball' joint.
float xJointD6GetAngle (IJoint *joint, int axis=0)
 Retrieves the current angle around specific axis of D6 and D6Spring joints.
float xJointD6GetAngularLowerX (IJoint *joint)
 Returns the lower angular limit of the X axis of D6 or D6Spring joint.
float xJointD6GetAngularLowerY (IJoint *joint)
 Returns the lower angular limit of the Y axis of D6 or D6Spring joint.
float xJointD6GetAngularLowerZ (IJoint *joint)
 Returns the lower angular limit of the Z axis of D6 or D6Spring joint.
float xJointD6GetAngularUpperX (IJoint *joint)
 Returns the upper angular limit of the X axis of D6 or D6Spring joint.
float xJointD6GetAngularUpperY (IJoint *joint)
 Returns the upper angular limit of the Y axis of D6 or D6Spring joint.
float xJointD6GetAngularUpperZ (IJoint *joint)
 Returns the upper angular limit of the Z axis of D6 or D6Spring joint.
float xJointD6GetLinearLowerX (IJoint *joint)
 Returns the lower linear limit of the X axis of D6 or D6Spring joint.
float xJointD6GetLinearLowerY (IJoint *joint)
 Returns the lower linear limit of the Y axis of D6 or D6Spring joint.
float xJointD6GetLinearLowerZ (IJoint *joint)
 Returns the lower linear limit of the Z axis of D6 or D6Spring joint.
float xJointD6GetLinearUpperX (IJoint *joint)
 Returns the upper linear limit of the X axis of D6 or D6Spring joint.
float xJointD6GetLinearUpperY (IJoint *joint)
 Returns the upper linear limit of the Y axis of D6 or D6Spring joint.
float xJointD6GetLinearUpperZ (IJoint *joint)
 Returns the upper linear limit of the Z axis of D6 or D6Spring joint.
float xJointD6GetPitchAngle (IJoint *joint)
 Retrieves the current pitch angle of D6 and D6Spring joints.
float xJointD6GetRollAngle (IJoint *joint)
 Retrieves the current roll angle of D6 and D6Spring joints.
float xJointD6GetYawAngle (IJoint *joint)
 Retrieves the current yaw angle of D6 and D6Spring joints.
void xJointD6SetAngularLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
 Sets the angular limits of D6 or D6Spring joint.
void xJointD6SetLimits (IJoint *joint, int axis, float lower, float upper)
 Sets the limits of the specific axis of D6 or D6Spring joint.
void xJointD6SetLinearLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ, float upperX, float upperY, float upperZ)
 Sets the linear limits of D6 or D6Spring joint.
void xJointD6SetLowerAngularLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ)
 Sets the lower angular limits of D6 or D6Spring joint.
void xJointD6SetLowerLinearLimits (IJoint *joint, float lowerX, float lowerY, float lowerZ)
 Sets the lower linear limits of D6 or D6Spring joint.
void xJointD6SetUpperAngularLimits (IJoint *joint, float upperX, float upperY, float upperZ)
 Sets the upper angular limits of D6 or D6Spring joint.
void xJointD6SetUpperLinearLimits (IJoint *joint, float upperX, float upperY, float upperZ)
 Sets the upper limits of D6 or D6Spring joint.
void 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.
void xJointDisableCollisions (IJoint *joint, int state)
 Disables or enables collision between two bodies connected with the joint. Initially collisions are enabled.
void xJointEnable (IJoint *joint, int state)
 Disables or enables the joint. Initially joint is enabled.
void 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.
Entity * xJointGetEntityA (IJoint *joint)
 Returns handle of the first entity.
Entity * xJointGetEntityB (IJoint *joint)
 Returns handle of the second entity.
float xJointGetImpulse (IJoint *joint)
 Retrieves an estimated total applied impulse.
float xJointHingeGetAngle (IJoint *joint)
 Retrieves the current hinge angle.
float xJointHingeGetLowerLimit (IJoint *joint)
 Returns the lower limit of the hinge joint.
float xJointHingeGetUpperLimit (IJoint *joint)
 Returns the upper limit of the hinge joint.
void xJointHingeSetAxis (IJoint *joint, float x, float y, float z)
 Sets the axis of the hinge joint.
void 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.
void xJointHingeSetMotorTarget (IJoint *joint, float targetAngle, float deltaTime)
 Sets the motor target of the hinge joint.
int xJointIsEnabled (IJoint *joint)
 Returns the state of the joint.

Function Documentation

IJoint* 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)
IJoint* 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)
IJoint* 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)
IJoint* 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)
float xJointHingeGetAngle ( IJoint *  joint)

Retrieves the current hinge angle.

Parameters:
jointJoint handle
float xJointD6GetPitchAngle ( IJoint *  joint)

Retrieves the current pitch angle of D6 and D6Spring joints.

Parameters:
jointJoint handle
float xJointD6GetYawAngle ( IJoint *  joint)

Retrieves the current yaw angle of D6 and D6Spring joints.

Parameters:
jointJoint handle
float xJointD6GetRollAngle ( IJoint *  joint)

Retrieves the current roll angle of D6 and D6Spring joints.

Parameters:
jointJoint handle
float 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
void 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.
void 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.
int xJointIsEnabled ( IJoint *  joint)

Returns the state of the joint.

Parameters:
jointJoint handle
float xJointGetImpulse ( IJoint *  joint)

Retrieves an estimated total applied impulse.

Parameters:
jointJoint handle
void xFreeJoint ( IJoint *  joint)

Frees a joint.

Parameters:
jointJoint handle
void 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)
float 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)
float 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)
float 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)
void 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
void 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
void 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
void 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
void 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
void 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
void 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
float xJointD6GetLinearLowerX ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetLinearLowerY ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetLinearLowerZ ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetLinearUpperX ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetLinearUpperY ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetLinearUpperZ ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetAngularLowerX ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetAngularLowerY ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetAngularLowerZ ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetAngularUpperX ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetAngularUpperY ( IJoint *  joint)

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

Parameters:
jointJoint handle
float xJointD6GetAngularUpperZ ( IJoint *  joint)

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

Parameters:
jointJoint handle
void 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
void 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
void 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
float xJointHingeGetLowerLimit ( IJoint *  joint)

Returns the lower limit of the hinge joint.

Parameters:
jointJoint handle
float xJointHingeGetUpperLimit ( IJoint *  joint)

Returns the upper limit of the hinge joint.

Parameters:
jointJoint handle
void 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')
void 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
Entity* xJointGetEntityA ( IJoint *  joint)

Returns handle of the first entity.

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

Returns handle of the second entity.

Parameters:
jointJoint handle