Box3D 0.1.0
A 3D physics engine for games
Loading...
Searching...
No Matches
Distance Joint

Functions for the distance joint. More...

Collaboration diagram for Distance Joint:

Data Structures

struct  b3DistanceJointDef
 Distance joint definition. More...

Functions

b3JointId b3CreateDistanceJoint (b3WorldId worldId, const b3DistanceJointDef *def)
 Create a distance joint.
void b3DistanceJoint_SetLength (b3JointId jointId, float length)
 Set the rest length of a distance joint.
float b3DistanceJoint_GetLength (b3JointId jointId)
 Get the rest length of a distance joint.
void b3DistanceJoint_EnableSpring (b3JointId jointId, bool enableSpring)
 Enable/disable the distance joint spring. When disabled the distance joint is rigid.
bool b3DistanceJoint_IsSpringEnabled (b3JointId jointId)
 Is the distance joint spring enabled?
void b3DistanceJoint_SetSpringForceRange (b3JointId jointId, float lowerForce, float upperForce)
 Set the force range for the spring.
void b3DistanceJoint_GetSpringForceRange (b3JointId jointId, float *lowerForce, float *upperForce)
 Get the force range for the spring.
void b3DistanceJoint_SetSpringHertz (b3JointId jointId, float hertz)
 Set the spring stiffness in Hertz.
void b3DistanceJoint_SetSpringDampingRatio (b3JointId jointId, float dampingRatio)
 Set the spring damping ratio, non-dimensional.
float b3DistanceJoint_GetSpringHertz (b3JointId jointId)
 Get the spring Hertz.
float b3DistanceJoint_GetSpringDampingRatio (b3JointId jointId)
 Get the spring damping ratio.
void b3DistanceJoint_EnableLimit (b3JointId jointId, bool enableLimit)
 Enable joint limit.
bool b3DistanceJoint_IsLimitEnabled (b3JointId jointId)
 Is the distance joint limit enabled?
void b3DistanceJoint_SetLengthRange (b3JointId jointId, float minLength, float maxLength)
 Set the minimum and maximum length parameters of a distance joint.
float b3DistanceJoint_GetMinLength (b3JointId jointId)
 Get the distance joint minimum length.
float b3DistanceJoint_GetMaxLength (b3JointId jointId)
 Get the distance joint maximum length.
float b3DistanceJoint_GetCurrentLength (b3JointId jointId)
 Get the current length of a distance joint.
void b3DistanceJoint_EnableMotor (b3JointId jointId, bool enableMotor)
 Enable/disable the distance joint motor.
bool b3DistanceJoint_IsMotorEnabled (b3JointId jointId)
 Is the distance joint motor enabled?
void b3DistanceJoint_SetMotorSpeed (b3JointId jointId, float motorSpeed)
 Set the distance joint motor speed, usually in meters per second.
float b3DistanceJoint_GetMotorSpeed (b3JointId jointId)
 Get the distance joint motor speed, usually in meters per second.
void b3DistanceJoint_SetMaxMotorForce (b3JointId jointId, float force)
 Set the distance joint maximum motor force, usually in newtons.
float b3DistanceJoint_GetMaxMotorForce (b3JointId jointId)
 Get the distance joint maximum motor force, usually in newtons.
float b3DistanceJoint_GetMotorForce (b3JointId jointId)
 Get the distance joint current motor force, usually in newtons.
b3DistanceJointDef b3DefaultDistanceJointDef (void)
 Use this to initialize your joint definition.

Detailed Description

Functions for the distance joint.


Data Structure Documentation

◆ b3DistanceJointDef

struct b3DistanceJointDef

Distance joint definition.

Connects a point on body A with a point on body B by a segment. Useful for ropes and springs.

Collaboration diagram for b3DistanceJointDef:
Data Fields
b3JointDef base Base joint definition.
float dampingRatio The spring linear damping ratio, non-dimensional.
bool enableLimit Enable/disable the joint limit.
bool enableMotor Enable/disable the joint motor.
bool enableSpring Enable the distance constraint to behave like a spring.

If false then the distance joint will be rigid, overriding the limit and motor.

float hertz The spring linear stiffness Hertz, cycles per second.
float length The rest length of this joint. Clamped to a stable minimum value.
float lowerSpringForce The lower spring force controls how much tension it can sustain.
float maxLength Maximum length. Must be greater than or equal to the minimum length.
float maxMotorForce The maximum motor force, usually in newtons.
float minLength Minimum length. Clamped to a stable minimum value.
float motorSpeed The desired motor speed, usually in meters per second.
float upperSpringForce The upper spring force controls how much compression it can sustain.

Function Documentation

◆ b3CreateDistanceJoint()

b3JointId b3CreateDistanceJoint ( b3WorldId worldId,
const b3DistanceJointDef * def )

Create a distance joint.

See also
b3DistanceJointDef for details

◆ b3DistanceJoint_EnableLimit()

void b3DistanceJoint_EnableLimit ( b3JointId jointId,
bool enableLimit )

Enable joint limit.

The limit only works if the joint spring is enabled. Otherwise the joint is rigid and the limit has no effect.

◆ b3DistanceJoint_SetLength()

void b3DistanceJoint_SetLength ( b3JointId jointId,
float length )

Set the rest length of a distance joint.

Parameters
jointIdThe id for a distance joint
lengthThe new distance joint length