Search in sources :

Example 1 with SkeletonBone

use of io.xol.chunkstories.api.animation.SkeletalAnimation.SkeletonBone in project chunkstories-api by Hugobros3.

the class CompoundAnimationHelper method getBoneHierarchyTransformationMatrixInternal.

private final Matrix4fc getBoneHierarchyTransformationMatrixInternal(String boneName, double animationTime) {
    SkeletalAnimation animation = getAnimationPlayingForBone(boneName, animationTime);
    SkeletonBone bone = animation.getBone(boneName);
    // Out if null
    if (bone == null) {
        System.out.println("null bone");
        return new Matrix4f();
    }
    // Get this very bone transformation matrix
    Matrix4fc thisBoneMatrix = getBoneTransformationMatrix(boneName, animationTime);
    // Transform by parent if existant
    SkeletonBone parent = animation.getBone(boneName).getParent();
    if (parent != null) {
        Matrix4f thisBoneMatrix2 = new Matrix4f();
        getBoneHierarchyTransformationMatrixInternal(parent.getName(), animationTime).mul(thisBoneMatrix, thisBoneMatrix2);
        return thisBoneMatrix2;
    }
    return thisBoneMatrix;
}
Also used : Matrix4fc(org.joml.Matrix4fc) Matrix4f(org.joml.Matrix4f) SkeletonBone(io.xol.chunkstories.api.animation.SkeletalAnimation.SkeletonBone)

Aggregations

SkeletonBone (io.xol.chunkstories.api.animation.SkeletalAnimation.SkeletonBone)1 Matrix4f (org.joml.Matrix4f)1 Matrix4fc (org.joml.Matrix4fc)1