Physics control of a 3D model

I was wondering if there are any examples of controlling a 3D model's skeleton using an underlying physics model.

I understand that I need to translate the world coordinates of the physics nodes to the appropriate local coordinates in the skeletal model, but my model ends up being unstable as I move further from the root.

For example, if I have a 3D model with a linear skeleton





and a physics model with 3 DynamicPhysicsNodes connected by rotational joints anchored between them, then I use the following code fragment to update the translations and rotations of the bones.  The first if statement aligns the root bone to the front of the first PhysicsNode and the the rest get aligned to the locations of the joints.

for (int i = 0; i < bones.size(); i++) {
   if (i == 0) {
      Segment thisSegment = segments.get(i);
      translation = new Vector3f(0, 0, thisSegment

      Quaternion rotation = thisSegment.getLocalRotation();

      prevSegment = thisSegment;
      Segment thisSegment = segments.get(i-1);

      translation = new Vector3f(0, 0, thisSegment

      Quaternion rotation = prevSegment.getLocalRotation();
      rotation = rotation.inverse().multLocal(thisSegment.getLocalRotation());

      prevSegment = thisSegment;


It works  fine for a few in a straight line but starts to jitter the further away from the root I get.

Any help would be appreciated

Hello i would like to know if you found a solution to your problem.

Thank you.