Functions for the distance joint. More...

Data Structures | |
| struct | b2DistanceJointDef |
| Distance joint definition. More... | |
Functions | |
| B2_API b2JointId | b2CreateDistanceJoint (b2WorldId worldId, const b2DistanceJointDef *def) |
| Create a distance joint. | |
| B2_API void | b2DistanceJoint_SetLength (b2JointId jointId, float length) |
| Set the rest length of a distance joint. | |
| B2_API float | b2DistanceJoint_GetLength (b2JointId jointId) |
| Get the rest length of a distance joint. | |
| B2_API void | b2DistanceJoint_EnableSpring (b2JointId jointId, bool enableSpring) |
| Enable/disable the distance joint spring. When disabled the distance joint is rigid. | |
| B2_API bool | b2DistanceJoint_IsSpringEnabled (b2JointId jointId) |
| Is the distance joint spring enabled? | |
| B2_API void | b2DistanceJoint_SetSpringHertz (b2JointId jointId, float hertz) |
| Set the spring stiffness in Hertz. | |
| B2_API void | b2DistanceJoint_SetSpringDampingRatio (b2JointId jointId, float dampingRatio) |
| Set the spring damping ratio, non-dimensional. | |
| B2_API float | b2DistanceJoint_GetSpringHertz (b2JointId jointId) |
| Get the spring Hertz. | |
| B2_API float | b2DistanceJoint_GetSpringDampingRatio (b2JointId jointId) |
| Get the spring damping ratio. | |
| B2_API void | b2DistanceJoint_EnableLimit (b2JointId jointId, bool enableLimit) |
| Enable joint limit. | |
| B2_API bool | b2DistanceJoint_IsLimitEnabled (b2JointId jointId) |
| Is the distance joint limit enabled? | |
| B2_API void | b2DistanceJoint_SetLengthRange (b2JointId jointId, float minLength, float maxLength) |
| Set the minimum and maximum length parameters of a distance joint. | |
| B2_API float | b2DistanceJoint_GetMinLength (b2JointId jointId) |
| Get the distance joint minimum length. | |
| B2_API float | b2DistanceJoint_GetMaxLength (b2JointId jointId) |
| Get the distance joint maximum length. | |
| B2_API float | b2DistanceJoint_GetCurrentLength (b2JointId jointId) |
| Get the current length of a distance joint. | |
| B2_API void | b2DistanceJoint_EnableMotor (b2JointId jointId, bool enableMotor) |
| Enable/disable the distance joint motor. | |
| B2_API bool | b2DistanceJoint_IsMotorEnabled (b2JointId jointId) |
| Is the distance joint motor enabled? | |
| B2_API void | b2DistanceJoint_SetMotorSpeed (b2JointId jointId, float motorSpeed) |
| Set the distance joint motor speed, usually in meters per second. | |
| B2_API float | b2DistanceJoint_GetMotorSpeed (b2JointId jointId) |
| Get the distance joint motor speed, usually in meters per second. | |
| B2_API void | b2DistanceJoint_SetMaxMotorForce (b2JointId jointId, float force) |
| Set the distance joint maximum motor force, usually in newtons. | |
| B2_API float | b2DistanceJoint_GetMaxMotorForce (b2JointId jointId) |
| Get the distance joint maximum motor force, usually in newtons. | |
| B2_API float | b2DistanceJoint_GetMotorForce (b2JointId jointId) |
| Get the distance joint current motor force, usually in newtons. | |
| b2DistanceJointDef | b2DefaultDistanceJointDef (void) |
| Use this to initialize your joint definition. | |
Functions for the distance joint.
| struct b2DistanceJointDef |
Distance joint definition.
This requires defining an anchor point on both bodies and the non-zero distance of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game.

| Data Fields | ||
|---|---|---|
| b2BodyId | bodyIdA | The first attached body. |
| b2BodyId | bodyIdB | The second attached body. |
| bool | collideConnected | Set this flag to true if the attached bodies should collide. |
| 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. |
| int | internalValue | Used internally to detect a valid definition. DO NOT SET. |
| float | length | The rest length of this joint. Clamped to a stable minimum value. |
| b2Vec2 | localAnchorA | The local anchor point relative to bodyA's origin. |
| b2Vec2 | localAnchorB | The local anchor point relative to bodyB's origin. |
| 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. |
| void * | userData | User data pointer. |
| B2_API b2JointId b2CreateDistanceJoint | ( | b2WorldId | worldId, |
| const b2DistanceJointDef * | def ) |
Create a distance joint.
| B2_API void b2DistanceJoint_EnableLimit | ( | b2JointId | 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.
| B2_API void b2DistanceJoint_SetLength | ( | b2JointId | jointId, |
| float | length ) |
Set the rest length of a distance joint.
| jointId | The id for a distance joint |
| length | The new distance joint length |