mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Implement tracker designation selection
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package io.eiren.gui;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
@@ -15,6 +18,7 @@ import io.eiren.util.ann.ThreadSafe;
|
||||
import io.eiren.util.ann.VRServerThread;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.vr.VRServer;
|
||||
import io.eiren.vr.processor.TrackerBodyPosition;
|
||||
import io.eiren.vr.trackers.ReferenceAdjustedTracker;
|
||||
import io.eiren.vr.trackers.ComputedTracker;
|
||||
import io.eiren.vr.trackers.HMDTracker;
|
||||
@@ -80,20 +84,27 @@ public class TrackersList extends EJBag {
|
||||
}
|
||||
|
||||
tr.build(n);
|
||||
TrackerConfig cfg = server.getTrackerConfig(t);
|
||||
|
||||
if(cfg.designation != null)
|
||||
add(new JLabel(cfg.designation), c(1, n, 2));
|
||||
/*if(t instanceof CalibratingTracker) {
|
||||
add(new JButton("Calibrate") {{
|
||||
addMouseListener(new MouseInputAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
new CalibrationWindow(t);
|
||||
}
|
||||
});
|
||||
}}, c(12, n, 2));
|
||||
}*/
|
||||
if(t.userEditable()) {
|
||||
TrackerConfig cfg = server.getTrackerConfig(t);
|
||||
JComboBox<String> desSelect;
|
||||
add(desSelect = new JComboBox<>(), c(1, n, 2));
|
||||
for(TrackerBodyPosition p : TrackerBodyPosition.values) {
|
||||
desSelect.addItem(p.name());
|
||||
}
|
||||
if(cfg.designation != null) {
|
||||
TrackerBodyPosition p = TrackerBodyPosition.getByDesignation(cfg.designation);
|
||||
if(p != null)
|
||||
desSelect.setSelectedItem(p.name());
|
||||
}
|
||||
desSelect.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
TrackerBodyPosition p = TrackerBodyPosition.valueOf(String.valueOf(desSelect.getSelectedItem()));
|
||||
t.setBodyPosition(p);
|
||||
server.trackerUpdated(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
n += tr.getSize();
|
||||
}
|
||||
gui.refresh();
|
||||
|
||||
@@ -75,6 +75,7 @@ public class VRServerGUI extends JFrame {
|
||||
|
||||
add(new JLabel("Trackers"));
|
||||
add(trackersList);
|
||||
add(Box.createVerticalGlue());
|
||||
}});
|
||||
|
||||
add(new EJBox(PAGE_AXIS) {{
|
||||
|
||||
@@ -113,6 +113,14 @@ public class VRServer extends Thread {
|
||||
consumer.accept(trackers.get(i));
|
||||
});
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public void trackerUpdated(Tracker tracker) {
|
||||
queueTask(() -> {
|
||||
humanPoseProcessor.trackerUpdated(tracker);
|
||||
saveConfig();
|
||||
});
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public void addSkeletonUpdatedCallback(Consumer<HumanSkeleton> consumer) {
|
||||
|
||||
@@ -41,8 +41,11 @@ public class HumanPoseProcessor {
|
||||
|
||||
@ThreadSafe
|
||||
public float getSkeletonConfig(String key) {
|
||||
if(skeleton != null)
|
||||
return skeleton.getSkeletonConfig().get(key);
|
||||
if(skeleton != null) {
|
||||
Number f = skeleton.getSkeletonConfig().get(key);
|
||||
if(f != null)
|
||||
return f.floatValue();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public enum TrackerBodyPosition {
|
||||
|
||||
public final String designation;
|
||||
|
||||
public static final TrackerBodyPosition[] values = values();
|
||||
private static final Map<String, TrackerBodyPosition> byDesignation = new HashMap<>();
|
||||
|
||||
private TrackerBodyPosition(String designation) {
|
||||
|
||||
@@ -75,4 +75,9 @@ public class ComputedTracker implements Tracker {
|
||||
public void setBodyPosition(TrackerBodyPosition position) {
|
||||
this.bodyPosition = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userEditable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,4 +126,9 @@ public class IMUTracker implements Tracker, TrackerWithTPS, TrackerWithBattery {
|
||||
public void setBodyPosition(TrackerBodyPosition position) {
|
||||
this.bodyPosition = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userEditable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,20 @@ public class ReferenceAdjustedTracker implements Tracker {
|
||||
public ReferenceAdjustedTracker(Tracker tracker) {
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userEditable() {
|
||||
return this.tracker.userEditable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfig(TrackerConfig config) {
|
||||
this.tracker.loadConfig(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig(TrackerConfig config) {
|
||||
this.tracker.saveConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,4 +28,6 @@ public interface Tracker {
|
||||
public TrackerBodyPosition getBodyPosition();
|
||||
|
||||
public void setBodyPosition(TrackerBodyPosition position);
|
||||
|
||||
public boolean userEditable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user