# a brief look at physics joints in jME3

Added 27 Oct 2013, 6:01 p.m. edited 19 Jun 2023, 3:39 a.m.

While blocks falling and hitting a flat plane or even a landscape is great, where dynamics libraries really come into their own is joints or constrains between two bodies... For example use the right constraint between bodies - lets call them planks and you have a bridge (for the advanced user peek at the applied forces being used to solve the constraint and you can tell when the bridge is overloaded and make the appropriate joints fail....). Probably the most common use for joints would be the vehicle class provided by bullet, its the joints that create the wheels both for motors and steering. The example that you can see in the video above demonstrates two different joints a hinge joint and the very flexible 6DoF joint. The hinge joint basically works like you'd assume, however by default it is without rotational constraints on its one axis of rotation, its basically ideal to use for wheel / axle joints by default. The 6DoF joint (Six Degrees of Freedom) is the most complex but equally the most useful. The six degrees refers to being able to move on all three axes (X,Y & Z) and additionally able to rotate round the same axes. Lets look first in a little more detail at the hinge joint

```        RigidBodyControl anchor1 = makeAblock(new Vector3f(0,0,0), 0);
bob1 = makeAblock(new Vector3f(0,1f,0), 1f);

joint = new HingeJoint(
anchor1,                    // obj A
bob1,                       // obj B
Vector3f.ZERO,              // pivot point local to A
new Vector3f(0f, 1, 0f),    // pivot point local to B
Vector3f.UNIT_Z,            // movement axis for A
Vector3f.UNIT_Z);           // movement axis for B
makeAblock is just for convenience it does nothing more than clone a mesh add a physics control to it and return the physics controller, it simply takes a position and mass for its parameters. Once you have finished one experiment with a joint and are happy with it this routine should make it real easy to add yet another joint to play with, that way you can make yourself a whole library of useful joint setups... Objects without mass rather than traveling at the speed of light as you'd expect are actually stationary - see its a dynamics library after all not a physics library ;) The joint constructor is fairly easy to follow and in the fragment above I've commented each parameter. The pivot points are both local in their frame of reference, ie when you are defining where the pivot point is in say object A, think of object A as the centre of the universe i.e. 0,0,0 The movement axes are axes that the hinge joint is working on, by changing the axes relative to each other you can have an axle / wheel joint or just make something orbit round the anchor point at a fixed distance... Obviously things get a tiny bit more complex with the 6DoF joint just alone because of its flexibility...
```
anchor2 = makeAblock(new Vector3f(2,0,0), 0);
bob2 = makeAblock(new Vector3f(2,-1f,0), 1f);
bob2.setAngularDamping(0.8f);

joint2 = new SixDofJoint(
anchor2,
bob2,
new Vector3f(0,0,0),
new Vector3f(0,1f,0),
true);
TranslationalLimitMotor tm = joint2.getTranslationalLimitMotor();
tm.setLimitSoftness(.1f);
tm.setRestitution(0.1f);

tm.setLowerLimit(new Vector3f(0,-.5f,0));
tm.setUpperLimit(new Vector3f(0,.5f,0));

`Bullet-Native: Initializing java classes`
`Bullet-Native: Initializing java classes`