Can select role for SteamVR trackers

Trackers now have info if they report position or rotation
Extended pelvis model is always on
This commit is contained in:
Eiren Rain committed 2021-09-12 12:10:59 +03:00
1 parent 62e1e65dda
commit 75ad29a68d
14 files changed
+74 -25

No files matched your search

@@ -43,6 +43,7 @@ public class SkeletonConfig extends EJBag {
int row = 0;
/**
add(new JCheckBox("Extended pelvis model") {{
addItemListener(new ItemListener() {
@Override
@@ -66,7 +67,7 @@ public class SkeletonConfig extends EJBag {
}
}}, s(c(0, row, 1), 3, 1));
row++;
//*/
/*
add(new JCheckBox("Extended knee model") {{
addItemListener(new ItemListener() {
+16 -10
View File
@@ -206,13 +206,17 @@ public class TrackersList extends EJBox {
}
row++;
}
add(new JLabel("Rotation"), c(0, row, 0, GridBagConstraints.FIRST_LINE_START));
add(new JLabel("Position"), c(1, row, 0, GridBagConstraints.FIRST_LINE_START));
if(t.hasRotation())
add(new JLabel("Rotation"), c(0, row, 0, GridBagConstraints.FIRST_LINE_START));
if(t.hasPosition())
add(new JLabel("Position"), c(1, row, 0, GridBagConstraints.FIRST_LINE_START));
add(new JLabel("Ping"), c(2, row, 0, GridBagConstraints.FIRST_LINE_START));
add(new JLabel("TPS"), c(3, row, 0, GridBagConstraints.FIRST_LINE_START));
row++;
add(rotation = new JLabel("0 0 0"), c(0, row, 0, GridBagConstraints.FIRST_LINE_START));
add(position = new JLabel("0 0 0"), c(1, row, 0, GridBagConstraints.FIRST_LINE_START));
if(t.hasRotation())
add(rotation = new JLabel("0 0 0"), c(0, row, 0, GridBagConstraints.FIRST_LINE_START));
if(t.hasPosition())
add(position = new JLabel("0 0 0"), c(1, row, 0, GridBagConstraints.FIRST_LINE_START));
add(ping = new JLabel(""), c(2, row, 0, GridBagConstraints.FIRST_LINE_START));
if(realTracker instanceof TrackerWithTPS) {
add(tps = new JLabel("0"), c(3, row, 0, GridBagConstraints.FIRST_LINE_START));
@@ -266,12 +270,14 @@ public class TrackersList extends EJBox {
t.getPosition(v);
q.toAngles(angles);
position.setText(StringUtils.prettyNumber(v.x, 1)
+ " " + StringUtils.prettyNumber(v.y, 1)
+ " " + StringUtils.prettyNumber(v.z, 1));
rotation.setText(StringUtils.prettyNumber(angles[0] * FastMath.RAD_TO_DEG, 0)
+ " " + StringUtils.prettyNumber(angles[1] * FastMath.RAD_TO_DEG, 0)
+ " " + StringUtils.prettyNumber(angles[2] * FastMath.RAD_TO_DEG, 0));
if(position != null)
position.setText(StringUtils.prettyNumber(v.x, 1)
+ " " + StringUtils.prettyNumber(v.y, 1)
+ " " + StringUtils.prettyNumber(v.z, 1));
if(rotation != null)
rotation.setText(StringUtils.prettyNumber(angles[0] * FastMath.RAD_TO_DEG, 0)
+ " " + StringUtils.prettyNumber(angles[1] * FastMath.RAD_TO_DEG, 0)
+ " " + StringUtils.prettyNumber(angles[2] * FastMath.RAD_TO_DEG, 0));
status.setText(t.getStatus().toString().toLowerCase());
if(realTracker instanceof TrackerWithTPS) {
@@ -52,7 +52,7 @@ public class NamedPipeVRBridge extends Thread implements VRBridge {
this.internalTrackers = new FastList<>(shareTrackers.size());
for(int i = 0; i < shareTrackers.size(); ++i) {
Tracker t = shareTrackers.get(i);
ComputedTracker ct = new ComputedTracker("internal://" + t.getName());
ComputedTracker ct = new ComputedTracker("internal://" + t.getName(), true, true);
ct.setStatus(TrackerStatus.OK);
this.internalTrackers.add(ct);
}
@@ -105,7 +105,7 @@ public class SteamVRPipeInputBridge extends Thread implements VRBridge {
LogManager.log.severe("[SteamVRPipeInputBridge] Error in ADD command. Command requires at least 4 arguments. Supplied: " + commandBuilder.toString());
return;
}
SteamVRTracker internalTracker = new SteamVRTracker(Integer.parseInt(command[1]), StringUtils.join(command, " ", 3, command.length));
SteamVRTracker internalTracker = new SteamVRTracker(Integer.parseInt(command[1]), StringUtils.join(command, " ", 3, command.length), true, true);
int roleId = Integer.parseInt(command[2]);
if(roleId >= 0 && roleId < SteamVRInputRoles.values.length) {
SteamVRInputRoles svrRole = SteamVRInputRoles.values[roleId];
@@ -183,7 +183,7 @@ public class SteamVRPipeInputBridge extends Thread implements VRBridge {
continue internal;
}
// Tracker is not found in current trackers
SteamVRTracker tracker = new SteamVRTracker(internalTracker.id, internalTracker.getName());
SteamVRTracker tracker = new SteamVRTracker(internalTracker.id, internalTracker.getName(), true, true);
tracker.bodyPosition = internalTracker.bodyPosition;
trackers.add(tracker);
server.registerTracker(tracker);
@@ -10,7 +10,7 @@ public class ComputedHumanPoseTracker extends ComputedTracker implements Tracker
protected BufferedTimer timer = new BufferedTimer(1f);
public ComputedHumanPoseTracker(ComputedHumanPoseTrackerPosition skeletonPosition) {
super("human://" + skeletonPosition.name());
super("human://" + skeletonPosition.name(), true, true);
this.skeletonPosition = skeletonPosition;
}
@@ -8,7 +8,6 @@ import com.jme3.math.Vector3f;
import io.eiren.util.ann.VRServerThread;
import io.eiren.vr.VRServer;
import io.eiren.vr.trackers.ComputedTracker;
import io.eiren.vr.trackers.Tracker;
import io.eiren.vr.trackers.TrackerStatus;
import io.eiren.vr.trackers.TrackerUtils;
@@ -105,7 +104,7 @@ public class HumanSkeletonWithLegs extends HumanSkeletonWithWaist {
kneeHeight = server.config.getFloat("body.kneeHeight", kneeHeight);
legsLength = server.config.getFloat("body.legsLength", legsLength);
footLength = server.config.getFloat("body.footLength", footLength);
extendedPelvisModel = server.config.getBoolean("body.model.extendedPelvis", extendedPelvisModel);
//extendedPelvisModel = server.config.getBoolean("body.model.extendedPelvis", extendedPelvisModel);
extendedKneeModel = server.config.getBoolean("body.model.extendedKnee", extendedKneeModel);
waistNode.attachChild(leftHipNode);
@@ -12,9 +12,13 @@ public class ComputedTracker implements Tracker {
protected final String name;
protected TrackerStatus status = TrackerStatus.DISCONNECTED;
public TrackerBodyPosition bodyPosition = null;
protected final boolean hasRotation;
protected final boolean hasPosition;
public ComputedTracker(String name) {
public ComputedTracker(String name, boolean hasRotation, boolean hasPosition) {
this.name = name;
this.hasRotation = hasRotation;
this.hasPosition = hasPosition;
}
@Override
@@ -84,4 +88,14 @@ public class ComputedTracker implements Tracker {
@Override
public void tick() {
}
@Override
public boolean hasRotation() {
return hasRotation;
}
@Override
public boolean hasPosition() {
return hasPosition;
}
}
@@ -8,7 +8,7 @@ public class HMDTracker extends ComputedTracker implements TrackerWithTPS {
protected BufferedTimer timer = new BufferedTimer(1f);
public HMDTracker(String name) {
super(name);
super(name, true, true);
setBodyPosition(TrackerBodyPosition.HMD);
}
@@ -225,4 +225,14 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
byStatus[ca.status] = ca;
}
}
@Override
public boolean hasRotation() {
return true;
}
@Override
public boolean hasPosition() {
return false;
}
}
@@ -146,4 +146,14 @@ public class ReferenceAdjustedTracker<E extends Tracker> implements Tracker {
public void tick() {
tracker.tick();
}
@Override
public boolean hasRotation() {
return tracker.hasRotation();
}
@Override
public boolean hasPosition() {
return tracker.hasPosition();
}
}
@@ -7,8 +7,8 @@ public class SteamVRTracker extends ComputedTracker implements TrackerWithTPS {
public final int id;
protected BufferedTimer timer = new BufferedTimer(1f);
public SteamVRTracker(int id, String name) {
super(name);
public SteamVRTracker(int id, String name, boolean hasRotation, boolean hasPosition) {
super(name, hasRotation, hasPosition);
this.id = id;
}
@@ -21,4 +21,9 @@ public class SteamVRTracker extends ComputedTracker implements TrackerWithTPS {
public void dataTick() {
timer.update();
}
@Override
public boolean userEditable() {
return true;
}
}
@@ -32,4 +32,8 @@ public interface Tracker {
public void setBodyPosition(TrackerBodyPosition position);
public boolean userEditable();
public boolean hasRotation();
public boolean hasPosition();
}
@@ -32,6 +32,6 @@ public class TrackerUtils {
t = findTrackerForBodyPosition(allTrackers, altPosition);
if(t != null)
return t;
return new ComputedTracker("Empty tracker");
return new ComputedTracker("Empty tracker", false, false);
}
}