static Joint findMainBone(Armature skeleton, Mesh[] targetMeshes) {
        Joint[] rootBones = skeleton.getRoots();

        Joint result;
        if (rootBones.length == 1) {
            result = rootBones[0];
        } else {
            result = null;
            float[] totalWeights = totalWeights(targetMeshes, skeleton);
            float greatestTotalWeight = Float.NEGATIVE_INFINITY;
            for (Joint rootBone : rootBones) {
                int boneIndex = skeleton.getJointIndex(rootBone);
                float weight = totalWeights[boneIndex];
                if (weight > greatestTotalWeight) {
                    result = rootBone;
                    greatestTotalWeight = weight;
                }
            }
        }

        return result;
    }
Find the main root bone of a skeleton, based on its total bone weight.

@param skeleton the skeleton (not null, unaffected)
@param targetMeshes an array of animated meshes to provide bone weights
(not null)
@return a root bone, or null if none found
jme3-jbullet/src/main/java/com/jme3/bullet/animation/RagUtils.java