Java Code Examples for com.jme3.animation.Skeleton#getBoneIndex()

The following examples show how to use com.jme3.animation.Skeleton#getBoneIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FbxMesh.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void applyCluster(FbxCluster cluster) {
    if (boneIndices == null) {
        boneIndices = new ArrayList[positions.length];
        boneWeights = new ArrayList[positions.length];
    }
    
    FbxLimbNode limb = cluster.getLimb();
    Bone bone = limb.getJmeBone();
    Skeleton skeleton = limb.getSkeletonHolder().getJmeSkeleton();
    int boneIndex = skeleton.getBoneIndex(bone);
    
    int[] positionIndices = cluster.getVertexIndices();
    double[] weights = cluster.getWeights();
    
    for (int i = 0; i < positionIndices.length; i++) {
        int positionIndex = positionIndices[i];
        float boneWeight = (float)weights[i];
        
        ArrayList<Integer> boneIndicesForVertex = boneIndices[positionIndex];
        ArrayList<Float>  boneWeightsForVertex = boneWeights[positionIndex];
        
        if (boneIndicesForVertex == null) {
            boneIndicesForVertex = new ArrayList<Integer>();
            boneWeightsForVertex = new ArrayList<Float>();
            boneIndices[positionIndex] = boneIndicesForVertex;
            boneWeights[positionIndex] = boneWeightsForVertex;
        }
        
        boneIndicesForVertex.add(boneIndex);
        boneWeightsForVertex.add(boneWeight);
    }
}
 
Example 2
Source File: FbxNode.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setSkeleton(Skeleton skeleton) {
	if(bone != null)
		boneIndex = skeleton.getBoneIndex(bone);
}