diff --git a/src/main/java/io/eiren/gui/VRServerGUI.java b/src/main/java/io/eiren/gui/VRServerGUI.java index 04b084478..779f02333 100644 --- a/src/main/java/io/eiren/gui/VRServerGUI.java +++ b/src/main/java/io/eiren/gui/VRServerGUI.java @@ -91,6 +91,15 @@ public class VRServerGUI extends JFrame { } }); }}); + add(Box.createHorizontalStrut(10)); + add(new JButton("Fast Reset") {{ + addMouseListener(new MouseInputAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + resetFast(); + } + }); + }}); add(Box.createHorizontalGlue()); add(new JButton("GUI Zoom (x" + StringUtils.prettyNumber(zoom, 2) + ")") {{ addMouseListener(new MouseInputAdapter() { @@ -234,6 +243,11 @@ public class VRServerGUI extends JFrame { } } + @AWTThread + private void resetFast() { + server.resetTrackersYaw(); + } + @AWTThread private void reset() { ButtonTimer.runTimer(resetButton, 3, "RESET", server::resetTrackers); diff --git a/src/main/java/io/eiren/vr/Main.java b/src/main/java/io/eiren/vr/Main.java index fea892e2d..9f4e5f13b 100644 --- a/src/main/java/io/eiren/vr/Main.java +++ b/src/main/java/io/eiren/vr/Main.java @@ -7,7 +7,7 @@ import io.eiren.util.logging.LogManager; public class Main { - public static String VERSION = "0.0.13 Test 3"; + public static String VERSION = "0.0.13 Test 4"; public static VRServer vrServer; diff --git a/src/main/java/io/eiren/vr/VRServer.java b/src/main/java/io/eiren/vr/VRServer.java index f15f868e9..a4dad1dea 100644 --- a/src/main/java/io/eiren/vr/VRServer.java +++ b/src/main/java/io/eiren/vr/VRServer.java @@ -234,6 +234,12 @@ public class VRServer extends Thread { }); } + public void resetTrackersYaw() { + queueTask(() -> { + humanPoseProcessor.resetTrackersYaw(); + }); + } + public int getTrackersCount() { return trackers.size(); } diff --git a/src/main/java/io/eiren/vr/processor/HumanPoseProcessor.java b/src/main/java/io/eiren/vr/processor/HumanPoseProcessor.java index cba7b3dc1..5b2dc9ce9 100644 --- a/src/main/java/io/eiren/vr/processor/HumanPoseProcessor.java +++ b/src/main/java/io/eiren/vr/processor/HumanPoseProcessor.java @@ -126,4 +126,10 @@ public class HumanPoseProcessor { if(skeleton != null) skeleton.resetTrackersFull(); } + + @VRServerThread + public void resetTrackersYaw() { + if(skeleton != null) + skeleton.resetTrackersYaw(); + } } diff --git a/src/main/java/io/eiren/vr/processor/HumanSekeletonWithLegs.java b/src/main/java/io/eiren/vr/processor/HumanSekeletonWithLegs.java index 22e8015e4..dcae277ab 100644 --- a/src/main/java/io/eiren/vr/processor/HumanSekeletonWithLegs.java +++ b/src/main/java/io/eiren/vr/processor/HumanSekeletonWithLegs.java @@ -325,4 +325,35 @@ public class HumanSekeletonWithLegs extends HumanSkeleonWithWaist { this.rightFootTracker.resetFull(referenceRotation); } } + + @Override + @VRServerThread + public void resetTrackersYaw() { + // Each tracker uses the tracker before it to adjust iteself, + // so trackers that don't need adjustments could be used too + super.resetTrackersYaw(); + // Start with waist, it was reset in the parent + Quaternion referenceRotation = new Quaternion(); + this.waistTracker.getRotation(referenceRotation); + + this.leftLegTracker.resetYaw(referenceRotation); + this.rightLegTracker.resetYaw(referenceRotation); + this.leftLegTracker.getRotation(referenceRotation); + + this.leftAnkleTracker.resetYaw(referenceRotation); + this.leftAnkleTracker.getRotation(referenceRotation); + + if(this.leftFootTracker != null) { + this.leftFootTracker.resetYaw(referenceRotation); + } + + this.rightLegTracker.getRotation(referenceRotation); + + this.rightAnkleTracker.resetYaw(referenceRotation); + this.rightAnkleTracker.getRotation(referenceRotation); + + if(this.rightFootTracker != null) { + this.rightFootTracker.resetYaw(referenceRotation); + } + } } diff --git a/src/main/java/io/eiren/vr/processor/HumanSkeleonWithWaist.java b/src/main/java/io/eiren/vr/processor/HumanSkeleonWithWaist.java index daeb9c86a..06dc68a5d 100644 --- a/src/main/java/io/eiren/vr/processor/HumanSkeleonWithWaist.java +++ b/src/main/java/io/eiren/vr/processor/HumanSkeleonWithWaist.java @@ -236,4 +236,18 @@ public class HumanSkeleonWithWaist extends HumanSkeleton { this.waistTracker.resetFull(referenceRotation); } + + @Override + @VRServerThread + public void resetTrackersYaw() { + // Each tracker uses the tracker before it to adjust iteself, + // so trackers that don't need adjustments could be used too + Quaternion referenceRotation = new Quaternion(); + server.hmdTracker.getRotation(referenceRotation); + + this.chestTracker.resetYaw(referenceRotation); + this.chestTracker.getRotation(referenceRotation); + + this.waistTracker.resetYaw(referenceRotation); + } } diff --git a/src/main/java/io/eiren/vr/processor/HumanSkeleton.java b/src/main/java/io/eiren/vr/processor/HumanSkeleton.java index 1b09a0bbb..ab537a6cf 100644 --- a/src/main/java/io/eiren/vr/processor/HumanSkeleton.java +++ b/src/main/java/io/eiren/vr/processor/HumanSkeleton.java @@ -24,4 +24,7 @@ public abstract class HumanSkeleton { @VRServerThread public abstract void resetTrackersFull(); + + @VRServerThread + public abstract void resetTrackersYaw(); } diff --git a/src/main/java/io/eiren/vr/trackers/ReferenceAdjustedTracker.java b/src/main/java/io/eiren/vr/trackers/ReferenceAdjustedTracker.java index 597c5cca5..bbc62e85f 100644 --- a/src/main/java/io/eiren/vr/trackers/ReferenceAdjustedTracker.java +++ b/src/main/java/io/eiren/vr/trackers/ReferenceAdjustedTracker.java @@ -52,7 +52,7 @@ public class ReferenceAdjustedTracker implements Tracker { gyroFix.mult(sensorRotation, sensorRotation); attachmentFix.set(sensorRotation).inverseLocal(); - resetYaw(reference); + fixYaw(reference); } /** @@ -64,6 +64,10 @@ public class ReferenceAdjustedTracker implements Tracker { */ @Override public void resetYaw(Quaternion reference) { + fixYaw(reference); + } + + private void fixYaw(Quaternion reference) { // Use only yaw HMD rotation Quaternion targetTrackerRotation = new Quaternion(reference); float[] angles = new float[3];