# Joint Class

This class is used to create joints.

## Jointclone ()

Clones the joint.

### Return value

Copy of the joint.

## vec3getAnchor0 ()

Returns the coordinates of the anchor point in a system of coordinates of the first connected body.

### Return value

Coordinates of the anchor point in the body coordinate space.

## vec3getAnchor1 ()

Returns the coordinates of the anchor point in a system of coordinates of the second connected body.

### Return value

Coordinates of the anchor point in the body coordinate space.

## floatgetAngularRestitution ()

Returns the current angular restitution (stiffness) of the joint. Angular restitution defines how fast the joint compensates for change of the angle between two bodies. When bodies are turned relative each other, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. For example:
• 1 means that the joint is to return bodies in place throughout 1 physics tick.
• 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).

### Return value

Angular restitution in the range [0;1].

## floatgetAngularSoftness ()

Returns the current angular softness (elasticity) of the joint. When the joint is twisted, angular softness defines whether angular velocities of the bodies are averaged out. For example:
• 0 means that the joint is rigid. Angular velocities of the first and the second body are independent.
• 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.

### Return value

Angular softness in the range [0;1].

## BodygetBody0 ()

Returns the first body connected using the joint.

### Return value

The first body connected with the joint.

## BodygetBody1 ()

Returns the second body connected using the joint.

### Return value

The second body connected with the joint.

## BodyRigidgetBodyRigid0 ()

Returns the first connected body as a rigid body.

### Return value

The first rigid body connected using the joint or NULL (0), if the body is not rigid.

## BodyRigidgetBodyRigid1 ()

Returns the second connected body as a rigid body.

### Return value

The second rigid body connected using the joint or NULL (0), if the body is not rigid.

## intgetCollision ()

Returns a value indicating if collisions between the connected bodies are enabled.

### Return value

Positive number if collisions between the bodies are enabled; otherwise, 0.

## intgetID ()

Returns the unique ID of the joint.

Unique ID.

## floatgetLinearRestitution ()

Returns the current linear restitution (stiffness) of the joint. Linear restitution defines how fast the joint compensates for linear coordinate change between two bodies. When bodies are dragged apart, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. For example:
• 1 means that the joint is to return bodies in place throughout 1 physics tick.
• 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).

### Return value

Linear restitution in the range [0;1].

## floatgetLinearSoftness ()

Returns the current linear softness (elasticity) of the joint. When the joint is stretched, linear softness defines whether linear velocities of the bodies are averaged out. For example:
• 0 means that the joint is rigid. Velocities of the first and the second body are independent.
• 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.

### Return value

Linear softness value in the range [0;1].

## floatgetMaxForce ()

Returns the maximum amount of force that can be exerted on the joint. If this limit is exceeded, the joint breaks.

### Return value

Maximum amount of force.

## floatgetMaxTorque ()

Returns the maximum amount of torque that can be exerted on the joint. If this limit is exceeded, the joint breaks.

### Return value

Maximum amount of torque.

## stringgetName ()

Returns the name of the joint.

### Return value

Name of the joint.

## intgetNumIterations ()

Returns the current number of iterations used to solve joints.

### Return value

Number of iterations.

## stringgetTypeName ()

Returns the name of the joint type.

Type name.

## intgetType ()

Returns the type of the joint.

### Return value

One of the JOINT_* pre-defined variables.

## vec3getWorldAnchor ()

Returns the anchor point in the world coordinates.

### Return value

Coordinates of the anchor point in the world space.

## intisBroken ()

Returns a value indicating if the joint is broken or not.

### Return value

Positive number if the joint is broken; otherwise, 0.

## intisEnabledSelf ()

Returns a value indicating is the joint is enabled.

### Return value

1 if the joint is enabled; otherwise, 0.

## intisEnabled ()

Returns a value indicating if the joint calculations are enabled.

### Return value

1 if the joint is enabled; otherwise, 0.

## intisFrozen ()

Returns a value indicating if the joint is frozen or not.

### Return value

Positive number if the joint is frozen; otherwise, 0.

## voidrenderVisualizer (vec4 color)

Renders the joint.
Notice
You should enable the engine visualizer by the show_visualizer 1 console command.

### Arguments

• vec4 color - Color, in which the joint will be rendered.

## intrestoreState (Stream stream)

Restores the state of a given node from a binary stream.
• If a node is a parent for other nodes, states of these child nodes need to be restored manually.
• To save the state into a buffer, file or a message from a socket, make sure the stream is opened. If necessary, you can set a position for writing for buffers and files.

### Arguments

• Stream stream - Stream with saved node state data.

### Return value

1 if node state is successfully restored; otherwise, 0.

## intsaveState (Stream stream)

Saves the state of a given node into a binary stream.
• If a node is a parent for other nodes, states of these child nodes need to be saved manually.
• To save the state from a buffer, file or a message from a socket, make sure the stream is opened. For buffers and files, you also need to set the proper position for reading.

### Arguments

• Stream stream - Stream to save node state data.

### Return value

1 if node state is successfully saved; otherwise, 0.

## voidsetAnchor0 (vec3 coordinates)

Sets coordinates of the anchor point in a system of coordinates of the first connected body.

### Arguments

• vec3 coordinates - Coordinates of the anchor point in the body coordinate space.

