MinieLibrary/src/main/java/com/jme3/bullet/animation/RagUtils.java
/**
     * Find the main root bone of a Skeleton, based on its total mesh 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
     */
Find the main root bone of a Skeleton, based on its total mesh 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
Find the main root bone of a Skeleton based on its total mesh 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
public static Bone findMainBone(Skeleton skeleton, Mesh[] targetMeshes) {
        Validate.nonNull(targetMeshes, "target meshes");
        Bone[] rootBones = skeleton.getRoots();
        Bone result;
        if (rootBones.length == 1) {
            result = rootBones[0];
        } else {
            result = null;
            float[] totalWeights = totalWeights(targetMeshes, skeleton);
            float greatestTotalWeight = Float.NEGATIVE_INFINITY;
            for (Bone rootBone : rootBones) {
                int boneIndex = skeleton.getBoneIndex(rootBone);
                float weight = totalWeights[boneIndex];
                if (weight > greatestTotalWeight) {
                    result = rootBone;
                    greatestTotalWeight = weight;
                }
            }
        }
        return result;
    }
public static Bone findMainBone ( Skeleton skeleton , Mesh [ ] targetMeshes ) { Validate . nonNull ( targetMeshes , "target meshes" ) ; Bone [ ] rootBones = skeleton . getRoots ( ) ; Bone result ; if ( rootBones . length == 1 ) { result = rootBones [ 0 ] ; } else { result = null ; float [ ] totalWeights = totalWeights ( targetMeshes , skeleton ) ; float greatestTotalWeight = Float . NEGATIVE_INFINITY ; for ( Bone rootBone : rootBones ) { int boneIndex = skeleton . getBoneIndex ( 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 mesh weight.
Find the main root bone of a Skeleton based on its total mesh weight .