Joints allow one or two objects to be connected to a common point. For instance in a door hinge the two objects are the door frame and the door itself, with the hinge being the common point between them.
For all the joints if only one object is linked to the joint, then the joint has one end attached to the world and does not move. If two objects are used in the creation of the joint, then the joint position moves with the two objects.
Some of the joints are affected by the function setAxisLimit which takes three arguments, axis, lower value and upper value. When specified, the movement of the joint along the specified axis is constricted to the boundaries.
Joint also have three breakable modes which the default is viz.JOINT_UNBREAKABLE and the others are viz.JOINT_BREAK_THRESH and viz.JOINT_BREAK_ACCUM. These modes are set through the use of the function setBreakMode. When using viz.JOINT_BREAK_THRESH a second argument is needed which specifies the amount of force needed to break the joint. When using viz.JOINT_BREAK_ACCUM a second and third argument is needed; the first specifies the total accumulated damage that must be reached before the joint breaks, and the second specifies the amount of force required to before damage is added. An optional parameter removeBroken can also be supplied to this function which when set to false leaves the joint in vizard once the joint is broken. By default the joints are removed when broken so any further calls on the joint will result in an error.
A ball joint permits 360 degrees of rotation along each axis. A ball joint is created with the addBallJoint and then takes three optional parameters which specify each axis. Changing the axis in the ball joint only affect the setAxisLimit function. By default the axis are created relative to absolute world coordinates where axis0 is along the x, axis1 is along the y and axis2 is along the z. Make sure if changing an axis that it is perpendicular to the line (or the axis along the line) between the two objects when they are created.
The movement along each axis can be restricted by using the setAxisLimit function, and the joint is breakable as specified above.
The following is an example of a ball joint in which the moving ball is restricted to the right hemisphere and the joint will break after some amount of damage has occurred. A force will be applied to the ball by middle clicking on it.
A hinge joint permits 360 degrees of rotation in one axis. All aspects of the hinge joint are the same except that it only has one axis which by default is along the world's x axis.
Notice how axis0 was changed by specifying the world's z axis.
A universal joint has two accesses and thus permits 360 degrees of rotation in two planes. Once again all aspects of this joint are similar to the ball joint with the exception of the joint only moving along two axis.
The following is similar to the ball joint example except this joint will not rotate about the z axis.
A wheel joint is much like the universal joint in that it permits 360 degrees of rotation in two planes. It also has an added suspension along its axis0 which gives it a more realistic look. A further restriction on this joint is that it must be created between two objects and thus cannot be passed the None keyword as one of its arguments.
The following is a simple wheel example, in which the front ball is connected by a wheel joint and the two rear balls are connected through hinge joints. This example also makes use of the setMotorAngle motor and setMotorThrottle motor which are covered in the motors section.
A slider joint allows movement away from or towards the anchor point in a straight line. The slider joint is affected by the setAxisLimit, setAxisBounce, and setAxisFriction functions. The axis limits specify how far in each direction the object can move. Axis Bounce specifies how much energy is transferred in the opposite direction when the limit is reached. Finally axis friction is the amount of resistance in the slider.
The fixed joint permanently links one object to another from their current location.
In the following example the ball is permanently linked to it's starting location. If this were linked to another object then the two objects would always move with each other.
Physics Shapes - In depth discussion of the collide methods.
Forces - More detail on applyForce and applyTorque.
Joints - In depth overview of the joint types.
Motors - In depth explanation of how each motor works with each joint.