MinieLibrary/src/main/java/com/jme3/bullet/animation/RagUtils.java
/**
     * Add the vertex weights of each bone in the specified mesh to an array of
     * total weights.
     *
     * @param mesh animated mesh to analyze (not null, unaffected)
     * @param totalWeights (not null, modified)
     */
Add the vertex weights of each bone in the specified mesh to an array of
total weights.

@param mesh animated mesh to analyze (not null, unaffected)
@param totalWeights (not null, modified)
Add the vertex weights of each bone in the specified mesh to an array of total weights . @param mesh animated mesh to analyze ( not null unaffected ) @param totalWeights ( not null modified )
private static void addWeights(Mesh mesh, float[] totalWeights) {
        assert totalWeights != null;
        int maxWeightsPerVert = mesh.getMaxNumWeights();
        if (maxWeightsPerVert <= 0) {
            maxWeightsPerVert = 1;
        }
        assert maxWeightsPerVert > 0 : maxWeightsPerVert;
        assert maxWeightsPerVert <= 4 : maxWeightsPerVert;
        VertexBuffer biBuf = mesh.getBuffer(VertexBuffer.Type.BoneIndex);
        Buffer boneIndexBuffer = biBuf.getDataReadOnly();
        boneIndexBuffer.rewind();
        int numBoneIndices = boneIndexBuffer.remaining();
        assert numBoneIndices % 4 == 0 : numBoneIndices;
        int numVertices = boneIndexBuffer.remaining() / 4;
        FloatBuffer weightBuffer
                = mesh.getFloatBuffer(VertexBuffer.Type.BoneWeight);
        weightBuffer.rewind();
        int numWeights = weightBuffer.remaining();
        assert numWeights == numVertices * 4 : numWeights;
        for (int vIndex = 0; vIndex < numVertices; ++vIndex) {
            for (int wIndex = 0; wIndex < 4; ++wIndex) {
                float weight = weightBuffer.get();
                int boneIndex = MyBuffer.readIndex(boneIndexBuffer);
                if (wIndex < maxWeightsPerVert) {
                    totalWeights[boneIndex] += FastMath.abs(weight);
                }
            }
        }
    }
private static void addWeights ( Mesh mesh , float [ ] totalWeights ) { assert totalWeights != null ; int maxWeightsPerVert = mesh . getMaxNumWeights ( ) ; if ( maxWeightsPerVert <= 0 ) { maxWeightsPerVert = 1 ; } assert maxWeightsPerVert > 0 : maxWeightsPerVert ; assert maxWeightsPerVert <= 4 : maxWeightsPerVert ; VertexBuffer biBuf = mesh . getBuffer ( VertexBuffer . Type . BoneIndex ) ; Buffer boneIndexBuffer = biBuf . getDataReadOnly ( ) ; boneIndexBuffer . rewind ( ) ; int numBoneIndices = boneIndexBuffer . remaining ( ) ; assert numBoneIndices % 4 == 0 : numBoneIndices ; int numVertices = boneIndexBuffer . remaining ( ) / 4 ; FloatBuffer weightBuffer = mesh . getFloatBuffer ( VertexBuffer . Type . BoneWeight ) ; weightBuffer . rewind ( ) ; int numWeights = weightBuffer . remaining ( ) ; assert numWeights == numVertices * 4 : numWeights ; for ( int vIndex = 0 ; vIndex < numVertices ; ++ vIndex ) { for ( int wIndex = 0 ; wIndex < 4 ; ++ wIndex ) { float weight = weightBuffer . get ( ) ; int boneIndex = MyBuffer . readIndex ( boneIndexBuffer ) ; if ( wIndex < maxWeightsPerVert ) { totalWeights [ boneIndex ] += FastMath . abs ( weight ) ; } } } }
Add the vertex weights of each bone in the specified mesh to an array of
 total weights.
Add the vertex weights of each bone in the specified mesh to an array of total weights .