diff --git a/rainbow/src/main/java/org/geysermc/rainbow/mapping/animation/AnimationMapper.java b/rainbow/src/main/java/org/geysermc/rainbow/mapping/animation/AnimationMapper.java index 3901502..30a641d 100644 --- a/rainbow/src/main/java/org/geysermc/rainbow/mapping/animation/AnimationMapper.java +++ b/rainbow/src/main/java/org/geysermc/rainbow/mapping/animation/AnimationMapper.java @@ -6,15 +6,12 @@ import org.geysermc.rainbow.pack.animation.BedrockAnimation; import org.joml.Vector3f; import org.joml.Vector3fc; -// TODO these offset values are completely wrong, I think +// TODO these offset values are still not entirely right, I think public class AnimationMapper { - // These aren't perfect... but I spent over 1.5 hours trying to get these. It's good enough for me. private static final Vector3fc FIRST_PERSON_POSITION_OFFSET = new Vector3f(-7.0F, 22.5F, -7.0F); private static final Vector3fc FIRST_PERSON_ROTATION_OFFSET = new Vector3f(-22.5F, 50.0F, -32.5F); - private static final Vector3fc THIRD_PERSON_POSITION_OFFSET = new Vector3f(0.0F, 13.0F, -3.0F); - private static final Vector3fc THIRD_PERSON_ROTATION_OFFSET = new Vector3f(90.0F, -90.0F, 0.0F); - + // These transformations perfect... but I spent over 3 hours trying to get these. It's good enough for me. public static BedrockAnimationContext mapAnimation(String identifier, String bone, ItemTransforms transforms) { // I don't think it's possible to display separate animations for left- and right hands ItemTransform firstPerson = transforms.firstPersonRightHand(); @@ -23,8 +20,10 @@ public class AnimationMapper { Vector3f firstPersonScale = new Vector3f(firstPerson.scale()); ItemTransform thirdPerson = transforms.thirdPersonRightHand(); - Vector3f thirdPersonPosition = THIRD_PERSON_POSITION_OFFSET.add(thirdPerson.translation(), new Vector3f()); - Vector3f thirdPersonRotation = THIRD_PERSON_ROTATION_OFFSET.add(-thirdPerson.rotation().x(), thirdPerson.rotation().y(), thirdPerson.rotation().z(), new Vector3f()); + // Translation Y/Z axes are swapped on bedrock, bedrock displays the model lower than Java does, and the X/Y axes (Java) is inverted on bedrock + Vector3f thirdPersonPosition = new Vector3f(-thirdPerson.translation().x(), 10.0F + thirdPerson.translation().z(), -thirdPerson.translation().y()); + // Rotation X/Y axes are inverted on bedrock, bedrock needs a +90-degree rotation on the X axis, and I couldn't figure out how the Z axis works + Vector3f thirdPersonRotation = new Vector3f(-thirdPerson.rotation().x() + 90.0F, -thirdPerson.rotation().y(), 0.0F); Vector3f thirdPersonScale = new Vector3f(thirdPerson.scale()); return new BedrockAnimationContext(BedrockAnimation.builder()