## voidsetAnchor1 (vec3 coordinates)

Sets coordinates of the anchor point in a system of coordinates of the second connected body.

### Arguments

• vec3 coordinates - Coordinates of the anchor point in the body coordinate space.

## voidsetAngularRestitution (float restitution)

Sets the current angular restitution (stiffness) of the joint. Angular restitution defines how fast the joint compensates for change of the angle between two bodies. When bodies are turned relative each other, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. For example:
• 1 means that the joint is to return bodies in place throughout 1 physics tick.
• 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).

### Arguments

• float restitution - Angular restitution. The provided value will be clamped in the range [0;1].

## voidsetAngularSoftness (float softness)

Sets the angular softness (elasticity) of the joint. When the joint is twisted, angular softness defines whether angular velocities of the bodies are averaged out. For example:
• 0 means that the joint is rigid. Angular velocities of the first and the second body are independent.
• 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.

### Arguments

• float softness - Angular softness. The provided value will be clamped in the range [0;1].

## voidsetBody0 (Body body)

Sets the first body connected using the joint.

### Arguments

• Body body - The first body connected with the joint.

## voidsetBody1 (Body body)

Sets the second body connected using the joint.

### Arguments

• Body body - The second body connected with the joint.

## voidsetBrokenCallback (Joint joint, variable function = 0, variable arg0 = 0, variable arg1 = 0)

Adds a callback function that will be run when a given joint breaks.
Notice
Physics-based callbacks are executed not immediately, but before the next flush() or next update() of the world script.

### Arguments

• Joint joint - Joint that will break.
• variable function - Name of the callback function.
• variable arg0 - Argument to the function. This is an optional parameter.
• variable arg1 - Argument to the function. This is an optional parameter.

## voidsetBroken (int mode)

Sets a value indicating if the joint is broken or not.

### Arguments

• int mode - Positive number to break the joint, 0 to make it intact.

## voidsetCollision (int mode)

Sets a value indicating if collisions between the connected bodies are enabled.

### Arguments

• int mode - Positive number to enable collisions between the bodies, 0 to disable them.

## voidsetEnabled (int mode)

Enables or disables joint calculations.

### Arguments

• int mode - Positive number to enable the joint, 0 to disable it.

## voidsetFrozen (int mode)

Freezes or unfreezes the joint.

### Arguments

• int mode - Positive number to freeze the joint, 0 to unfreeze it.

## intsetID (int id)

Sets the unique ID for the joint.

### Arguments

• int id - Unique ID.

### Return value

1 if the ID is set successfully; otherwise, 0.

## voidsetLinearRestitution (float restitution)

Sets the linear restitution (stiffness) of the joint. Linear restitution defines how fast the joint compensates for linear coordinate change between two bodies. When bodies are dragged apart, restitution controls the magnitude of force which is applied to both bodies so that their anchor points to become aligned again. For example:
• 1 means that the joint is to return bodies in place throughout 1 physics tick.
• 0.2 means that the joint is to return bodies in place throughout 5 physics ticks.
The maximum value of 1 can lead to destabilization of physics (as too great forces are applied).

### Arguments

• float restitution - Linear restitution. The provided value will be clamped in the range [0;1].

## voidsetLinearSoftness (float softness)

Sets the linear softness (elasticity) of the joint. When the joint is stretched, linear softness defines whether linear velocities of the bodies are averaged out. For example:
• 0 means that the joint is rigid. Linear velocities of the first and the second body are independent.
• 1 means that the joint is elastic (jelly-like). If the first body changes its velocity, velocity of the second body is equalized with it.

### Arguments

• float softness - Linear softness. The provided value will be clamped in the range [0;1].

## voidsetMaxForce (float force)

Sets the maximum amount of force that can be exerted on the joint. If this limit is exceeded, the joint breaks.

### Arguments

• float force - Maximum amount of force.

## voidsetMaxTorque (float torque)

Sets the maximum amount of torque that can be exerted on the joint. If this limit is exceeded, the joint breaks.

### Arguments

• float torque - Maximum amount of torque.

## voidsetName (string name)

Sets the name of the joint.

### Arguments

• string name - Name of the joint.

## voidsetNumIterations (int iterations)

Sets the number of iterations used to solve joints. Note that if this value is too low, the precision of calculations will suffer.

### Arguments

• int iterations - Number of iterations. If a non-positive value is provided, 1 will be used instead.

## voidsetWorldAnchor (vec3 coordinates)

Sets the anchor point in the world coordinates.

### Arguments

• vec3 coordinates - Coordinates of the anchor point in the world space.

## voidswap (Joint joint)

Swaps the joints saving the pointers.

### Arguments

• Joint joint - A joint to swap.

Ball joint.

## int JOINT_CYLINDRICAL

### Description

Cylindrical joint.

Fixed joint.

Hinge joint.

## int JOINT_PARTICLES

### Description

Particles joint pins BodyCloth or BodyRope (both children of BodyParticles) to BodyRigid or BodyRagdoll.

## int JOINT_PATH

### Description

Path joint that connects BodyRigid to BodyPath. It allows a rigid body to move along the path.

Prismatic joint.

## int JOINT_SUSPENSION

### Description

Suspension joint.

## int JOINT_WHEEL

### Description

Wheel joint (ray car wheels).
Last update: 2017-07-03