From 7ecec380a932bcea15f133604b366068daaed069 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 7 Oct 2024 21:40:36 +0200 Subject: [PATCH] fix: animation rotation angle and speed --- .../signals/animation/AnimationRotionCalc.java | 6 ++---- .../signals/animation/SignalAnimationRotation.java | 10 ++++++---- .../opensignals/animations/railroadgateanimated.json | 6 +++--- .../assets/opensignals/animations/semaphoresignal.json | 5 +++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/troblecodings/signals/animation/AnimationRotionCalc.java b/src/main/java/com/troblecodings/signals/animation/AnimationRotionCalc.java index 3e0626680..8edd3cf4a 100644 --- a/src/main/java/com/troblecodings/signals/animation/AnimationRotionCalc.java +++ b/src/main/java/com/troblecodings/signals/animation/AnimationRotionCalc.java @@ -50,13 +50,11 @@ public void updateAnimation() { public boolean isAnimationFinished() { if (step > 0) { - if (progress < max) { + if (progress < max) return false; - } } else { - if (max < progress) { + if (max < progress) return false; - } } return true; } diff --git a/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java b/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java index 026419399..826b8af56 100644 --- a/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java +++ b/src/main/java/com/troblecodings/signals/animation/SignalAnimationRotation.java @@ -10,6 +10,8 @@ public class SignalAnimationRotation implements SignalAnimation { + private static float factor = 3.49065f; + private AnimationRotionCalc calc; private final Predicate> predicate; @@ -39,15 +41,15 @@ public void setUpAnimationValues(final ModelTranslation currentTranslation) { Vector3f maxPos = new Vector3f(0, 0, 0); switch (axis) { case X: { - maxPos = new Vector3f(-rotation * 0.005f * animationSpeed, 0, 0); + maxPos = new Vector3f(rotation * 0.005f * factor, 0, 0); break; } case Y: { - maxPos = new Vector3f(0, -rotation * 0.005f * animationSpeed, 0); + maxPos = new Vector3f(0, rotation * 0.005f * factor, 0); break; } case Z: { - maxPos = new Vector3f(0, 0, -rotation * 0.005f * animationSpeed); + maxPos = new Vector3f(0, 0, rotation * 0.005f * factor); break; } default: @@ -58,7 +60,7 @@ public void setUpAnimationValues(final ModelTranslation currentTranslation) { @Override public ModelTranslation getFinalModelTranslation() { - return new ModelTranslation(pivot, axis.getForAxis(-rotation * 0.005f * animationSpeed)); + return new ModelTranslation(pivot, axis.getForAxis(rotation * 0.005f * factor)); } @Override diff --git a/src/main/resources/assets/opensignals/animations/railroadgateanimated.json b/src/main/resources/assets/opensignals/animations/railroadgateanimated.json index f938e164b..c8de0b926 100644 --- a/src/main/resources/assets/opensignals/animations/railroadgateanimated.json +++ b/src/main/resources/assets/opensignals/animations/railroadgateanimated.json @@ -18,7 +18,7 @@ "predicate": "config(BARRIER_OPEN.TRUE)", "mode": "ROTATION", "rotationAxis": "Z", - "rotation": -310, + "rotation": 90, "pivotX": 0, "pivotY": 0, "pivotZ": 0 @@ -43,7 +43,7 @@ "predicate": "config(BARRIER_OPEN.TRUE)", "mode": "ROTATION", "rotationAxis": "Z", - "rotation": -310, + "rotation": 90, "pivotX": 0, "pivotY": 0, "pivotZ": 0 @@ -68,7 +68,7 @@ "predicate": "config(BARRIER_OPEN.TRUE)", "mode": "ROTATION", "rotationAxis": "Z", - "rotation": -310, + "rotation": 90, "pivotX": 0, "pivotY": 0, "pivotZ": 0 diff --git a/src/main/resources/assets/opensignals/animations/semaphoresignal.json b/src/main/resources/assets/opensignals/animations/semaphoresignal.json index 124a273ca..49c3c8bc7 100644 --- a/src/main/resources/assets/opensignals/animations/semaphoresignal.json +++ b/src/main/resources/assets/opensignals/animations/semaphoresignal.json @@ -4,6 +4,7 @@ "translationX": 0.15, "translationY": 6.95, "translationZ": -0.5, + "animationConfigs": [ { "predicate": "config(WING1.FALSE)", @@ -18,7 +19,7 @@ "predicate": "config(WING1.TRUE)", "mode": "ROTATION", "rotationAxis": "Z", - "rotation": 155, + "rotation": -45, "pivotX": -0.65, "pivotY": -4.45, "pivotZ": 0 @@ -40,7 +41,7 @@ "predicate": "config(WING2.TRUE)", "mode": "ROTATION", "rotationAxis": "Z", - "rotation": -100, + "rotation": 45, "pivotX": 0, "pivotY": 0, "pivotZ": 0