53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
package electrosphere.renderer.model;
 | 
						|
 | 
						|
import java.util.HashMap;
 | 
						|
import java.util.Map;
 | 
						|
 | 
						|
import org.joml.Matrix4d;
 | 
						|
import org.lwjgl.assimp.AIBone;
 | 
						|
 | 
						|
 | 
						|
/**
 | 
						|
 * Keeps track of bone data
 | 
						|
 */
 | 
						|
public class Bone {
 | 
						|
    public String boneID;
 | 
						|
    int numWeights;
 | 
						|
    Map<Integer,Float> weights = new HashMap<Integer,Float>();
 | 
						|
    public Matrix4d inverseBindPoseMatrix;
 | 
						|
    public Matrix4d deform;
 | 
						|
    public Matrix4d transform;
 | 
						|
    public Matrix4d final_transform;
 | 
						|
    public AIBone raw_data;
 | 
						|
    public Bone(){
 | 
						|
        transform = new Matrix4d();
 | 
						|
        deform = new Matrix4d();
 | 
						|
        final_transform = new Matrix4d();
 | 
						|
    }
 | 
						|
    public Bone(AIBone raw_data){
 | 
						|
        transform = new Matrix4d();
 | 
						|
        deform = new Matrix4d();
 | 
						|
        final_transform = new Matrix4d();
 | 
						|
        boneID = raw_data.mName().dataString();
 | 
						|
        inverseBindPoseMatrix = electrosphere.util.Utilities.convertAIMatrixd(raw_data.mOffsetMatrix());
 | 
						|
        numWeights = raw_data.mNumWeights();
 | 
						|
        this.raw_data = raw_data;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Stores a bone weight
 | 
						|
     * @param index the index of the bone in the bone array in shader
 | 
						|
     * @param weight the weight for the given bone
 | 
						|
     */
 | 
						|
    public void putWeight(int index, float weight){
 | 
						|
        weights.put(index,weight);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Returns the weight map
 | 
						|
     */
 | 
						|
    public Map<Integer,Float> getWeights(){
 | 
						|
        return weights;
 | 
						|
    }
 | 
						|
}
 |