R3d.SliderJoint

Available since: Gideros 2019.10
Class: R3d.Joint

Description

The SliderJoint class describes a slider joint (or prismatic joint) that only allows relative translation along a single direction. It has a single degree of freedom and allows no relative rotation.

In order to create a slider joint, you first need to specify the anchor point (in world-space) and the slider axis direction (in world-space). The constructor of the SliderJointInfo object needs two pointers to the bodies of the joint, the anchor point and the axis direction.

Note that the two bodies have to be in a correct initial position when the joint is created.

r3d.SliderJoint

Now, it is possible to create the actual joint in the dynamics world using the DynamicsWorld::createJoint() method.

Note that this method will also return a pointer to the SliderJoint object that has been created internally. You will then be able to use that pointer to change properties of the joint and also to destroy it at the end.

Limits

It is also possible to control the range of the slider joint motion using limits. The limits are disabled by default. In order to use the limits when the joint is created, you first need to activate them using the isLimitEnabled variable of the SliderJointInfo class. Then, you need to specify the minimum and maximum translation limits (in meters) using the minTranslationLimit and maxTranslationLimit variables.

Note that the initial position of the two bodies when the joint is created corresponds to a translation of zero. Therefore, the minimum limit must be smaller or equal to zero and the maximum limit must be larger or equal to zero.

Motor

The slider joint also has a motor. You can use it to translate the bodies along the slider axis at a given linear speed and such that the force applied to move the bodies does not exceed a maximum allowed force.

The motor is disabled by default. If you want to use it when the joint is created, you first have to activate it using the isMotorEnabled boolean variable of the SliderJointInfo object before you create the joint. Then, you need to specify the linear motor speed (in meters/seconds) using the motorSpeed variable and also the maximum allowed force (in Newtons) with the maxMotorForce variable.

Example