Introduction

Joints connect two Solids, constraining their relative motion. There are several types of Joints, each constraining motion in different ways. The available Joints are:
  • Hinge Joints
    • One rotational degree of freedom
  • Universal Joints
    • Two rotational degrees of freedom
  • Ball Joints
    • Three rotational degrees of freedom
  • Wheel Joints
    • Two rotational degrees of freedom
    • Typically one axis coincides with a wheel’s axis, and the other is used for steering
  • Slider Joints
    • One translational degree of freedom
  • Fixed Joints
    • Zero rotational degrees of freedom

Creation

Joints are created much like Solids:
Joint joint = sim.CreateJoint(); Note: sim is an initialized Simulator

Initialization

Before using the Joint, it must be initialized with a JointData object. Before it can be initialized, you must create two Solids and position them:
Solid solid0 = sim.CreateSolid();
BoxShapeData boxData = new BoxShapeData();
solid0.AddShape(boxData);
Solid solid1 = sim.CreateSolid();
Matrix solid1Transform = Matrix.Identity;
solid1Transform.Translation = new Vector3(0.0f, 1.5f, 0.0f);
solid1.Transform = solid1Transform;
CapsuleShapeData capsuleData = new CapsuleShapeData();
solid1.AddShape(capsuleData);

JointData jointData = new JointData();
jointData.Type = JointType.Hinge;
jointData.Solid0 = solid0;
jointData.Solid1 = solid1;
jointData.Anchor = new Vector3(0.0f, 0.75f, 0.0f);
jointData.Axis[0].Direction = new Vector3(1.0f, 0.0f, 0.0f);
joint.Init(jointData); 


Note that a Joint can connect two Solids, or it can pin a single Solid to the static environment by simply setting the Joint’s other Solid to null.

Limits

Joints can have limits for each of their degrees of freedom. Let’s create another Joint with some limits:
JointData jointData = new JointData();
jointData.Type = JointType.Hinge;
jointData.Solid0 = solid0;
jointData.Solid1 = solid1;
jointData.Anchor = new Vector3(0.0f, 0.75f, 0.0f);
jointData.Axis[0].Direction = new Vector3(1.0f, 0.0f, 0.0f);
jointData.Axis[0].LimitsEnabled = true;
jointData.Axis[0].Limits.Low = -45.0f;
jointData.Axis[0].Limits.High = 25.0f;
joint.Init(jointData); 


In the above example the limits will be considered to be angles, because axis 0 for hinge joint is rotational. If the axis was not rotational, the limits would be considered to be distances instead.

Breakable

By default, Joints are unbreakable: they can withstand unlimited amounts of stress. Joints can also be setup as breakable Joints. The following code sets up an existing Joint in “threshold” break mode (when the combined force and torque on the Joint exceeds some threshold, it breaks):
joint.SetBreakParams(JointBreakMode.Threshold, 3.0f, 0.0f); 


Another Joint break mode in XPA is “accumulated” mode: stress is accumulated until it exceeds a threshold, at which point the Joint breaks. When a Joint breaks, it is immediately disabled, and the Joint’s JointBreakEventHandler is notified (if one has been set).

Monitoring

You can easily get current status of the joint's damage, by accessing the following methods:
float Joint.BreakThresh;
float Joint.AccumulatedDamage;
float Joint.AccumulatedThresh;
bool Joint.IsBroken;
void Joint.RepairAccumDamage(); 


See API for more info.

Clean Up

When you are done with a Joint, tell the Simulator to destroy it:
sim.DestroyJoint(joint); 


If anything depends on this Joint, like a Motor, it will automatically be disabled.

Last edited Oct 12, 2006 at 7:01 PM by KleMiX, version 2

Comments

No comments yet.