1
0
mirror of https://github.com/GeyserMC/Rainbow.git synced 2025-12-19 14:59:16 +00:00

Fix 3rd-person animations a bit, maybe

This commit is contained in:
Eclipse
2025-10-16 12:06:48 +00:00
parent 51ecbf1fd4
commit 2cc85d6c91

View File

@@ -6,15 +6,12 @@ import org.geysermc.rainbow.pack.animation.BedrockAnimation;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3fc; 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 { 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_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 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); // These transformations perfect... but I spent over 3 hours trying to get these. It's good enough for me.
private static final Vector3fc THIRD_PERSON_ROTATION_OFFSET = new Vector3f(90.0F, -90.0F, 0.0F);
public static BedrockAnimationContext mapAnimation(String identifier, String bone, ItemTransforms transforms) { 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 // I don't think it's possible to display separate animations for left- and right hands
ItemTransform firstPerson = transforms.firstPersonRightHand(); ItemTransform firstPerson = transforms.firstPersonRightHand();
@@ -23,8 +20,10 @@ public class AnimationMapper {
Vector3f firstPersonScale = new Vector3f(firstPerson.scale()); Vector3f firstPersonScale = new Vector3f(firstPerson.scale());
ItemTransform thirdPerson = transforms.thirdPersonRightHand(); ItemTransform thirdPerson = transforms.thirdPersonRightHand();
Vector3f thirdPersonPosition = THIRD_PERSON_POSITION_OFFSET.add(thirdPerson.translation(), 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 thirdPersonRotation = THIRD_PERSON_ROTATION_OFFSET.add(-thirdPerson.rotation().x(), thirdPerson.rotation().y(), thirdPerson.rotation().z(), new Vector3f()); 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()); Vector3f thirdPersonScale = new Vector3f(thirdPerson.scale());
return new BedrockAnimationContext(BedrockAnimation.builder() return new BedrockAnimationContext(BedrockAnimation.builder()