Cleanup tracker list, added tracker adjustment setting

This commit is contained in:
Eiren Rain committed 2021-03-19 17:29:39 +03:00
1 parent bb82e7bbfd
commit 86e98ca143
2 files changed
+10 -4

No files matched your search

+4 -4
View File
@@ -204,21 +204,21 @@ public class TrackersList extends EJBag {
@Override
public TrackerRow build(int n) {
super.build(n);
n++;
/*n++;
add(new JLabel("Mag / Accel:"), c(0, n, 2, GridBagConstraints.FIRST_LINE_END));
add(mx = new JLabel("0"), c(2, n, 2, GridBagConstraints.FIRST_LINE_START));
add(my = new JLabel("0"), c(3, n, 2, GridBagConstraints.FIRST_LINE_START));
add(mz = new JLabel("0"), c(4, n, 2, GridBagConstraints.FIRST_LINE_START));
add(ax = new JLabel("0"), c(5, n, 2, GridBagConstraints.FIRST_LINE_START));
add(ay = new JLabel("0"), c(6, n, 2, GridBagConstraints.FIRST_LINE_START));
add(az = new JLabel("0"), c(7, n, 2, GridBagConstraints.FIRST_LINE_START));
add(az = new JLabel("0"), c(7, n, 2, GridBagConstraints.FIRST_LINE_START));*/
return this;
}
@Override
public void update() {
super.update();
q.lookAt(it.magVector, Vector3f.UNIT_Y);
/*q.lookAt(it.magVector, Vector3f.UNIT_Y);
q.toAngles(angles);
mx.setText(StringUtils.prettyNumber(angles[0] * FastMath.RAD_TO_DEG, 0));
my.setText(StringUtils.prettyNumber(angles[1] * FastMath.RAD_TO_DEG, 0));
@@ -227,7 +227,7 @@ public class TrackersList extends EJBag {
q.toAngles(angles);
ax.setText(StringUtils.prettyNumber(angles[0] * FastMath.RAD_TO_DEG, 0));
ay.setText(StringUtils.prettyNumber(angles[1] * FastMath.RAD_TO_DEG, 0));
az.setText(StringUtils.prettyNumber(angles[2] * FastMath.RAD_TO_DEG, 0));
az.setText(StringUtils.prettyNumber(angles[2] * FastMath.RAD_TO_DEG, 0));*/
}
@Override
@@ -3,6 +3,7 @@ package io.eiren.vr.trackers;
import java.nio.ByteBuffer;
import java.util.function.Consumer;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
@@ -15,6 +16,7 @@ public class IMUTracker implements Tracker, CalibratingTracker, TrackerWithTPS,
public final Vector3f accelVector = new Vector3f();
public final Vector3f magVector = new Vector3f();
public final Quaternion rotQuaternion = new Quaternion();
protected final Quaternion rotAdjust = new Quaternion();
protected TrackerStatus status = TrackerStatus.OK;
protected final String name;
@@ -39,6 +41,9 @@ public class IMUTracker implements Tracker, CalibratingTracker, TrackerWithTPS,
@Override
public void loadConfig(TrackerConfig config) {
if(!FloatMath.equalsToZero(config.trackerRotation)) {
rotAdjust.fromAngles(0, config.trackerRotation * FastMath.DEG_TO_RAD, 0);
}
}
@Override
@@ -55,6 +60,7 @@ public class IMUTracker implements Tracker, CalibratingTracker, TrackerWithTPS,
@Override
public boolean getRotation(Quaternion store) {
store.set(rotQuaternion);
store.multLocal(rotAdjust);
return true;
}