use of org.joml.Matrix4fc 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;
}
use of org.joml.Matrix4fc in project chunkstories by Hugobros3.
the class BonedRenderer method internalRenderer.
private void internalRenderer(RenderingInterface renderingContext, SkeletonAnimator skeleton, double animationTime) {
prepareDraw(renderingContext);
Shader shader = renderingContext.currentShader();
if (skeleton != null) {
for (int i = 0; i < boneName.length; i++) {
if (skeleton.shouldHideBone(renderingContext, boneName[i])) {
Matrix4f boneMatrix = new Matrix4f();
boneMatrix.translate(50000, 50000, 50000);
shader.setUniformMatrix4f("bones[" + i + "]", boneMatrix);
} else {
Matrix4fc boneMatrix = skeleton.getBoneHierarchyTransformationMatrixWithOffset(boneName[i], animationTime < 0 ? 0 : animationTime);
shader.setUniformMatrix4f("bones[" + i + "]", boneMatrix);
}
}
}
renderingContext.draw(Primitive.TRIANGLE, 0, verticesCount);
}
use of org.joml.Matrix4fc in project chunkstories-core by Hugobros3.
the class CachedLodSkeletonAnimator method getBoneHierarchyTransformationMatrixWithOffset.
@Override
public Matrix4fc getBoneHierarchyTransformationMatrixWithOffset(String nameOfEndBone, double animationTime) {
// Don't mess with the player animation, it should NEVER be cached
if (entity.getWorld() instanceof WorldClient && ((WorldClient) entity.getWorld()).getClient() != null && ((WorldClient) entity.getWorld()).getClient().getPlayer().getControlledEntity() == entity)
return dataSource.getBoneHierarchyTransformationMatrixWithOffset(nameOfEndBone, animationTime);
CachedData cachedData = cachedBones.get(nameOfEndBone);
// If the matrix exists and doesn't need an update
if (cachedData != null && !cachedData.needsUpdate) {
cachedData.needsUpdate = false;
return cachedData.matrix;
}
// Obtains the matrix and caches it
Matrix4fc matrix = dataSource.getBoneHierarchyTransformationMatrixWithOffset(nameOfEndBone, animationTime);
cachedBones.put(nameOfEndBone, new CachedData(matrix, System.currentTimeMillis()));
return matrix;
}
Aggregations