MinieLibrary/src/main/java/com/jme3/bullet/animation/RagUtils.java
/**
     * Determine which physics link should manage the specified mesh vertex.
     *
     * @param mesh the mesh containing the vertex (not null, unaffected)
     * @param vertexIndex the vertex index in the mesh (&ge;0)
     * @param iArray temporary storage for bone indices (not null, modified)
     * @param wArray temporary storage for bone weights (not null, modified)
     * @param managerMap a map from bone indices to bone/torso names (not null,
     * unaffected)
     * @return a bone/torso name
     */
Determine which physics link should manage the specified mesh vertex.


Determine which physics link should manage the specified mesh vertex .
public static String findManager(Mesh mesh, int vertexIndex, int[] iArray,
            float[] wArray, String[] managerMap) {
        Validate.nonNull(mesh, "mesh");
        Validate.nonNegative(vertexIndex, "vertex index");
        Validate.nonNull(iArray, "index array");
        Validate.nonNull(wArray, "weight array");
        Validate.nonNull(managerMap, "manager map");
        MyMesh.vertexBoneIndices(mesh, vertexIndex, iArray);
        MyMesh.vertexBoneWeights(mesh, vertexIndex, wArray);
        Map<String, Float> weightMap = weightMap(iArray, wArray, managerMap);
        float bestTotalWeight = Float.NEGATIVE_INFINITY;
        String bestName = null;
        for (Map.Entry<String, Float> entry : weightMap.entrySet()) {
            float totalWeight = entry.getValue();
            if (totalWeight >= bestTotalWeight) {
                bestTotalWeight = totalWeight;
                bestName = entry.getKey();
            }
        }
        return bestName;
    }
public static String findManager ( Mesh mesh , int vertexIndex , int [ ] iArray , float [ ] wArray , String [ ] managerMap ) { Validate . nonNull ( mesh , "mesh" ) ; Validate . nonNegative ( vertexIndex , "vertex index" ) ; Validate . nonNull ( iArray , "index array" ) ; Validate . nonNull ( wArray , "weight array" ) ; Validate . nonNull ( managerMap , "manager map" ) ; MyMesh . vertexBoneIndices ( mesh , vertexIndex , iArray ) ; MyMesh . vertexBoneWeights ( mesh , vertexIndex , wArray ) ; Map < String , Float > weightMap = weightMap ( iArray , wArray , managerMap ) ; float bestTotalWeight = Float . NEGATIVE_INFINITY ; String bestName = null ; for ( Map . Entry < String , Float > entry : weightMap . entrySet ( ) ) { float totalWeight = entry . getValue ( ) ; if ( totalWeight >= bestTotalWeight ) { bestTotalWeight = totalWeight ; bestName = entry . getKey ( ) ; } } return bestName ; }
Determine which physics link should manage the specified mesh vertex.
Determine which physics link should manage the specified mesh vertex .