mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Skeleton Separation Refactor (#442)
This commit is contained in:
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@@ -10,7 +10,7 @@
|
||||
|
||||
/gui/src/components/settings/ @Louka3000 @loucass003
|
||||
|
||||
/gui/src-tauri/ @ImUrX @TheButlah
|
||||
/gui/src-tauri/ @ImUrX @TheButlah
|
||||
|
||||
# Some server code~
|
||||
/server/ @ButterscotchV @Eirenliel @Louka3000
|
||||
@@ -20,7 +20,7 @@
|
||||
/server/src/main/java/dev/slimevr/posestreamer/ @ButterscotchV
|
||||
|
||||
/server/src/main/java/dev/slimevr/osc/ @Louka3000
|
||||
/server/src/main/java/dev/slimevr/vr/processor/ @Louka3000
|
||||
/server/src/main/java/dev/slimevr/tracking/processor/ @Louka3000
|
||||
/server/src/main/java/dev/slimevr/filtering/ @Louka3000
|
||||
|
||||
server/src/main/java/dev/slimevr/config/ @loucass003
|
||||
|
||||
@@ -15,13 +15,13 @@ import dev.slimevr.poserecorder.BVHRecorder;
|
||||
import dev.slimevr.protocol.ProtocolAPI;
|
||||
import dev.slimevr.serial.SerialHandler;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.DeviceManager;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
import dev.slimevr.vr.processor.skeleton.Skeleton;
|
||||
import dev.slimevr.vr.trackers.HMDTracker;
|
||||
import dev.slimevr.vr.trackers.ShareableTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.udp.TrackersUDPServer;
|
||||
import dev.slimevr.tracking.DeviceManager;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.HMDTracker;
|
||||
import dev.slimevr.tracking.trackers.ShareableTracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.udp.TrackersUDPServer;
|
||||
import dev.slimevr.websocketapi.WebSocketVRBridge;
|
||||
import io.eiren.util.OperatingSystem;
|
||||
import io.eiren.util.ann.ThreadSafe;
|
||||
@@ -42,7 +42,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class VRServer extends Thread {
|
||||
|
||||
public final HumanPoseProcessor humanPoseProcessor;
|
||||
public final HumanPoseManager humanPoseManager;
|
||||
public final HMDTracker hmdTracker;
|
||||
private final List<Tracker> trackers = new FastList<>();
|
||||
private final TrackersUDPServer trackersServer;
|
||||
@@ -85,8 +85,8 @@ public class VRServer extends Thread {
|
||||
hmdTracker.position.set(0, 1.8f, 0); // Set starting position for easier
|
||||
// debugging
|
||||
// TODO Multiple processors
|
||||
humanPoseProcessor = new HumanPoseProcessor(this);
|
||||
shareTrackers = humanPoseProcessor.getComputedTrackers();
|
||||
humanPoseManager = new HumanPoseManager(this);
|
||||
shareTrackers = humanPoseManager.getShareableTracker();
|
||||
|
||||
// Start server for SlimeVR trackers
|
||||
int trackerPort = configManager.getVrConfig().getServer().getTrackerPort();
|
||||
@@ -178,7 +178,7 @@ public class VRServer extends Thread {
|
||||
vrcOSCHandler = new VRCOSCHandler(
|
||||
this,
|
||||
hmdTracker,
|
||||
humanPoseProcessor,
|
||||
humanPoseManager,
|
||||
driverBridge,
|
||||
getConfigManager().getVrConfig().getVrcOSC(),
|
||||
shareTrackers
|
||||
@@ -234,15 +234,15 @@ public class VRServer extends Thread {
|
||||
@ThreadSafe
|
||||
public void trackerUpdated(Tracker tracker) {
|
||||
queueTask(() -> {
|
||||
humanPoseProcessor.trackerUpdated(tracker);
|
||||
humanPoseManager.trackerUpdated(tracker);
|
||||
this.getConfigManager().getVrConfig().writeTrackerConfig(tracker);
|
||||
this.getConfigManager().saveConfig();
|
||||
});
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public void addSkeletonUpdatedCallback(Consumer<Skeleton> consumer) {
|
||||
queueTask(() -> humanPoseProcessor.addSkeletonUpdatedCallback(consumer));
|
||||
public void addSkeletonUpdatedCallback(Consumer<HumanSkeleton> consumer) {
|
||||
queueTask(() -> humanPoseManager.addSkeletonUpdatedCallback(consumer));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,7 +267,7 @@ public class VRServer extends Thread {
|
||||
for (Tracker tracker : trackers) {
|
||||
tracker.tick();
|
||||
}
|
||||
humanPoseProcessor.update();
|
||||
humanPoseManager.update();
|
||||
for (Bridge bridge : bridges) {
|
||||
bridge.dataWrite();
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class VRServer extends Thread {
|
||||
|
||||
@VRServerThread
|
||||
private void trackerAdded(Tracker tracker) {
|
||||
humanPoseProcessor.trackerAdded(tracker);
|
||||
humanPoseManager.trackerAdded(tracker);
|
||||
}
|
||||
|
||||
@ThreadSecure
|
||||
@@ -302,15 +302,15 @@ public class VRServer extends Thread {
|
||||
}
|
||||
|
||||
public void resetTrackers() {
|
||||
queueTask(humanPoseProcessor::resetTrackers);
|
||||
queueTask(humanPoseManager::resetTrackersFull);
|
||||
}
|
||||
|
||||
public void resetTrackersYaw() {
|
||||
queueTask(humanPoseProcessor::resetTrackersYaw);
|
||||
queueTask(humanPoseManager::resetTrackersYaw);
|
||||
}
|
||||
|
||||
public void resetTrackersMounting() {
|
||||
queueTask(humanPoseProcessor::resetTrackersMounting);
|
||||
queueTask(humanPoseManager::resetTrackersMounting);
|
||||
}
|
||||
|
||||
public void scheduleResetTrackers(long delay) {
|
||||
@@ -330,32 +330,32 @@ public class VRServer extends Thread {
|
||||
|
||||
class resetTask extends TimerTask {
|
||||
public void run() {
|
||||
queueTask(humanPoseProcessor::resetTrackers);
|
||||
queueTask(humanPoseManager::resetTrackersFull);
|
||||
}
|
||||
}
|
||||
|
||||
class yawResetTask extends TimerTask {
|
||||
public void run() {
|
||||
queueTask(humanPoseProcessor::resetTrackersYaw);
|
||||
queueTask(humanPoseManager::resetTrackersYaw);
|
||||
}
|
||||
}
|
||||
|
||||
class resetMountingTask extends TimerTask {
|
||||
public void run() {
|
||||
queueTask(humanPoseProcessor::resetTrackersMounting);
|
||||
queueTask(humanPoseManager::resetTrackersMounting);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLegTweaksEnabled(boolean value) {
|
||||
queueTask(() -> humanPoseProcessor.setLegTweaksEnabled(value));
|
||||
queueTask(() -> humanPoseManager.setLegTweaksEnabled(value));
|
||||
}
|
||||
|
||||
public void setSkatingReductionEnabled(boolean value) {
|
||||
queueTask(() -> humanPoseProcessor.setSkatingCorrectionEnabled(value));
|
||||
queueTask(() -> humanPoseManager.setSkatingCorrectionEnabled(value));
|
||||
}
|
||||
|
||||
public void setFloorClipEnabled(boolean value) {
|
||||
queueTask(() -> humanPoseProcessor.setFloorClipEnabled(value));
|
||||
queueTask(() -> humanPoseManager.setFloorClipEnabled(value));
|
||||
}
|
||||
|
||||
public int getTrackersCount() {
|
||||
|
||||
@@ -6,13 +6,15 @@ import dev.slimevr.VRServer;
|
||||
import dev.slimevr.autobone.errors.*;
|
||||
import dev.slimevr.config.AutoBoneConfig;
|
||||
import dev.slimevr.poserecorder.PoseFrameIO;
|
||||
import dev.slimevr.poserecorder.PoseFrameSkeleton;
|
||||
import dev.slimevr.poserecorder.PoseFrameTracker;
|
||||
import dev.slimevr.poserecorder.PoseFrames;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import dev.slimevr.vr.processor.skeleton.*;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.processor.BoneType;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigManager;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
import io.eiren.util.StringUtils;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
@@ -116,19 +118,22 @@ public class AutoBone {
|
||||
return loadDir;
|
||||
}
|
||||
|
||||
public float computeBoneOffset(BoneType bone, SkeletonConfig skeletonConfig) {
|
||||
public float computeBoneOffset(
|
||||
BoneType bone,
|
||||
Function<SkeletonConfigOffsets, Float> getOffset
|
||||
) {
|
||||
return switch (bone) {
|
||||
case HEAD -> skeletonConfig.getOffset(SkeletonConfigOffsets.HEAD);
|
||||
case NECK -> skeletonConfig.getOffset(SkeletonConfigOffsets.NECK);
|
||||
case CHEST -> skeletonConfig.getOffset(SkeletonConfigOffsets.CHEST);
|
||||
case WAIST -> skeletonConfig.getOffset(SkeletonConfigOffsets.WAIST);
|
||||
case HIP -> skeletonConfig.getOffset(SkeletonConfigOffsets.HIP);
|
||||
case LEFT_HIP, RIGHT_HIP -> skeletonConfig.getOffset(SkeletonConfigOffsets.HIPS_WIDTH)
|
||||
case HEAD -> getOffset.apply(SkeletonConfigOffsets.HEAD);
|
||||
case NECK -> getOffset.apply(SkeletonConfigOffsets.NECK);
|
||||
case CHEST -> getOffset.apply(SkeletonConfigOffsets.CHEST);
|
||||
case WAIST -> getOffset.apply(SkeletonConfigOffsets.WAIST);
|
||||
case HIP -> getOffset.apply(SkeletonConfigOffsets.HIP);
|
||||
case LEFT_HIP, RIGHT_HIP -> getOffset.apply(SkeletonConfigOffsets.HIPS_WIDTH)
|
||||
/ 2f;
|
||||
case LEFT_UPPER_LEG, RIGHT_UPPER_LEG -> skeletonConfig
|
||||
.getOffset(SkeletonConfigOffsets.UPPER_LEG);
|
||||
case LEFT_LOWER_LEG, RIGHT_LOWER_LEG -> skeletonConfig
|
||||
.getOffset(SkeletonConfigOffsets.LOWER_LEG);
|
||||
case LEFT_UPPER_LEG, RIGHT_UPPER_LEG -> getOffset
|
||||
.apply(SkeletonConfigOffsets.UPPER_LEG);
|
||||
case LEFT_LOWER_LEG, RIGHT_LOWER_LEG -> getOffset
|
||||
.apply(SkeletonConfigOffsets.LOWER_LEG);
|
||||
default -> -1f;
|
||||
};
|
||||
|
||||
@@ -143,13 +148,13 @@ public class AutoBone {
|
||||
offsets.clear();
|
||||
|
||||
// Get current or default skeleton configs
|
||||
Skeleton skeleton = getSkeleton();
|
||||
SkeletonConfig skeletonConfig = skeleton != null
|
||||
? skeleton.getSkeletonConfig()
|
||||
: new SkeletonConfig(false);
|
||||
HumanPoseManager skeleton = getHumanPoseManager();
|
||||
Function<SkeletonConfigOffsets, Float> getOffset = skeleton != null
|
||||
? skeleton::getOffset
|
||||
: new SkeletonConfigManager(false)::getOffset;
|
||||
|
||||
for (BoneType bone : adjustOffsets) {
|
||||
float offset = computeBoneOffset(bone, skeletonConfig);
|
||||
float offset = computeBoneOffset(bone, getOffset);
|
||||
if (offset > 0f) {
|
||||
offsets.put(bone, offset);
|
||||
}
|
||||
@@ -157,7 +162,7 @@ public class AutoBone {
|
||||
}
|
||||
|
||||
public Vector3f getBoneDirection(
|
||||
HumanSkeleton skeleton,
|
||||
HumanPoseManager skeleton,
|
||||
BoneType node,
|
||||
boolean rightSide,
|
||||
Vector3f buffer
|
||||
@@ -184,8 +189,8 @@ public class AutoBone {
|
||||
}
|
||||
|
||||
public float getDotProductDiff(
|
||||
HumanSkeleton skeleton1,
|
||||
HumanSkeleton skeleton2,
|
||||
HumanPoseManager skeleton1,
|
||||
HumanPoseManager skeleton2,
|
||||
BoneType node,
|
||||
boolean rightSide,
|
||||
Vector3f offset
|
||||
@@ -203,20 +208,19 @@ public class AutoBone {
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple utility method to get the {@link Skeleton} from the
|
||||
* A simple utility method to get the {@link HumanSkeleton} from the
|
||||
* {@link VRServer}
|
||||
*
|
||||
* @return The {@link Skeleton} associated with the {@link VRServer}, or
|
||||
* null if there is none available
|
||||
* @see {@link VRServer}, {@link Skeleton}
|
||||
* @return The {@link HumanSkeleton} associated with the {@link VRServer},
|
||||
* or null if there is none available
|
||||
* @see {@link VRServer}, {@link HumanSkeleton}
|
||||
*/
|
||||
private Skeleton getSkeleton() {
|
||||
HumanPoseProcessor humanPoseProcessor = server != null ? server.humanPoseProcessor : null;
|
||||
return humanPoseProcessor != null ? humanPoseProcessor.getSkeleton() : null;
|
||||
private HumanPoseManager getHumanPoseManager() {
|
||||
return server != null ? server.humanPoseManager : null;
|
||||
}
|
||||
|
||||
public void applyAndSaveConfig() {
|
||||
if (!applyAndSaveConfig(getSkeleton())) {
|
||||
if (!applyAndSaveConfig(getHumanPoseManager())) {
|
||||
// Unable to apply to skeleton, save directly
|
||||
// saveConfigs();
|
||||
}
|
||||
@@ -305,28 +309,30 @@ public class AutoBone {
|
||||
return applyConfig(skeletonConfig, offsets);
|
||||
}
|
||||
|
||||
public boolean applyConfig(SkeletonConfig skeletonConfig, Map<BoneType, Float> offsets) {
|
||||
if (skeletonConfig == null) {
|
||||
public boolean applyConfig(
|
||||
HumanPoseManager humanPoseManager,
|
||||
Map<BoneType, Float> offsets
|
||||
) {
|
||||
if (humanPoseManager == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return applyConfig(skeletonConfig::setOffset, offsets);
|
||||
return applyConfig(humanPoseManager::setOffset, offsets);
|
||||
}
|
||||
|
||||
public boolean applyConfig(SkeletonConfig skeletonConfig) {
|
||||
return applyConfig(skeletonConfig, offsets);
|
||||
public boolean applyConfig(HumanPoseManager humanPoseManager) {
|
||||
return applyConfig(humanPoseManager, offsets);
|
||||
}
|
||||
|
||||
public boolean applyAndSaveConfig(Skeleton skeleton) {
|
||||
if (skeleton == null) {
|
||||
public boolean applyAndSaveConfig(HumanPoseManager humanPoseManager) {
|
||||
if (humanPoseManager == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkeletonConfig skeletonConfig = skeleton.getSkeletonConfig();
|
||||
if (!applyConfig(skeletonConfig))
|
||||
if (!applyConfig(humanPoseManager))
|
||||
return false;
|
||||
|
||||
skeletonConfig.save();
|
||||
humanPoseManager.saveConfig();
|
||||
server.getConfigManager().saveConfig();
|
||||
|
||||
LogManager.info("[AutoBone] Configured skeleton bone lengths");
|
||||
@@ -362,9 +368,9 @@ public class AutoBone {
|
||||
|
||||
public float sumSelectConfigs(
|
||||
List<SkeletonConfigOffsets> selection,
|
||||
SkeletonConfig config
|
||||
HumanPoseManager humanPoseManager
|
||||
) {
|
||||
return sumSelectConfigs(selection, config::getOffset);
|
||||
return sumSelectConfigs(selection, humanPoseManager::getOffset);
|
||||
}
|
||||
|
||||
public float getLengthSum(Map<BoneType, Float> configs) {
|
||||
@@ -396,11 +402,11 @@ public class AutoBone {
|
||||
public float getTargetHeight(PoseFrames frames) {
|
||||
float targetHeight;
|
||||
// Get the current skeleton from the server
|
||||
Skeleton skeleton = getSkeleton();
|
||||
if (skeleton != null) {
|
||||
HumanPoseManager humanPoseManager = getHumanPoseManager();
|
||||
if (humanPoseManager != null) {
|
||||
// If there is a skeleton available, calculate the target height
|
||||
// from its configs
|
||||
targetHeight = sumSelectConfigs(legacyHeightConfigs, skeleton.getSkeletonConfig());
|
||||
targetHeight = sumSelectConfigs(legacyHeightConfigs, humanPoseManager);
|
||||
LogManager
|
||||
.warning(
|
||||
"[AutoBone] Target height loaded from skeleton (Make sure you reset before running!): "
|
||||
@@ -448,17 +454,20 @@ public class AutoBone {
|
||||
) throws AutoBoneException {
|
||||
final int frameCount = frames.getMaxFrameCount();
|
||||
|
||||
List<PoseFrameTracker> trackers = frames.getTrackers();
|
||||
reloadConfigValues(trackers); // Reload configs and detect chest tracker
|
||||
// from the first frame
|
||||
final PoseFrames frames1 = new PoseFrames(frames);
|
||||
final PoseFrames frames2 = new PoseFrames(frames);
|
||||
|
||||
final PoseFrameSkeleton skeleton1 = new PoseFrameSkeleton(
|
||||
trackers,
|
||||
null
|
||||
List<PoseFrameTracker> trackers1 = frames1.getTrackers();
|
||||
List<PoseFrameTracker> trackers2 = frames2.getTrackers();
|
||||
|
||||
// Reload configs and detect chest tracker from the first frame
|
||||
reloadConfigValues(trackers1);
|
||||
|
||||
final HumanPoseManager skeleton1 = new HumanPoseManager(
|
||||
trackers1
|
||||
);
|
||||
final PoseFrameSkeleton skeleton2 = new PoseFrameSkeleton(
|
||||
trackers,
|
||||
null
|
||||
final HumanPoseManager skeleton2 = new HumanPoseManager(
|
||||
trackers2
|
||||
);
|
||||
|
||||
EnumMap<BoneType, Float> intermediateOffsets = new EnumMap<>(
|
||||
@@ -525,8 +534,8 @@ public class AutoBone {
|
||||
) {
|
||||
int frameCursor2 = frameCursor + cursorOffset;
|
||||
|
||||
applyConfig(skeleton1.skeletonConfig);
|
||||
skeleton2.skeletonConfig.setOffsets(skeleton1.skeletonConfig);
|
||||
applyConfig(skeleton1);
|
||||
applyConfig(skeleton2);
|
||||
|
||||
if (config.randomizeFrameOrder) {
|
||||
trainingStep
|
||||
@@ -538,11 +547,11 @@ public class AutoBone {
|
||||
trainingStep.setCursors(frameCursor, frameCursor2);
|
||||
}
|
||||
|
||||
skeleton1.setCursor(trainingStep.getCursor1());
|
||||
skeleton2.setCursor(trainingStep.getCursor2());
|
||||
frames1.setCursors(trainingStep.getCursor1());
|
||||
frames2.setCursors(trainingStep.getCursor2());
|
||||
|
||||
skeleton1.updatePose();
|
||||
skeleton2.updatePose();
|
||||
skeleton1.update();
|
||||
skeleton2.update();
|
||||
|
||||
float totalLength = getLengthSum(offsets);
|
||||
float curHeight = sumSelectConfigs(heightOffsets, offsets);
|
||||
@@ -558,7 +567,7 @@ public class AutoBone {
|
||||
.warning(
|
||||
"[AutoBone] Error value is invalid, resetting variables to recover"
|
||||
);
|
||||
reloadConfigValues(trackers);
|
||||
reloadConfigValues(trackers1);
|
||||
|
||||
// Reset error sum values
|
||||
errorStats.reset();
|
||||
@@ -632,12 +641,12 @@ public class AutoBone {
|
||||
|
||||
// Apply new offset length
|
||||
intermediateOffsets.put(entry.getKey(), newLength);
|
||||
applyConfig(skeleton1.skeletonConfig, intermediateOffsets);
|
||||
skeleton2.skeletonConfig.setOffsets(skeleton1.skeletonConfig);
|
||||
applyConfig(skeleton1, intermediateOffsets);
|
||||
applyConfig(skeleton2, intermediateOffsets);
|
||||
|
||||
// Update the skeleton poses for the new offset length
|
||||
skeleton1.updatePose();
|
||||
skeleton2.updatePose();
|
||||
skeleton1.update();
|
||||
skeleton2.update();
|
||||
|
||||
float newHeight = isHeightVar ? curHeight + curAdjustVal : curHeight;
|
||||
trainingStep.setCurrentHeight(newHeight);
|
||||
@@ -651,8 +660,8 @@ public class AutoBone {
|
||||
// Reset the length to minimize bias in other variables,
|
||||
// it's applied later
|
||||
intermediateOffsets.put(entry.getKey(), originalLength);
|
||||
applyConfig(skeleton1.skeletonConfig, intermediateOffsets);
|
||||
skeleton2.skeletonConfig.setOffsets(skeleton1.skeletonConfig);
|
||||
applyConfig(skeleton1, intermediateOffsets);
|
||||
applyConfig(skeleton2, intermediateOffsets);
|
||||
}
|
||||
|
||||
if (config.scaleEachStep) {
|
||||
|
||||
@@ -4,8 +4,8 @@ import dev.slimevr.VRServer;
|
||||
import dev.slimevr.autobone.AutoBone.AutoBoneResults;
|
||||
import dev.slimevr.autobone.errors.AutoBoneException;
|
||||
import dev.slimevr.poserecorder.*;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigManager;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
import io.eiren.util.StringUtils;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -314,7 +314,7 @@ public class AutoBoneHandler {
|
||||
announceProcessStatus(AutoBoneProcessType.PROCESS, "Processing recording(s)...");
|
||||
LogManager.info("[AutoBone] Processing frames...");
|
||||
StatsCalculator errorStats = new StatsCalculator();
|
||||
SkeletonConfig skeletonConfigBuffer = new SkeletonConfig(false);
|
||||
SkeletonConfigManager skeletonConfigManagerBuffer = new SkeletonConfigManager(false);
|
||||
for (Pair<String, PoseFrames> recording : frameRecordings) {
|
||||
LogManager
|
||||
.info("[AutoBone] Processing frames from \"" + recording.getKey() + "\"...");
|
||||
@@ -355,23 +355,24 @@ public class AutoBoneHandler {
|
||||
LogManager.info("[AutoBone] Done processing!");
|
||||
|
||||
// #region Stats/Values
|
||||
skeletonConfigBuffer.setOffsets(autoBoneResults.configValues);
|
||||
skeletonConfigManagerBuffer.setOffsets(autoBoneResults.configValues);
|
||||
|
||||
float neckLength = skeletonConfigBuffer.getOffset(SkeletonConfigOffsets.NECK);
|
||||
float chestLength = skeletonConfigBuffer
|
||||
float neckLength = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.NECK);
|
||||
float chestLength = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.CHEST);
|
||||
float waistLength = skeletonConfigBuffer
|
||||
float waistLength = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.WAIST);
|
||||
float hipLength = skeletonConfigBuffer
|
||||
float hipLength = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.HIP);
|
||||
float torsoLength = chestLength + waistLength + hipLength;
|
||||
float hipWidth = skeletonConfigBuffer
|
||||
float hipWidth = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.HIPS_WIDTH);
|
||||
float legLength = skeletonConfigBuffer
|
||||
float legLength = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.UPPER_LEG)
|
||||
+ skeletonConfigBuffer
|
||||
+ skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.LOWER_LEG);
|
||||
float lowerLegLength = skeletonConfigBuffer
|
||||
float lowerLegLength = skeletonConfigManagerBuffer
|
||||
.getOffset(SkeletonConfigOffsets.LOWER_LEG);
|
||||
|
||||
float neckTorso = neckLength / torsoLength;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.slimevr.autobone;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import dev.slimevr.autobone.AutoBone.Epoch;
|
||||
import dev.slimevr.poserecorder.PoseFrames;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
|
||||
public interface AutoBoneListener {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.slimevr.autobone;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import dev.slimevr.poserecorder.PoseFrameSkeleton;
|
||||
import dev.slimevr.poserecorder.PoseFrames;
|
||||
import dev.slimevr.vr.processor.skeleton.BoneType;
|
||||
import dev.slimevr.tracking.processor.BoneType;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class AutoBoneTrainingStep {
|
||||
@@ -14,8 +14,8 @@ public class AutoBoneTrainingStep {
|
||||
private float currentHeight;
|
||||
private final float targetHeight;
|
||||
|
||||
private final PoseFrameSkeleton skeleton1;
|
||||
private final PoseFrameSkeleton skeleton2;
|
||||
private final HumanPoseManager humanPoseManager1;
|
||||
private final HumanPoseManager humanPoseManager2;
|
||||
|
||||
private final PoseFrames trainingFrames;
|
||||
|
||||
@@ -25,30 +25,30 @@ public class AutoBoneTrainingStep {
|
||||
int cursor1,
|
||||
int cursor2,
|
||||
float targetHeight,
|
||||
PoseFrameSkeleton skeleton1,
|
||||
PoseFrameSkeleton skeleton2,
|
||||
HumanPoseManager humanPoseManager1,
|
||||
HumanPoseManager humanPoseManager2,
|
||||
PoseFrames trainingFrames,
|
||||
Map<BoneType, Float> intermediateOffsets
|
||||
) {
|
||||
this.cursor1 = cursor1;
|
||||
this.cursor2 = cursor2;
|
||||
this.targetHeight = targetHeight;
|
||||
this.skeleton1 = skeleton1;
|
||||
this.skeleton2 = skeleton2;
|
||||
this.humanPoseManager1 = humanPoseManager1;
|
||||
this.humanPoseManager2 = humanPoseManager2;
|
||||
this.trainingFrames = trainingFrames;
|
||||
this.intermediateOffsets = intermediateOffsets;
|
||||
}
|
||||
|
||||
public AutoBoneTrainingStep(
|
||||
float targetHeight,
|
||||
PoseFrameSkeleton skeleton1,
|
||||
PoseFrameSkeleton skeleton2,
|
||||
HumanPoseManager humanPoseManager1,
|
||||
HumanPoseManager humanPoseManager2,
|
||||
PoseFrames trainingFrames,
|
||||
Map<BoneType, Float> intermediateOffsets
|
||||
) {
|
||||
this.targetHeight = targetHeight;
|
||||
this.skeleton1 = skeleton1;
|
||||
this.skeleton2 = skeleton2;
|
||||
this.humanPoseManager1 = humanPoseManager1;
|
||||
this.humanPoseManager2 = humanPoseManager2;
|
||||
this.trainingFrames = trainingFrames;
|
||||
this.intermediateOffsets = intermediateOffsets;
|
||||
}
|
||||
@@ -86,12 +86,12 @@ public class AutoBoneTrainingStep {
|
||||
return targetHeight;
|
||||
}
|
||||
|
||||
public PoseFrameSkeleton getSkeleton1() {
|
||||
return skeleton1;
|
||||
public HumanPoseManager getHumanPoseManager1() {
|
||||
return humanPoseManager1;
|
||||
}
|
||||
|
||||
public PoseFrameSkeleton getSkeleton2() {
|
||||
return skeleton2;
|
||||
public HumanPoseManager getHumanPoseManager2() {
|
||||
return humanPoseManager2;
|
||||
}
|
||||
|
||||
public PoseFrames getTrainingFrames() {
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.jme3.math.FastMath;
|
||||
import dev.slimevr.autobone.AutoBoneTrainingStep;
|
||||
import dev.slimevr.autobone.errors.proportions.ProportionLimiter;
|
||||
import dev.slimevr.autobone.errors.proportions.RangeProportionLimiter;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
|
||||
|
||||
// The distance from average human proportions
|
||||
@@ -120,17 +120,17 @@ public class BodyProportionError implements IAutoBoneError {
|
||||
@Override
|
||||
public float getStepError(AutoBoneTrainingStep trainingStep) throws AutoBoneException {
|
||||
return getBodyProportionError(
|
||||
trainingStep.getSkeleton1().skeletonConfig,
|
||||
trainingStep.getHumanPoseManager1(),
|
||||
trainingStep.getCurrentHeight()
|
||||
);
|
||||
}
|
||||
|
||||
public float getBodyProportionError(SkeletonConfig config, float height) {
|
||||
public float getBodyProportionError(HumanPoseManager humanPoseManager, float height) {
|
||||
float fullHeight = height / eyeHeightToHeightRatio;
|
||||
|
||||
float sum = 0f;
|
||||
for (ProportionLimiter limiter : proportionLimits) {
|
||||
sum += FastMath.abs(limiter.getProportionError(config, fullHeight));
|
||||
sum += FastMath.abs(limiter.getProportionError(humanPoseManager, fullHeight));
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
||||
@@ -3,16 +3,19 @@ package dev.slimevr.autobone.errors;
|
||||
import com.jme3.math.FastMath;
|
||||
|
||||
import dev.slimevr.autobone.AutoBoneTrainingStep;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.trackers.ComputedTracker;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.ComputedTracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
|
||||
|
||||
// The offset between the height both feet at one instant and over time
|
||||
public class FootHeightOffsetError implements IAutoBoneError {
|
||||
@Override
|
||||
public float getStepError(AutoBoneTrainingStep trainingStep) throws AutoBoneException {
|
||||
return getSlideError(trainingStep.getSkeleton1(), trainingStep.getSkeleton2());
|
||||
return getSlideError(
|
||||
trainingStep.getHumanPoseManager1().getSkeleton(),
|
||||
trainingStep.getHumanPoseManager2().getSkeleton()
|
||||
);
|
||||
}
|
||||
|
||||
public static float getSlideError(HumanSkeleton skeleton1, HumanSkeleton skeleton2) {
|
||||
|
||||
@@ -4,16 +4,19 @@ import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
import dev.slimevr.autobone.AutoBoneTrainingStep;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.trackers.ComputedTracker;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.ComputedTracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
|
||||
|
||||
// The change in distance between both of the ankles over time
|
||||
public class OffsetSlideError implements IAutoBoneError {
|
||||
@Override
|
||||
public float getStepError(AutoBoneTrainingStep trainingStep) throws AutoBoneException {
|
||||
return getSlideError(trainingStep.getSkeleton1(), trainingStep.getSkeleton2());
|
||||
return getSlideError(
|
||||
trainingStep.getHumanPoseManager1().getSkeleton(),
|
||||
trainingStep.getHumanPoseManager2().getSkeleton()
|
||||
);
|
||||
}
|
||||
|
||||
public static float getSlideError(HumanSkeleton skeleton1, HumanSkeleton skeleton2) {
|
||||
|
||||
@@ -8,8 +8,8 @@ import dev.slimevr.autobone.AutoBoneTrainingStep;
|
||||
import dev.slimevr.poserecorder.PoseFrameTracker;
|
||||
import dev.slimevr.poserecorder.TrackerFrame;
|
||||
import dev.slimevr.poserecorder.TrackerFrameData;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.trackers.ComputedTracker;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.ComputedTracker;
|
||||
|
||||
|
||||
// The distance of any points to the corresponding absolute position
|
||||
@@ -20,12 +20,12 @@ public class PositionError implements IAutoBoneError {
|
||||
return (getPositionError(
|
||||
trackers,
|
||||
trainingStep.getCursor1(),
|
||||
trainingStep.getSkeleton1()
|
||||
trainingStep.getHumanPoseManager1().getSkeleton()
|
||||
)
|
||||
+ getPositionError(
|
||||
trackers,
|
||||
trainingStep.getCursor2(),
|
||||
trainingStep.getSkeleton2()
|
||||
trainingStep.getHumanPoseManager2().getSkeleton()
|
||||
))
|
||||
/ 2f;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import dev.slimevr.autobone.AutoBoneTrainingStep;
|
||||
import dev.slimevr.poserecorder.PoseFrameTracker;
|
||||
import dev.slimevr.poserecorder.TrackerFrame;
|
||||
import dev.slimevr.poserecorder.TrackerFrameData;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.trackers.ComputedTracker;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.ComputedTracker;
|
||||
|
||||
|
||||
// The difference between offset of absolute position and the corresponding point over time
|
||||
@@ -21,8 +21,8 @@ public class PositionOffsetError implements IAutoBoneError {
|
||||
trackers,
|
||||
trainingStep.getCursor1(),
|
||||
trainingStep.getCursor2(),
|
||||
trainingStep.getSkeleton1(),
|
||||
trainingStep.getSkeleton2()
|
||||
trainingStep.getHumanPoseManager1().getSkeleton(),
|
||||
trainingStep.getHumanPoseManager2().getSkeleton()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package dev.slimevr.autobone.errors;
|
||||
|
||||
import dev.slimevr.autobone.AutoBoneTrainingStep;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.trackers.ComputedTracker;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.ComputedTracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
|
||||
|
||||
// The change in position of the ankle over time
|
||||
public class SlideError implements IAutoBoneError {
|
||||
@Override
|
||||
public float getStepError(AutoBoneTrainingStep trainingStep) throws AutoBoneException {
|
||||
return getSlideError(trainingStep.getSkeleton1(), trainingStep.getSkeleton2());
|
||||
return getSlideError(
|
||||
trainingStep.getHumanPoseManager1().getSkeleton(),
|
||||
trainingStep.getHumanPoseManager2().getSkeleton()
|
||||
);
|
||||
}
|
||||
|
||||
public static float getSlideError(HumanSkeleton skeleton1, HumanSkeleton skeleton2) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.autobone.errors.proportions;
|
||||
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.function.Function;
|
||||
public class HardProportionLimiter implements ProportionLimiter {
|
||||
|
||||
protected final float targetRatio;
|
||||
protected final Function<SkeletonConfig, Float> boneLengthFunction;
|
||||
protected final Function<HumanPoseManager, Float> boneLengthFunction;
|
||||
|
||||
/**
|
||||
* @param targetRatio The bone to height ratio to target
|
||||
@@ -17,15 +17,15 @@ public class HardProportionLimiter implements ProportionLimiter {
|
||||
*/
|
||||
public HardProportionLimiter(
|
||||
float targetRatio,
|
||||
Function<SkeletonConfig, Float> boneLengthFunction
|
||||
Function<HumanPoseManager, Float> boneLengthFunction
|
||||
) {
|
||||
this.targetRatio = targetRatio;
|
||||
this.boneLengthFunction = boneLengthFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProportionError(SkeletonConfig config, float height) {
|
||||
float boneLength = boneLengthFunction.apply(config);
|
||||
public float getProportionError(HumanPoseManager humanPoseManager, float height) {
|
||||
float boneLength = boneLengthFunction.apply(humanPoseManager);
|
||||
return targetRatio - (boneLength / height);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.slimevr.autobone.errors.proportions;
|
||||
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
|
||||
|
||||
public interface ProportionLimiter {
|
||||
public float getProportionError(SkeletonConfig config, float height);
|
||||
public float getProportionError(HumanPoseManager humanPoseManager, float height);
|
||||
|
||||
public float getTargetRatio();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.autobone.errors.proportions;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RangeProportionLimiter extends HardProportionLimiter {
|
||||
*/
|
||||
public RangeProportionLimiter(
|
||||
float targetRatio,
|
||||
Function<SkeletonConfig, Float> boneLengthFunction,
|
||||
Function<HumanPoseManager, Float> boneLengthFunction,
|
||||
float range
|
||||
) {
|
||||
super(targetRatio, boneLengthFunction);
|
||||
@@ -41,7 +41,7 @@ public class RangeProportionLimiter extends HardProportionLimiter {
|
||||
*/
|
||||
public RangeProportionLimiter(
|
||||
float targetRatio,
|
||||
Function<SkeletonConfig, Float> boneLengthFunction,
|
||||
Function<HumanPoseManager, Float> boneLengthFunction,
|
||||
float positiveRange,
|
||||
float negativeRange
|
||||
) {
|
||||
@@ -58,7 +58,7 @@ public class RangeProportionLimiter extends HardProportionLimiter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProportionError(SkeletonConfig config, float height) {
|
||||
public float getProportionError(HumanPoseManager config, float height) {
|
||||
float boneLength = boneLengthFunction.apply(config);
|
||||
float ratioOffset = targetRatio - (boneLength / height);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.bridge;
|
||||
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.trackers.ShareableTracker;
|
||||
import dev.slimevr.tracking.trackers.ShareableTracker;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.bridge;
|
||||
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.trackers.ShareableTracker;
|
||||
import dev.slimevr.tracking.trackers.ShareableTracker;
|
||||
|
||||
|
||||
public class OpenVRNativeBridge implements Bridge {
|
||||
|
||||
@@ -6,7 +6,7 @@ import dev.slimevr.Main;
|
||||
import dev.slimevr.bridge.ProtobufMessages.TrackerStatus;
|
||||
import dev.slimevr.bridge.ProtobufMessages.*;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import io.eiren.util.ann.Synchronize;
|
||||
import io.eiren.util.ann.ThreadSafe;
|
||||
import io.eiren.util.collections.FastList;
|
||||
@@ -193,7 +193,8 @@ public abstract class ProtobufBridge<T extends VRTracker> implements Bridge {
|
||||
if (tracker != null) {
|
||||
tracker
|
||||
.setStatus(
|
||||
dev.slimevr.vr.trackers.TrackerStatus.getById(trackerStatus.getStatusValue())
|
||||
dev.slimevr.tracking.trackers.TrackerStatus
|
||||
.getById(trackerStatus.getStatusValue())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -224,11 +225,11 @@ public abstract class ProtobufBridge<T extends VRTracker> implements Bridge {
|
||||
for (Entry<Integer, T> integerTEntry : remoteTrackersByTrackerId.entrySet()) {
|
||||
integerTEntry
|
||||
.getValue()
|
||||
.setStatus(dev.slimevr.vr.trackers.TrackerStatus.DISCONNECTED);
|
||||
.setStatus(dev.slimevr.tracking.trackers.TrackerStatus.DISCONNECTED);
|
||||
}
|
||||
}
|
||||
if (hmdTracker != null) {
|
||||
hmd.setStatus(dev.slimevr.vr.trackers.TrackerStatus.DISCONNECTED);
|
||||
hmd.setStatus(dev.slimevr.tracking.trackers.TrackerStatus.DISCONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.bridge;
|
||||
|
||||
import dev.slimevr.vr.trackers.ShareableTracker;
|
||||
import dev.slimevr.tracking.trackers.ShareableTracker;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
||||
import dev.slimevr.config.serializers.BooleanMapDeserializer;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.slimevr.config;
|
||||
|
||||
import dev.slimevr.Main;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.IMUTracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
|
||||
|
||||
public class DriftCompensationConfig {
|
||||
|
||||
@@ -2,8 +2,8 @@ package dev.slimevr.config;
|
||||
|
||||
import dev.slimevr.Main;
|
||||
import dev.slimevr.filtering.TrackerFilters;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerWithFiltering;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerWithFiltering;
|
||||
|
||||
|
||||
public class FiltersConfig {
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
||||
import dev.slimevr.config.serializers.BooleanMapDeserializer;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.jme3.math.Quaternion;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.IMUTracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
|
||||
|
||||
public class TrackerConfig {
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
||||
import com.github.jonpeterson.jackson.module.versioning.JsonVersionedModel;
|
||||
import dev.slimevr.config.serializers.BridgeConfigMapDeserializer;
|
||||
import dev.slimevr.config.serializers.TrackerConfigMapDeserializer;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -10,11 +10,11 @@ import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.config.OSCConfig;
|
||||
import dev.slimevr.platform.SteamVRBridge;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
import dev.slimevr.vr.trackers.HMDTracker;
|
||||
import dev.slimevr.vr.trackers.ShareableTracker;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.trackers.HMDTracker;
|
||||
import dev.slimevr.tracking.trackers.ShareableTracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class VRCOSCHandler implements OSCHandler {
|
||||
private final VRServer server;
|
||||
private final HMDTracker hmd;
|
||||
private final SteamVRBridge steamvrBridge;
|
||||
private final HumanPoseProcessor humanPoseProcessor;
|
||||
private final HumanPoseManager humanPoseManager;
|
||||
private final List<? extends ShareableTracker> shareableTrackers;
|
||||
private final FastList<Float> oscArgs = new FastList<>(3);
|
||||
private final Vector3f vec = new Vector3f();
|
||||
@@ -52,14 +52,14 @@ public class VRCOSCHandler implements OSCHandler {
|
||||
public VRCOSCHandler(
|
||||
VRServer server,
|
||||
HMDTracker hmd,
|
||||
HumanPoseProcessor humanPoseProcessor,
|
||||
HumanPoseManager humanPoseManager,
|
||||
SteamVRBridge steamvrBridge,
|
||||
OSCConfig oscConfig,
|
||||
List<? extends ShareableTracker> shareableTrackers
|
||||
) {
|
||||
this.server = server;
|
||||
this.hmd = hmd;
|
||||
this.humanPoseProcessor = humanPoseProcessor;
|
||||
this.humanPoseManager = humanPoseManager;
|
||||
this.steamvrBridge = steamvrBridge;
|
||||
this.config = oscConfig;
|
||||
this.shareableTrackers = shareableTrackers;
|
||||
@@ -185,7 +185,7 @@ public class VRCOSCHandler implements OSCHandler {
|
||||
(float) event
|
||||
.getMessage()
|
||||
.getArguments()
|
||||
.get(0) * humanPoseProcessor.getUserHeightFromConfig(),
|
||||
.get(0) * humanPoseManager.getUserHeightFromConfig(),
|
||||
0f
|
||||
);
|
||||
hmd.rotation.set(Quaternion.IDENTITY);
|
||||
|
||||
@@ -6,8 +6,8 @@ import dev.slimevr.bridge.ProtobufBridge;
|
||||
import dev.slimevr.bridge.ProtobufMessages;
|
||||
import dev.slimevr.config.BridgeConfig;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import dev.slimevr.VRServer;
|
||||
import dev.slimevr.bridge.BridgeThread;
|
||||
import dev.slimevr.bridge.ProtobufMessages;
|
||||
import dev.slimevr.platform.SteamVRBridge;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -11,7 +11,7 @@ import dev.slimevr.bridge.BridgeThread;
|
||||
import dev.slimevr.bridge.PipeState;
|
||||
import dev.slimevr.bridge.ProtobufMessages.ProtobufMessage;
|
||||
import dev.slimevr.platform.SteamVRBridge;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.sun.jna.ptr.IntByReference;
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.bridge.Bridge;
|
||||
import dev.slimevr.bridge.PipeState;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.slimevr.poserecorder;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.vr.trackers.TrackerPosition;
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package dev.slimevr.poserecorder;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.vr.processor.ComputedHumanPoseTracker;
|
||||
import dev.slimevr.vr.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigOffsets;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class PoseFrameSkeleton extends HumanSkeleton {
|
||||
|
||||
private int frameCursor = 0;
|
||||
|
||||
protected PoseFrameSkeleton(List<? extends ComputedHumanPoseTracker> computedTrackers) {
|
||||
super(computedTrackers);
|
||||
}
|
||||
|
||||
public PoseFrameSkeleton(
|
||||
VRServer server,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers
|
||||
) {
|
||||
super(server, computedTrackers);
|
||||
}
|
||||
|
||||
public PoseFrameSkeleton(
|
||||
List<? extends Tracker> trackers,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers
|
||||
) {
|
||||
super(trackers, computedTrackers);
|
||||
}
|
||||
|
||||
public PoseFrameSkeleton(
|
||||
List<? extends Tracker> trackers,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers,
|
||||
Map<SkeletonConfigOffsets, Float> configs,
|
||||
Map<SkeletonConfigOffsets, Float> altConfigs
|
||||
) {
|
||||
super(trackers, computedTrackers, configs, altConfigs);
|
||||
}
|
||||
|
||||
public PoseFrameSkeleton(
|
||||
List<? extends Tracker> trackers,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers,
|
||||
Map<SkeletonConfigOffsets, Float> configs
|
||||
) {
|
||||
super(trackers, computedTrackers, configs);
|
||||
}
|
||||
|
||||
private int limitCursor() {
|
||||
if (frameCursor < 0) {
|
||||
frameCursor = 0;
|
||||
}
|
||||
|
||||
return frameCursor;
|
||||
}
|
||||
|
||||
public int setCursor(int index) {
|
||||
frameCursor = index;
|
||||
return limitCursor();
|
||||
}
|
||||
|
||||
public int incrementCursor(int increment) {
|
||||
frameCursor += increment;
|
||||
return limitCursor();
|
||||
}
|
||||
|
||||
public int incrementCursor() {
|
||||
return incrementCursor(1);
|
||||
}
|
||||
|
||||
public int getCursor() {
|
||||
return frameCursor;
|
||||
}
|
||||
|
||||
// Get tracker for specific frame
|
||||
@Override
|
||||
protected Tracker trackerPreUpdate(Tracker tracker) {
|
||||
if (tracker instanceof PoseFrameTracker) {
|
||||
// Return frame if available, otherwise return the original tracker
|
||||
TrackerFrame frame = ((PoseFrameTracker) tracker).safeGetFrame(frameCursor);
|
||||
return frame == null ? tracker : frame;
|
||||
}
|
||||
return tracker;
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@ package dev.slimevr.poserecorder;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.config.TrackerConfig;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerPosition;
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition;
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -45,6 +45,10 @@ public class PoseFrameTracker implements Tracker, Iterable<TrackerFrame> {
|
||||
this(parent.getName());
|
||||
}
|
||||
|
||||
public PoseFrameTracker(PoseFrameTracker parent) {
|
||||
this(parent.name, parent.frames);
|
||||
}
|
||||
|
||||
private int limitCursor() {
|
||||
if (frameCursor < 0 || frames.isEmpty()) {
|
||||
frameCursor = 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.poserecorder;
|
||||
|
||||
import dev.slimevr.vr.trackers.TrackerPosition;
|
||||
import dev.slimevr.vr.trackers.TrackerUtils;
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition;
|
||||
import dev.slimevr.tracking.trackers.TrackerUtils;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -23,6 +23,22 @@ public final class PoseFrames implements Iterable<TrackerFrame[]> {
|
||||
this.trackers = trackers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link PoseFrames} object with the provided {@link PoseFrames}
|
||||
* object, wrapping the list of {@link PoseFrameTracker}s with new
|
||||
* {@link PoseFrameTracker} objects as the internal {@link PoseFrameTracker}
|
||||
* list
|
||||
*
|
||||
* @see {@link FastList}, {@link PoseFrameTracker}
|
||||
*/
|
||||
public PoseFrames(PoseFrames parent) {
|
||||
trackers = new FastList<>(parent.trackers.size());
|
||||
for (PoseFrameTracker tracker : parent.trackers) {
|
||||
// Wrap all the trackers so cursors can be per-instance
|
||||
trackers.add(tracker != null ? new PoseFrameTracker(tracker) : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link PoseFrames} object with the specified initial tracker
|
||||
* capacity
|
||||
@@ -113,6 +129,20 @@ public final class PoseFrames implements Iterable<TrackerFrame[]> {
|
||||
return trackers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor index for all the {@link PoseFrameTracker} objects from
|
||||
* the internal {@link PoseFrameTracker} list
|
||||
*
|
||||
* @see {@link List#remove(Object)}, {@link PoseFrameTracker}
|
||||
*/
|
||||
public void setCursors(int index) {
|
||||
for (PoseFrameTracker tracker : trackers) {
|
||||
if (tracker != null) {
|
||||
tracker.setCursor(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #region Data Utilities
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package dev.slimevr.poserecorder;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.config.TrackerConfig;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerPosition;
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition;
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus;
|
||||
|
||||
|
||||
public final class TrackerFrame implements Tracker {
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Transform;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import dev.slimevr.vr.processor.skeleton.Skeleton;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.*;
|
||||
@@ -23,7 +23,7 @@ public class BVHFileStream extends PoseDataStream {
|
||||
private float[] angleBuf = new float[3];
|
||||
private Quaternion rotBuf = new Quaternion();
|
||||
|
||||
private Skeleton wrappedSkeleton;
|
||||
private HumanSkeleton wrappedSkeleton;
|
||||
private TransformNodeWrapper rootNode;
|
||||
|
||||
public BVHFileStream(OutputStream outputStream) {
|
||||
@@ -71,7 +71,7 @@ public class BVHFileStream extends PoseDataStream {
|
||||
return bufferCount > 0 ? frameString + StringUtils.repeat(' ', bufferCount) : frameString;
|
||||
}
|
||||
|
||||
private TransformNodeWrapper wrapSkeletonIfNew(Skeleton skeleton) {
|
||||
private TransformNodeWrapper wrapSkeletonIfNew(HumanSkeleton skeleton) {
|
||||
TransformNodeWrapper wrapper = rootNode;
|
||||
|
||||
// If the wrapped skeleton is missing or the skeleton is updated
|
||||
@@ -82,7 +82,7 @@ public class BVHFileStream extends PoseDataStream {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private TransformNodeWrapper wrapSkeleton(Skeleton skeleton) {
|
||||
private TransformNodeWrapper wrapSkeleton(HumanSkeleton skeleton) {
|
||||
TransformNodeWrapper wrapper = wrapSkeletonNodes(skeleton.getRootNode());
|
||||
|
||||
wrappedSkeleton = skeleton;
|
||||
@@ -179,7 +179,7 @@ public class BVHFileStream extends PoseDataStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeHeader(Skeleton skeleton, PoseStreamer streamer) throws IOException {
|
||||
public void writeHeader(HumanSkeleton skeleton, PoseStreamer streamer) throws IOException {
|
||||
if (skeleton == null) {
|
||||
throw new NullPointerException("skeleton must not be null");
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public class BVHFileStream extends PoseDataStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFrame(Skeleton skeleton) throws IOException {
|
||||
public void writeFrame(HumanSkeleton skeleton) throws IOException {
|
||||
if (skeleton == null) {
|
||||
throw new NullPointerException("skeleton must not be null");
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public class BVHFileStream extends PoseDataStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFooter(Skeleton skeleton) throws IOException {
|
||||
public void writeFooter(HumanSkeleton skeleton) throws IOException {
|
||||
// Write the final frame count for files
|
||||
if (outputStream instanceof FileOutputStream fileOutputStream) {
|
||||
// Flush before anything else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.posestreamer;
|
||||
|
||||
import dev.slimevr.vr.processor.skeleton.Skeleton;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -22,12 +22,12 @@ public abstract class PoseDataStream implements AutoCloseable {
|
||||
this(new FileOutputStream(file));
|
||||
}
|
||||
|
||||
public void writeHeader(Skeleton skeleton, PoseStreamer streamer) throws IOException {
|
||||
public void writeHeader(HumanSkeleton skeleton, PoseStreamer streamer) throws IOException {
|
||||
}
|
||||
|
||||
abstract void writeFrame(Skeleton skeleton) throws IOException;
|
||||
abstract void writeFrame(HumanSkeleton skeleton) throws IOException;
|
||||
|
||||
public void writeFooter(Skeleton skeleton) throws IOException {
|
||||
public void writeFooter(HumanSkeleton skeleton) throws IOException {
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.slimevr.posestreamer;
|
||||
|
||||
import dev.slimevr.poserecorder.PoseFrameIO;
|
||||
import dev.slimevr.poserecorder.PoseFrameSkeleton;
|
||||
import dev.slimevr.poserecorder.PoseFrames;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.io.File;
|
||||
public class PoseFrameStreamer extends PoseStreamer {
|
||||
|
||||
private final PoseFrames frames;
|
||||
private final HumanPoseManager humanPoseManager;
|
||||
|
||||
public PoseFrameStreamer(String path) {
|
||||
this(new File(path));
|
||||
@@ -20,8 +21,9 @@ public class PoseFrameStreamer extends PoseStreamer {
|
||||
}
|
||||
|
||||
public PoseFrameStreamer(PoseFrames frames) {
|
||||
super(new PoseFrameSkeleton(frames.getTrackers(), null));
|
||||
this.frames = frames;
|
||||
this.frames = new PoseFrames(frames);
|
||||
humanPoseManager = new HumanPoseManager(this.frames.getTrackers());
|
||||
skeleton = humanPoseManager.getSkeleton();
|
||||
}
|
||||
|
||||
public PoseFrames getFrames() {
|
||||
@@ -29,10 +31,9 @@ public class PoseFrameStreamer extends PoseStreamer {
|
||||
}
|
||||
|
||||
public synchronized void streamAllFrames() {
|
||||
PoseFrameSkeleton skeleton = (PoseFrameSkeleton) this.skeleton;
|
||||
for (int i = 0; i < frames.getMaxFrameCount(); i++) {
|
||||
skeleton.setCursor(i);
|
||||
skeleton.updatePose();
|
||||
frames.setCursors(i);
|
||||
humanPoseManager.update();
|
||||
captureFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.posestreamer;
|
||||
|
||||
import dev.slimevr.vr.processor.skeleton.Skeleton;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -10,10 +10,13 @@ public class PoseStreamer {
|
||||
|
||||
protected long frameRecordingInterval = 60L;
|
||||
|
||||
protected Skeleton skeleton;
|
||||
protected HumanSkeleton skeleton;
|
||||
protected PoseDataStream poseFileStream;
|
||||
|
||||
public PoseStreamer(Skeleton skeleton) {
|
||||
protected PoseStreamer() {
|
||||
}
|
||||
|
||||
public PoseStreamer(HumanSkeleton skeleton) {
|
||||
this.skeleton = skeleton;
|
||||
}
|
||||
|
||||
@@ -43,7 +46,7 @@ public class PoseStreamer {
|
||||
this.frameRecordingInterval = intervalMs;
|
||||
}
|
||||
|
||||
public synchronized Skeleton getSkeleton() {
|
||||
public synchronized HumanSkeleton getSkeleton() {
|
||||
return skeleton;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.slimevr.posestreamer;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.processor.skeleton.Skeleton;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
|
||||
|
||||
public class ServerPoseStreamer extends TickPoseStreamer {
|
||||
@@ -19,7 +19,7 @@ public class ServerPoseStreamer extends TickPoseStreamer {
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void onSkeletonUpdated(Skeleton skeleton) {
|
||||
public void onSkeletonUpdated(HumanSkeleton skeleton) {
|
||||
this.skeleton = skeleton;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.posestreamer;
|
||||
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.posestreamer;
|
||||
|
||||
import dev.slimevr.vr.processor.skeleton.Skeleton;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -9,7 +9,7 @@ public class TickPoseStreamer extends PoseStreamer {
|
||||
|
||||
protected long nextFrameTimeMs = -1L;
|
||||
|
||||
public TickPoseStreamer(Skeleton skeleton) {
|
||||
public TickPoseStreamer(HumanSkeleton skeleton) {
|
||||
super(skeleton);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TickPoseStreamer extends PoseStreamer {
|
||||
return;
|
||||
}
|
||||
|
||||
Skeleton skeleton = this.skeleton;
|
||||
HumanSkeleton skeleton = this.skeleton;
|
||||
if (skeleton == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.slimevr.posestreamer;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Transform;
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -3,9 +3,9 @@ package dev.slimevr.protocol.datafeed;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.processor.skeleton.BoneInfo;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import dev.slimevr.tracking.processor.BoneInfo;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import solarxr_protocol.data_feed.Bone;
|
||||
import solarxr_protocol.data_feed.DataFeedUpdate;
|
||||
import solarxr_protocol.data_feed.device_data.DeviceData;
|
||||
|
||||
@@ -89,12 +89,12 @@ public class DataFeedHandler extends ProtocolHandler<DataFeedMessageHeader> {
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
var s = this.api.server.humanPoseProcessor.getSkeleton();
|
||||
var h = this.api.server.humanPoseManager;
|
||||
int bonesOffset = DataFeedBuilder
|
||||
.createBonesData(
|
||||
fbb,
|
||||
config.getBoneMask(),
|
||||
s.currentBoneInfo
|
||||
h.getCurrentBoneInfo()
|
||||
);
|
||||
|
||||
return DataFeedUpdate.createDataFeedUpdate(fbb, devicesOffset, trackersOffset, bonesOffset);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.slimevr.protocol.rpc;
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import dev.slimevr.vr.processor.HumanPoseProcessor;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
import solarxr_protocol.rpc.SkeletonConfigResponse;
|
||||
import solarxr_protocol.rpc.SkeletonPart;
|
||||
|
||||
@@ -11,14 +11,14 @@ public class RPCBuilder {
|
||||
|
||||
public static int createSkeletonConfig(
|
||||
FlatBufferBuilder fbb,
|
||||
HumanPoseProcessor humanPoseProcessor
|
||||
HumanPoseManager humanPoseManager
|
||||
) {
|
||||
int[] partsOffsets = new int[SkeletonConfigOffsets.values().length];
|
||||
|
||||
for (int index = 0; index < SkeletonConfigOffsets.values().length; index++) {
|
||||
SkeletonConfigOffsets val = SkeletonConfigOffsets.values[index];
|
||||
int part = SkeletonPart
|
||||
.createSkeletonPart(fbb, val.id, humanPoseProcessor.getSkeletonConfig(val));
|
||||
.createSkeletonPart(fbb, val.id, humanPoseManager.getOffset(val));
|
||||
partsOffsets[index] = part;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ import dev.slimevr.protocol.ProtocolAPI;
|
||||
import dev.slimevr.protocol.ProtocolHandler;
|
||||
import dev.slimevr.protocol.rpc.serial.RPCSerialHandler;
|
||||
import dev.slimevr.protocol.rpc.settings.RPCSettingsHandler;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigOffsets;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerPosition;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.trackers.IMUTracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerPosition;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import solarxr_protocol.MessageBundle;
|
||||
import solarxr_protocol.datatypes.TransactionId;
|
||||
@@ -101,13 +101,13 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader>
|
||||
if (req == null)
|
||||
return;
|
||||
|
||||
this.api.server.humanPoseProcessor.getSkeletonConfig().resetOffsets();
|
||||
this.api.server.humanPoseProcessor.getSkeletonConfig().save();
|
||||
this.api.server.humanPoseManager.resetOffsets();
|
||||
this.api.server.humanPoseManager.saveConfig();
|
||||
this.api.server.getConfigManager().saveConfig();
|
||||
|
||||
// might not be a good idea maybe let the client ask again
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(300);
|
||||
int config = RPCBuilder.createSkeletonConfig(fbb, this.api.server.humanPoseProcessor);
|
||||
int config = RPCBuilder.createSkeletonConfig(fbb, this.api.server.humanPoseManager);
|
||||
int outbound = this.createRPCMessage(fbb, RpcMessage.SkeletonConfigResponse, config);
|
||||
fbb.finish(outbound);
|
||||
conn.send(fbb.dataBuffer());
|
||||
@@ -120,7 +120,7 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader>
|
||||
return;
|
||||
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(300);
|
||||
int config = RPCBuilder.createSkeletonConfig(fbb, this.api.server.humanPoseProcessor);
|
||||
int config = RPCBuilder.createSkeletonConfig(fbb, this.api.server.humanPoseManager);
|
||||
int outbound = this.createRPCMessage(fbb, RpcMessage.SkeletonConfigResponse, config);
|
||||
fbb.finish(outbound);
|
||||
conn.send(fbb.dataBuffer());
|
||||
@@ -137,8 +137,8 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader>
|
||||
|
||||
SkeletonConfigOffsets joint = SkeletonConfigOffsets.getById(req.bone());
|
||||
|
||||
this.api.server.humanPoseProcessor.setSkeletonConfig(joint, req.value());
|
||||
this.api.server.humanPoseProcessor.getSkeletonConfig().save();
|
||||
this.api.server.humanPoseManager.setOffset(joint, req.value());
|
||||
this.api.server.humanPoseManager.saveConfig();
|
||||
this.api.server.getConfigManager().saveConfig();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import dev.slimevr.config.*;
|
||||
import dev.slimevr.filtering.TrackerFilters;
|
||||
import dev.slimevr.platform.SteamVRBridge;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfig;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigToggles;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigValues;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigToggles;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigValues;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
import solarxr_protocol.rpc.*;
|
||||
import solarxr_protocol.rpc.settings.LegTweaksSettings;
|
||||
import solarxr_protocol.rpc.settings.ModelRatios;
|
||||
@@ -141,29 +141,29 @@ public class RPCSettingsBuilder {
|
||||
|
||||
public static int createModelSettings(
|
||||
FlatBufferBuilder fbb,
|
||||
SkeletonConfig config,
|
||||
HumanPoseManager humanPoseManager,
|
||||
LegTweaksConfig legTweaksConfig
|
||||
) {
|
||||
int togglesOffset = ModelToggles
|
||||
.createModelToggles(
|
||||
fbb,
|
||||
config.getToggle(SkeletonConfigToggles.EXTENDED_SPINE_MODEL),
|
||||
config.getToggle(SkeletonConfigToggles.EXTENDED_PELVIS_MODEL),
|
||||
config.getToggle(SkeletonConfigToggles.EXTENDED_KNEE_MODEL),
|
||||
config.getToggle(SkeletonConfigToggles.FORCE_ARMS_FROM_HMD),
|
||||
config.getToggle(SkeletonConfigToggles.FLOOR_CLIP),
|
||||
config.getToggle(SkeletonConfigToggles.SKATING_CORRECTION),
|
||||
config.getToggle(SkeletonConfigToggles.VIVE_EMULATION)
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.EXTENDED_SPINE_MODEL),
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.EXTENDED_PELVIS_MODEL),
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.EXTENDED_KNEE_MODEL),
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.FORCE_ARMS_FROM_HMD),
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.FLOOR_CLIP),
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.SKATING_CORRECTION),
|
||||
humanPoseManager.getToggle(SkeletonConfigToggles.VIVE_EMULATION)
|
||||
);
|
||||
int ratiosOffset = ModelRatios
|
||||
.createModelRatios(
|
||||
fbb,
|
||||
config.getValue(SkeletonConfigValues.WAIST_FROM_CHEST_HIP_AVERAGING),
|
||||
config.getValue(SkeletonConfigValues.WAIST_FROM_CHEST_LEGS_AVERAGING),
|
||||
config.getValue(SkeletonConfigValues.HIP_FROM_CHEST_LEGS_AVERAGING),
|
||||
config.getValue(SkeletonConfigValues.HIP_FROM_WAIST_LEGS_AVERAGING),
|
||||
config.getValue(SkeletonConfigValues.HIP_LEGS_AVERAGING),
|
||||
config.getValue(SkeletonConfigValues.KNEE_TRACKER_ANKLE_AVERAGING)
|
||||
humanPoseManager.getValue(SkeletonConfigValues.WAIST_FROM_CHEST_HIP_AVERAGING),
|
||||
humanPoseManager.getValue(SkeletonConfigValues.WAIST_FROM_CHEST_LEGS_AVERAGING),
|
||||
humanPoseManager.getValue(SkeletonConfigValues.HIP_FROM_CHEST_LEGS_AVERAGING),
|
||||
humanPoseManager.getValue(SkeletonConfigValues.HIP_FROM_WAIST_LEGS_AVERAGING),
|
||||
humanPoseManager.getValue(SkeletonConfigValues.HIP_LEGS_AVERAGING),
|
||||
humanPoseManager.getValue(SkeletonConfigValues.KNEE_TRACKER_ANKLE_AVERAGING)
|
||||
);
|
||||
int legTweaksOffset = LegTweaksSettings
|
||||
.createLegTweaksSettings(
|
||||
|
||||
@@ -12,9 +12,9 @@ import dev.slimevr.platform.SteamVRBridge;
|
||||
import dev.slimevr.protocol.GenericConnection;
|
||||
import dev.slimevr.protocol.ProtocolAPI;
|
||||
import dev.slimevr.protocol.rpc.RPCHandler;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigToggles;
|
||||
import dev.slimevr.vr.processor.skeleton.SkeletonConfigValues;
|
||||
import dev.slimevr.vr.trackers.TrackerRole;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigToggles;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigValues;
|
||||
import dev.slimevr.tracking.trackers.TrackerRole;
|
||||
import solarxr_protocol.rpc.ChangeSettingsRequest;
|
||||
import solarxr_protocol.rpc.RpcMessage;
|
||||
import solarxr_protocol.rpc.RpcMessageHeader;
|
||||
@@ -68,7 +68,7 @@ public record RPCSettingsHandler(RPCHandler rpcHandler, ProtocolAPI api) {
|
||||
RPCSettingsBuilder
|
||||
.createModelSettings(
|
||||
fbb,
|
||||
this.api.server.humanPoseProcessor.getSkeletonConfig(),
|
||||
this.api.server.humanPoseManager,
|
||||
this.api.server.getConfigManager().getVrConfig().getLegTweaks()
|
||||
),
|
||||
RPCSettingsBuilder
|
||||
@@ -227,13 +227,13 @@ public record RPCSettingsHandler(RPCHandler rpcHandler, ProtocolAPI api) {
|
||||
.setMountingResetTaps(tapDetectionSettings.tapMountingResetTaps());
|
||||
}
|
||||
|
||||
this.api.server.humanPoseProcessor.getSkeleton().updateTapDetectionConfig();
|
||||
this.api.server.humanPoseManager.updateTapDetectionConfig();
|
||||
}
|
||||
}
|
||||
|
||||
var modelSettings = req.modelSettings();
|
||||
if (modelSettings != null) {
|
||||
var cfg = this.api.server.humanPoseProcessor.getSkeletonConfig();
|
||||
var hpm = this.api.server.humanPoseManager;
|
||||
var legTweaksConfig = this.api.server.getConfigManager().getVrConfig().getLegTweaks();
|
||||
var toggles = modelSettings.toggles();
|
||||
var ratios = modelSettings.ratios();
|
||||
@@ -242,73 +242,73 @@ public record RPCSettingsHandler(RPCHandler rpcHandler, ProtocolAPI api) {
|
||||
if (toggles != null) {
|
||||
// Note: toggles.has____ returns the same as toggles._____ this
|
||||
// seems like a bug
|
||||
cfg.setToggle(SkeletonConfigToggles.EXTENDED_SPINE_MODEL, toggles.extendedSpine());
|
||||
cfg
|
||||
hpm.setToggle(SkeletonConfigToggles.EXTENDED_SPINE_MODEL, toggles.extendedSpine());
|
||||
hpm
|
||||
.setToggle(
|
||||
SkeletonConfigToggles.EXTENDED_PELVIS_MODEL,
|
||||
toggles.extendedPelvis()
|
||||
);
|
||||
cfg.setToggle(SkeletonConfigToggles.EXTENDED_KNEE_MODEL, toggles.extendedKnee());
|
||||
cfg
|
||||
hpm.setToggle(SkeletonConfigToggles.EXTENDED_KNEE_MODEL, toggles.extendedKnee());
|
||||
hpm
|
||||
.setToggle(
|
||||
SkeletonConfigToggles.FORCE_ARMS_FROM_HMD,
|
||||
toggles.forceArmsFromHmd()
|
||||
);
|
||||
cfg.setToggle(SkeletonConfigToggles.EXTENDED_SPINE_MODEL, toggles.extendedSpine());
|
||||
cfg
|
||||
hpm.setToggle(SkeletonConfigToggles.EXTENDED_SPINE_MODEL, toggles.extendedSpine());
|
||||
hpm
|
||||
.setToggle(
|
||||
SkeletonConfigToggles.EXTENDED_PELVIS_MODEL,
|
||||
toggles.extendedPelvis()
|
||||
);
|
||||
cfg.setToggle(SkeletonConfigToggles.EXTENDED_KNEE_MODEL, toggles.extendedKnee());
|
||||
cfg
|
||||
hpm.setToggle(SkeletonConfigToggles.EXTENDED_KNEE_MODEL, toggles.extendedKnee());
|
||||
hpm
|
||||
.setToggle(
|
||||
SkeletonConfigToggles.FORCE_ARMS_FROM_HMD,
|
||||
toggles.forceArmsFromHmd()
|
||||
);
|
||||
cfg.setToggle(SkeletonConfigToggles.FLOOR_CLIP, toggles.floorClip());
|
||||
cfg
|
||||
hpm.setToggle(SkeletonConfigToggles.FLOOR_CLIP, toggles.floorClip());
|
||||
hpm
|
||||
.setToggle(
|
||||
SkeletonConfigToggles.SKATING_CORRECTION,
|
||||
toggles.skatingCorrection()
|
||||
);
|
||||
cfg.setToggle(SkeletonConfigToggles.VIVE_EMULATION, toggles.viveEmulation());
|
||||
hpm.setToggle(SkeletonConfigToggles.VIVE_EMULATION, toggles.viveEmulation());
|
||||
}
|
||||
|
||||
if (ratios != null) {
|
||||
if (ratios.hasImputeWaistFromChestHip()) {
|
||||
cfg
|
||||
hpm
|
||||
.setValue(
|
||||
SkeletonConfigValues.WAIST_FROM_CHEST_HIP_AVERAGING,
|
||||
ratios.imputeWaistFromChestHip()
|
||||
);
|
||||
}
|
||||
if (ratios.hasImputeWaistFromChestLegs()) {
|
||||
cfg
|
||||
hpm
|
||||
.setValue(
|
||||
SkeletonConfigValues.WAIST_FROM_CHEST_LEGS_AVERAGING,
|
||||
ratios.imputeWaistFromChestLegs()
|
||||
);
|
||||
}
|
||||
if (ratios.hasImputeHipFromChestLegs()) {
|
||||
cfg
|
||||
hpm
|
||||
.setValue(
|
||||
SkeletonConfigValues.HIP_FROM_CHEST_LEGS_AVERAGING,
|
||||
ratios.imputeHipFromChestLegs()
|
||||
);
|
||||
}
|
||||
if (ratios.hasImputeHipFromWaistLegs()) {
|
||||
cfg
|
||||
hpm
|
||||
.setValue(
|
||||
SkeletonConfigValues.HIP_FROM_WAIST_LEGS_AVERAGING,
|
||||
ratios.imputeHipFromWaistLegs()
|
||||
);
|
||||
}
|
||||
if (ratios.hasInterpHipLegs()) {
|
||||
cfg.setValue(SkeletonConfigValues.HIP_LEGS_AVERAGING, ratios.interpHipLegs());
|
||||
hpm.setValue(SkeletonConfigValues.HIP_LEGS_AVERAGING, ratios.interpHipLegs());
|
||||
}
|
||||
if (ratios.hasInterpKneeTrackerAnkle()) {
|
||||
cfg
|
||||
hpm
|
||||
.setValue(
|
||||
SkeletonConfigValues.KNEE_TRACKER_ANKLE_AVERAGING,
|
||||
ratios.interpKneeTrackerAnkle()
|
||||
@@ -320,10 +320,10 @@ public record RPCSettingsHandler(RPCHandler rpcHandler, ProtocolAPI api) {
|
||||
if (legTweaks.hasCorrectionStrength()) {
|
||||
legTweaksConfig.setCorrectionStrength(legTweaks.correctionStrength());
|
||||
}
|
||||
this.api.server.humanPoseProcessor.getSkeleton().updateLegTweaksConfig();
|
||||
this.api.server.humanPoseManager.updateLegTweaksConfig();
|
||||
}
|
||||
|
||||
cfg.save();
|
||||
hpm.saveConfig();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.vr;
|
||||
package dev.slimevr.tracking;
|
||||
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr;
|
||||
package dev.slimevr.tracking;
|
||||
|
||||
import dev.slimevr.VRServer;
|
||||
import io.eiren.util.collections.FastList;
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
|
||||
|
||||
/**
|
||||
* Provides an easy way to access pose information of a particular skeletal bone
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor;
|
||||
|
||||
import solarxr_protocol.datatypes.BodyPart;
|
||||
|
||||
@@ -0,0 +1,579 @@
|
||||
package dev.slimevr.tracking.processor;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigManager;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigToggles;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigValues;
|
||||
import dev.slimevr.tracking.processor.skeleton.HumanSkeleton;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import io.eiren.util.ann.ThreadSafe;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* Class to handle communicate between classes in "skeleton" package and outside
|
||||
*/
|
||||
public class HumanPoseManager {
|
||||
|
||||
private VRServer server;
|
||||
private final List<ComputedHumanPoseTracker> computedTrackers = new FastList<>();
|
||||
private final List<Consumer<HumanSkeleton>> onSkeletonUpdated = new FastList<>();
|
||||
private final SkeletonConfigManager skeletonConfigManager;
|
||||
private HumanSkeleton skeleton;
|
||||
|
||||
// #region Constructors
|
||||
private HumanPoseManager() {
|
||||
skeletonConfigManager = new SkeletonConfigManager(true, this);
|
||||
initializeComputedHumanPoseTracker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HumanPoseManager that uses the VRServer
|
||||
*
|
||||
* @param server the used VRServer
|
||||
*/
|
||||
public HumanPoseManager(VRServer server) {
|
||||
this();
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HumanPoseManager that uses the given trackers for the
|
||||
* HumanSkeleton and the default config
|
||||
*
|
||||
* @param trackers a list of all trackers
|
||||
*/
|
||||
public HumanPoseManager(List<? extends Tracker> trackers) {
|
||||
this();
|
||||
skeleton = new HumanSkeleton(this, trackers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HumanPoseManager that uses the given trackers for the
|
||||
* HumanSkeleton and the given offsets for config
|
||||
*
|
||||
* @param trackers a list of all trackers
|
||||
* @param offsetConfigs a map of the SkeletonConfigOffsets and values for
|
||||
* them
|
||||
*/
|
||||
public HumanPoseManager(
|
||||
List<? extends Tracker> trackers,
|
||||
Map<SkeletonConfigOffsets, Float> offsetConfigs
|
||||
) {
|
||||
this();
|
||||
skeleton = new HumanSkeleton(this, trackers);
|
||||
// Set offsetConfigs from given offsetConfigs on creation
|
||||
skeletonConfigManager.setOffsets(offsetConfigs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HumanPoseManager that uses the given trackers for the
|
||||
* HumanSkeleton and the given offsets for config
|
||||
*
|
||||
* @param trackers a list of all trackers
|
||||
* @param offsetConfigs a map of the SkeletonConfigOffsets and values for
|
||||
* them
|
||||
* @param altOffsetConfigs an alternative map of the SkeletonConfigOffsets
|
||||
* and values for them
|
||||
*/
|
||||
public HumanPoseManager(
|
||||
List<? extends Tracker> trackers,
|
||||
Map<SkeletonConfigOffsets, Float> offsetConfigs,
|
||||
Map<SkeletonConfigOffsets, Float> altOffsetConfigs
|
||||
) {
|
||||
this();
|
||||
skeleton = new HumanSkeleton(this, trackers);
|
||||
// Set offsetConfigs from given offsetConfigs on creation
|
||||
if (altOffsetConfigs != null) {
|
||||
// Set alts first, so if there's any overlap it doesn't affect
|
||||
// the values
|
||||
skeletonConfigManager.setOffsets(altOffsetConfigs);
|
||||
}
|
||||
skeletonConfigManager.setOffsets(offsetConfigs);
|
||||
}
|
||||
|
||||
// #endregion
|
||||
// #region private methods
|
||||
private void initializeComputedHumanPoseTracker() {
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.HEAD,
|
||||
TrackerRole.HEAD
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.CHEST,
|
||||
TrackerRole.CHEST
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.WAIST,
|
||||
TrackerRole.WAIST
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.LEFT_FOOT,
|
||||
TrackerRole.LEFT_FOOT
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.RIGHT_FOOT,
|
||||
TrackerRole.RIGHT_FOOT
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.LEFT_KNEE,
|
||||
TrackerRole.LEFT_KNEE
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.RIGHT_KNEE,
|
||||
TrackerRole.RIGHT_KNEE
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.LEFT_ELBOW,
|
||||
TrackerRole.LEFT_ELBOW
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.RIGHT_ELBOW,
|
||||
TrackerRole.RIGHT_ELBOW
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.LEFT_HAND,
|
||||
TrackerRole.LEFT_HAND
|
||||
)
|
||||
);
|
||||
computedTrackers
|
||||
.add(
|
||||
new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
ComputedHumanPoseTrackerPosition.RIGHT_HAND,
|
||||
TrackerRole.RIGHT_HAND
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
private void updateSkeletonModelFromServer() {
|
||||
disconnectAllTrackers();
|
||||
skeleton = new HumanSkeleton(this, server);
|
||||
skeletonConfigManager.loadFromConfig(server.getConfigManager());
|
||||
for (Consumer<HumanSkeleton> sc : onSkeletonUpdated)
|
||||
sc.accept(skeleton);
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
private void disconnectAllTrackers() {
|
||||
for (ComputedHumanPoseTracker t : computedTrackers) {
|
||||
t.setStatus(TrackerStatus.DISCONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
// #endregion
|
||||
// #region public methods
|
||||
// #region skeleton methods
|
||||
@VRServerThread
|
||||
public void trackerAdded(Tracker tracker) {
|
||||
updateSkeletonModelFromServer();
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void trackerUpdated(Tracker tracker) {
|
||||
updateSkeletonModelFromServer();
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void addSkeletonUpdatedCallback(Consumer<HumanSkeleton> consumer) {
|
||||
onSkeletonUpdated.add(consumer);
|
||||
if (isSkeletonPresent())
|
||||
consumer.accept(skeleton);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the skeleton isn't null, or false if it's null
|
||||
*/
|
||||
@ThreadSafe
|
||||
public boolean isSkeletonPresent() {
|
||||
return skeleton != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the pose of the skeleton from trackers rotations
|
||||
*/
|
||||
@VRServerThread
|
||||
public void update() {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.updatePose();
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public HumanSkeleton getSkeleton() {
|
||||
return skeleton;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
// #region tracker/nodes/bones methods
|
||||
/**
|
||||
* @return a list of the computed trackers as ShareableTrackers
|
||||
*/
|
||||
@ThreadSafe
|
||||
public List<? extends ShareableTracker> getShareableTracker() {
|
||||
return computedTrackers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of the computed trackers as ComputedHumanPoseTracker
|
||||
*/
|
||||
@ThreadSafe
|
||||
public List<? extends ComputedHumanPoseTracker> getComputedTracker() {
|
||||
return computedTrackers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding computed tracker for a given TrackerRole
|
||||
*
|
||||
* @param trackerRole the role of the tracker which we want
|
||||
* @return the corresponding computed tracker for the trackerRole
|
||||
*/
|
||||
@ThreadSafe
|
||||
public ComputedHumanPoseTracker getComputedTracker(TrackerRole trackerRole) {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.getComputedTracker(trackerRole);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the root node of the skeleton, which is the HMD
|
||||
*/
|
||||
@ThreadSafe
|
||||
public TransformNode getRootNode() {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.getRootNode();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tail node (away from the tracking root) of the given bone
|
||||
*
|
||||
* @param bone the bone from which we want the tail node
|
||||
* @return the tail node of the bone
|
||||
*/
|
||||
@ThreadSafe
|
||||
public TransformNode getTailNodeOfBone(BoneType bone) {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.getTailNodeOfBone(bone);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the HMD's y position from the skeleton
|
||||
*/
|
||||
@ThreadSafe
|
||||
public float getHmdHeight() {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.getHmdHeight();
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs checks to know if we should (and are) performing the tracking of the
|
||||
* left arm from the controller.
|
||||
*
|
||||
* @return a bool telling us if we are tracking the left arm from the
|
||||
* controller or not.
|
||||
*/
|
||||
@ThreadSafe
|
||||
public boolean isTrackingLeftArmFromController() {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.isTrackingLeftArmFromController();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs checks to know if we should (and are) performing the tracking of the
|
||||
* right arm from the controller.
|
||||
*
|
||||
* @return a bool telling us if we are tracking the right arm from the
|
||||
* controller or not.
|
||||
*/
|
||||
@ThreadSafe
|
||||
public boolean isTrackingRightArmFromController() {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.isTrackingRightArmFromController();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public List<BoneInfo> getCurrentBoneInfo() {
|
||||
if (isSkeletonPresent())
|
||||
return skeleton.currentBoneInfo;
|
||||
return null;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
// #region config methods
|
||||
/**
|
||||
* @param key the offset from which to get the corresponding value
|
||||
* @return the offset in config corresponding to the key
|
||||
*/
|
||||
@ThreadSafe
|
||||
public float getOffset(SkeletonConfigOffsets key) {
|
||||
return skeletonConfigManager.getOffset(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the offset to set the length to
|
||||
* @param newLength the new attributed length to the offset
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void setOffset(SkeletonConfigOffsets key, Float newLength) {
|
||||
skeletonConfigManager.setOffset(key, newLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all the offsets in the current SkeletonConfigManager
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void resetOffsets() {
|
||||
skeletonConfigManager.resetOffsets();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the toggle from which to get the corresponding value
|
||||
* @return the toggle in config corresponding to the key
|
||||
*/
|
||||
@ThreadSafe
|
||||
public boolean getToggle(SkeletonConfigToggles key) {
|
||||
return skeletonConfigManager.getToggle(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the toggle to set the value to
|
||||
* @param newValue the new attributed value to the toggle
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void setToggle(SkeletonConfigToggles key, Boolean newValue) {
|
||||
skeletonConfigManager.setToggle(key, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all the toggles in the current SkeletonConfigManager
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void resetToggles() {
|
||||
skeletonConfigManager.resetToggles();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the value from which to get the corresponding value
|
||||
* @return the value in config corresponding to the key
|
||||
*/
|
||||
@ThreadSafe
|
||||
public float getValue(SkeletonConfigValues key) {
|
||||
return skeletonConfigManager.getValue(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the value to set the value to
|
||||
* @param newValue the new attributed value to the value
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void setValue(SkeletonConfigValues key, Float newValue) {
|
||||
skeletonConfigManager.setValue(key, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all the values in the current SkeletonConfigManager
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void resetValues() {
|
||||
skeletonConfigManager.resetValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all the skeleton configs in the current SkeletonConfigManager
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void resetAllConfigs() {
|
||||
skeletonConfigManager.resetAllConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the skeleton configs
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void saveConfig() {
|
||||
skeletonConfigManager.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the given node with the given offset
|
||||
*
|
||||
* @param node the node to update
|
||||
* @param offset the new offset to apply to the node
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void updateNodeOffset(BoneType node, Vector3f offset) {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.updateNodeOffset(node, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the given toggle to the new given value in the skeleton
|
||||
*
|
||||
* @param configToggle the toggle to update
|
||||
* @param newValue the new value to apply to the toggle
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void updateToggleState(SkeletonConfigToggles configToggle, boolean newValue) {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.updateToggleState(configToggle, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the given value to the new given value in the skeleton
|
||||
*
|
||||
* @param configValue the value to update
|
||||
* @param newValue the new value to apply to the value
|
||||
*/
|
||||
@ThreadSafe
|
||||
public void updateValueState(SkeletonConfigValues configValue, float newValue) {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.updateValueState(configValue, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the offset for the given node and apply the new offset
|
||||
*
|
||||
* @param node the node to update
|
||||
*/
|
||||
public void computeNodeOffset(BoneType node) {
|
||||
skeletonConfigManager.computeNodeOffset(node);
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void resetTrackersFull() {
|
||||
if (isSkeletonPresent()) {
|
||||
skeleton.resetTrackersFull();
|
||||
if (server != null)
|
||||
server.getVrcOSCHandler().yawAlign();
|
||||
}
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void resetTrackersMounting() {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.resetTrackersMounting();
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void resetTrackersYaw() {
|
||||
if (isSkeletonPresent()) {
|
||||
skeleton.resetTrackersYaw();
|
||||
if (server != null)
|
||||
server.getVrcOSCHandler().yawAlign();
|
||||
}
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public boolean[] getLegTweaksState() {
|
||||
return skeleton.getLegTweaksState();
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void setLegTweaksEnabled(boolean value) {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.setLegTweaksEnabled(value);
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void setFloorClipEnabled(boolean value) {
|
||||
if (isSkeletonPresent()) {
|
||||
skeleton.setFloorclipEnabled(value);
|
||||
if (server != null) {
|
||||
server
|
||||
.getConfigManager()
|
||||
.getVrConfig()
|
||||
.getSkeleton()
|
||||
.getToggles()
|
||||
.put(SkeletonConfigToggles.FLOOR_CLIP.configKey, value);
|
||||
server.getConfigManager().saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VRServerThread
|
||||
public void setSkatingCorrectionEnabled(boolean value) {
|
||||
if (isSkeletonPresent()) {
|
||||
skeleton.setSkatingCorrectionEnabled(value);
|
||||
if (server != null) {
|
||||
server
|
||||
.getConfigManager()
|
||||
.getVrConfig()
|
||||
.getSkeleton()
|
||||
.getToggles()
|
||||
.put(SkeletonConfigToggles.SKATING_CORRECTION.configKey, value);
|
||||
server.getConfigManager().saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTapDetectionConfig() {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.updateTapDetectionConfig();
|
||||
}
|
||||
|
||||
public void updateLegTweaksConfig() {
|
||||
if (isSkeletonPresent())
|
||||
skeleton.updateLegTweaksConfig();
|
||||
}
|
||||
|
||||
@ThreadSafe
|
||||
public float getUserHeightFromConfig() {
|
||||
if (isSkeletonPresent()) {
|
||||
return skeletonConfigManager.getUserHeightFromOffsets();
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
// #endregion
|
||||
// #endregion
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.processor;
|
||||
package dev.slimevr.tracking.processor;
|
||||
|
||||
import com.jme3.math.Transform;
|
||||
import io.eiren.util.collections.FastList;
|
||||
@@ -1,16 +1,18 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.config;
|
||||
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.Main;
|
||||
import dev.slimevr.autobone.errors.BodyProportionError;
|
||||
import dev.slimevr.config.ConfigManager;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
import dev.slimevr.tracking.processor.BoneType;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class SkeletonConfig {
|
||||
public class SkeletonConfigManager {
|
||||
|
||||
protected final EnumMap<SkeletonConfigOffsets, Float> configOffsets = new EnumMap<>(
|
||||
SkeletonConfigOffsets.class
|
||||
@@ -30,73 +32,46 @@ public class SkeletonConfig {
|
||||
);
|
||||
|
||||
protected final boolean autoUpdateOffsets;
|
||||
protected final SkeletonConfigCallback callback;
|
||||
protected Skeleton skeleton;
|
||||
protected HumanPoseManager humanPoseManager;
|
||||
protected float userHeight;
|
||||
static final float FLOOR_OFFSET = 0.05f;
|
||||
|
||||
public SkeletonConfig(boolean autoUpdateOffsets) {
|
||||
public SkeletonConfigManager(boolean autoUpdateOffsets) {
|
||||
this.autoUpdateOffsets = autoUpdateOffsets;
|
||||
this.callback = null;
|
||||
|
||||
callCallbackOnAll(true);
|
||||
updateSettingsInSkeleton();
|
||||
|
||||
if (autoUpdateOffsets) {
|
||||
computeAllNodeOffsets();
|
||||
}
|
||||
}
|
||||
|
||||
public SkeletonConfig(
|
||||
public SkeletonConfigManager(
|
||||
boolean autoUpdateOffsets,
|
||||
SkeletonConfigCallback callback,
|
||||
Skeleton skeleton
|
||||
HumanPoseManager humanPoseManager
|
||||
) {
|
||||
this.autoUpdateOffsets = autoUpdateOffsets;
|
||||
this.callback = callback;
|
||||
this.skeleton = skeleton;
|
||||
this.humanPoseManager = humanPoseManager;
|
||||
|
||||
callCallbackOnAll(true);
|
||||
updateSettingsInSkeleton();
|
||||
|
||||
if (autoUpdateOffsets) {
|
||||
computeAllNodeOffsets();
|
||||
}
|
||||
}
|
||||
|
||||
private void callCallbackOnAll(boolean defaultOnly) {
|
||||
if (callback == null) {
|
||||
public void updateSettingsInSkeleton() {
|
||||
if (humanPoseManager == null)
|
||||
return;
|
||||
}
|
||||
|
||||
for (SkeletonConfigOffsets config : SkeletonConfigOffsets.values) {
|
||||
try {
|
||||
Float val = configOffsets.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateOffsetsState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
}
|
||||
|
||||
for (SkeletonConfigToggles config : SkeletonConfigToggles.values) {
|
||||
try {
|
||||
Boolean val = configToggles.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateTogglesState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
Boolean val = configToggles.get(config);
|
||||
humanPoseManager.updateToggleState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
|
||||
for (SkeletonConfigValues config : SkeletonConfigValues.values) {
|
||||
try {
|
||||
Float val = configValues.get(config);
|
||||
if (!defaultOnly || val == null) {
|
||||
callback.updateValuesState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
Float val = configValues.get(config);
|
||||
humanPoseManager.updateValueState(config, val == null ? config.defaultValue : val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,16 +93,6 @@ public class SkeletonConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Calls callback
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback
|
||||
.updateOffsetsState(config, newValue != null ? newValue : config.defaultValue);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-calculate user height
|
||||
userHeight = getOffset(SkeletonConfigOffsets.NECK)
|
||||
+ getOffset(SkeletonConfigOffsets.CHEST)
|
||||
@@ -164,13 +129,10 @@ public class SkeletonConfig {
|
||||
configToggles.remove(config);
|
||||
}
|
||||
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback
|
||||
.updateTogglesState(config, newValue != null ? newValue : config.defaultValue);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
// Updates in skeleton
|
||||
if (humanPoseManager != null) {
|
||||
humanPoseManager
|
||||
.updateToggleState(config, newValue != null ? newValue : config.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,13 +155,10 @@ public class SkeletonConfig {
|
||||
configValues.remove(config);
|
||||
}
|
||||
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback
|
||||
.updateValuesState(config, newValue != null ? newValue : config.defaultValue);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
// Updates in skeleton
|
||||
if (humanPoseManager != null) {
|
||||
humanPoseManager
|
||||
.updateValueState(config, newValue != null ? newValue : config.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,12 +181,9 @@ public class SkeletonConfig {
|
||||
offset.set(x, y, z);
|
||||
}
|
||||
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback.updateNodeOffset(nodeOffset, offset);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
// Updates in skeleton
|
||||
if (humanPoseManager != null) {
|
||||
humanPoseManager.updateNodeOffset(nodeOffset, offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,23 +323,23 @@ public class SkeletonConfig {
|
||||
setOffsets(configOffsets, true);
|
||||
}
|
||||
|
||||
public void setOffsets(SkeletonConfig skeletonConfig) {
|
||||
public void setOffsets(SkeletonConfigManager skeletonConfigManager) {
|
||||
// Don't recalculate node offsets, just re-use them from skeletonConfig
|
||||
setOffsets(
|
||||
skeletonConfig.configOffsets,
|
||||
skeletonConfigManager.configOffsets,
|
||||
false
|
||||
);
|
||||
|
||||
// Copy skeletonConfig's nodeOffsets as the configs are all the same
|
||||
skeletonConfig.nodeOffsets.forEach((key, value) -> {
|
||||
skeletonConfigManager.nodeOffsets.forEach((key, value) -> {
|
||||
setNodeOffset(key, value.x, value.y, value.z);
|
||||
});
|
||||
}
|
||||
|
||||
public void resetOffsets() {
|
||||
if (skeleton != null) {
|
||||
if (humanPoseManager != null) {
|
||||
for (SkeletonConfigOffsets config : SkeletonConfigOffsets.values) {
|
||||
skeleton.resetSkeletonConfig(config);
|
||||
resetOffset(config);
|
||||
}
|
||||
} else {
|
||||
configOffsets.clear();
|
||||
@@ -391,60 +347,16 @@ public class SkeletonConfig {
|
||||
computeAllNodeOffsets();
|
||||
}
|
||||
}
|
||||
|
||||
// Calls offset callback
|
||||
if (callback != null) {
|
||||
for (SkeletonConfigOffsets config : SkeletonConfigOffsets.values) {
|
||||
try {
|
||||
callback
|
||||
.updateOffsetsState(config, config.defaultValue);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetValues() {
|
||||
configValues.clear();
|
||||
|
||||
// Calls values callback
|
||||
if (callback != null) {
|
||||
for (SkeletonConfigValues config : SkeletonConfigValues.values) {
|
||||
try {
|
||||
callback
|
||||
.updateValuesState(config, config.defaultValue);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove from config to use default if they change in the future.
|
||||
Arrays.fill(changedValues, false);
|
||||
for (SkeletonConfigValues value : SkeletonConfigValues.values) {
|
||||
Main
|
||||
.getVrServer()
|
||||
.getConfigManager()
|
||||
.getVrConfig()
|
||||
.getSkeleton()
|
||||
.getValues()
|
||||
.remove(value.configKey);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetToggles() {
|
||||
configToggles.clear();
|
||||
|
||||
// Calls toggles callback
|
||||
if (callback != null) {
|
||||
for (SkeletonConfigOffsets config : SkeletonConfigOffsets.values) {
|
||||
try {
|
||||
callback
|
||||
.updateOffsetsState(config, config.defaultValue);
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("[SkeletonConfig] Exception while calling callback", e);
|
||||
}
|
||||
// Updates in skeleton
|
||||
if (humanPoseManager != null) {
|
||||
for (SkeletonConfigToggles config : SkeletonConfigToggles.values) {
|
||||
humanPoseManager.updateToggleState(config, config.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,11 +370,69 @@ public class SkeletonConfig {
|
||||
.getSkeleton()
|
||||
.getToggles()
|
||||
.remove(value.configKey);
|
||||
// Set default in skeleton
|
||||
setToggle(value, value.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetValues() {
|
||||
configValues.clear();
|
||||
|
||||
// Updates in skeleton
|
||||
if (humanPoseManager != null) {
|
||||
for (SkeletonConfigValues config : SkeletonConfigValues.values) {
|
||||
humanPoseManager.updateValueState(config, config.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove from config to use default if they change in the future.
|
||||
Arrays.fill(changedValues, false);
|
||||
for (SkeletonConfigValues value : SkeletonConfigValues.values) {
|
||||
Main
|
||||
.getVrServer()
|
||||
.getConfigManager()
|
||||
.getVrConfig()
|
||||
.getSkeleton()
|
||||
.getValues()
|
||||
.remove(value.configKey);
|
||||
// Set default in skeleton
|
||||
setValue(value, value.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetAllConfigs() {
|
||||
resetOffsets();
|
||||
resetToggles();
|
||||
resetValues();
|
||||
}
|
||||
|
||||
public void resetOffset(SkeletonConfigOffsets config) {
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (config) {
|
||||
case CHEST, WAIST, HIP, UPPER_LEG, LOWER_LEG -> {
|
||||
float height = humanPoseManager.getHmdHeight()
|
||||
/ BodyProportionError.eyeHeightToHeightRatio;
|
||||
if (height > 0.5f) { // Reset only if floor level seems right,
|
||||
setOffset(
|
||||
config,
|
||||
height
|
||||
* BodyProportionError
|
||||
.getProportionLimitForOffset(config)
|
||||
.getTargetRatio()
|
||||
);
|
||||
} else { // if floor level is incorrect
|
||||
setOffset(config, null);
|
||||
}
|
||||
}
|
||||
default -> setOffset(config, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadFromConfig(ConfigManager configManager) {
|
||||
|
||||
// Load offsets
|
||||
for (SkeletonConfigOffsets configValue : SkeletonConfigOffsets.values) {
|
||||
Float val = configManager
|
||||
.getVrConfig()
|
||||
@@ -476,6 +446,7 @@ public class SkeletonConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Load toggles
|
||||
for (SkeletonConfigToggles configValue : SkeletonConfigToggles.values) {
|
||||
Boolean val = configManager
|
||||
.getVrConfig()
|
||||
@@ -487,6 +458,7 @@ public class SkeletonConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Load values
|
||||
for (SkeletonConfigValues configValue : SkeletonConfigValues.values) {
|
||||
Float val = configManager
|
||||
.getVrConfig()
|
||||
@@ -498,7 +470,7 @@ public class SkeletonConfig {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Updates all offsets
|
||||
if (autoUpdateOffsets) {
|
||||
computeAllNodeOffsets();
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.config;
|
||||
|
||||
import dev.slimevr.tracking.processor.BoneType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -1,25 +1,26 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.VRServer;
|
||||
import dev.slimevr.autobone.errors.BodyProportionError;
|
||||
import dev.slimevr.tracking.processor.BoneInfo;
|
||||
import dev.slimevr.tracking.processor.BoneType;
|
||||
import dev.slimevr.tracking.processor.HumanPoseManager;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigToggles;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigValues;
|
||||
import dev.slimevr.tracking.trackers.*;
|
||||
import dev.slimevr.util.ann.VRServerThread;
|
||||
import dev.slimevr.vr.processor.ComputedHumanPoseTracker;
|
||||
import dev.slimevr.vr.processor.ComputedHumanPoseTrackerPosition;
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
|
||||
public final SkeletonConfig skeletonConfig;
|
||||
public class HumanSkeleton {
|
||||
protected final HumanPoseManager humanPoseManager;
|
||||
// #region Upper body nodes (torso)
|
||||
// @formatter:off
|
||||
protected final TransformNode hmdNode = new TransformNode("HMD", false);
|
||||
@@ -64,6 +65,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
protected final TransformNode leftControllerNode = new TransformNode("Left-Controller", false);
|
||||
protected final TransformNode rightControllerNode = new TransformNode("Right-Controller", false);
|
||||
// @formatter:on
|
||||
public final List<BoneInfo> currentBoneInfo = new ArrayList<>();
|
||||
// #endregion
|
||||
// #region Buffers
|
||||
private final Vector3f posBuf = new Vector3f();
|
||||
@@ -117,7 +119,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
protected ComputedHumanPoseTracker computedRightHandTracker;
|
||||
// #endregion
|
||||
|
||||
// #region FK Settings
|
||||
// #region Settings
|
||||
// Toggles
|
||||
protected boolean extendedSpineModel;
|
||||
protected boolean extendedPelvisModel;
|
||||
@@ -147,27 +149,27 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
// #endregion
|
||||
|
||||
// #region Constructors
|
||||
protected HumanSkeleton(List<? extends ComputedHumanPoseTracker> computedTrackers) {
|
||||
assembleSkeleton(false);
|
||||
protected HumanSkeleton(
|
||||
HumanPoseManager humanPoseManager
|
||||
) {
|
||||
this.humanPoseManager = humanPoseManager;
|
||||
|
||||
// Set default skeleton configuration (callback automatically sets
|
||||
// initial offsets)
|
||||
skeletonConfig = new SkeletonConfig(true, this, this);
|
||||
assembleSkeleton();
|
||||
|
||||
if (computedTrackers != null) {
|
||||
setComputedTrackers(computedTrackers);
|
||||
if (humanPoseManager.getComputedTracker() != null) {
|
||||
setComputedTrackers(humanPoseManager.getComputedTracker());
|
||||
}
|
||||
fillNullComputedTrackers();
|
||||
resetBones();
|
||||
}
|
||||
|
||||
public HumanSkeleton(
|
||||
VRServer server,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers
|
||||
HumanPoseManager humanPoseManager,
|
||||
VRServer server
|
||||
) {
|
||||
this(computedTrackers);
|
||||
this(humanPoseManager);
|
||||
|
||||
setTrackersFromServer(server);
|
||||
skeletonConfig.loadFromConfig(server.getConfigManager());
|
||||
|
||||
tapDetectionManager = new TapDetectionManager(
|
||||
this,
|
||||
@@ -175,52 +177,19 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
server.getConfigManager().getVrConfig().getTapDetection()
|
||||
);
|
||||
legTweaks.setConfig(server.getConfigManager().getVrConfig().getLegTweaks());
|
||||
|
||||
}
|
||||
|
||||
public HumanSkeleton(
|
||||
List<? extends Tracker> trackers,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers
|
||||
HumanPoseManager humanPoseManager,
|
||||
List<? extends Tracker> trackers
|
||||
) {
|
||||
this(computedTrackers);
|
||||
this(humanPoseManager);
|
||||
|
||||
setTrackersFromList(Objects.requireNonNullElseGet(trackers, () -> new FastList<>(0)));
|
||||
}
|
||||
|
||||
public HumanSkeleton(
|
||||
List<? extends Tracker> trackers,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers,
|
||||
Map<SkeletonConfigOffsets, Float> configs,
|
||||
Map<SkeletonConfigOffsets, Float> altConfigs
|
||||
) {
|
||||
// Initialize
|
||||
this(trackers, computedTrackers);
|
||||
|
||||
// Set configs
|
||||
if (altConfigs != null) {
|
||||
// Set alts first, so if there's any overlap it doesn't affect the
|
||||
// values
|
||||
skeletonConfig.setOffsets(altConfigs);
|
||||
}
|
||||
skeletonConfig.setOffsets(configs);
|
||||
}
|
||||
|
||||
public HumanSkeleton(
|
||||
List<? extends Tracker> trackers,
|
||||
List<? extends ComputedHumanPoseTracker> computedTrackers,
|
||||
Map<SkeletonConfigOffsets, Float> configs
|
||||
) {
|
||||
this(trackers, computedTrackers, configs, null);
|
||||
}
|
||||
// #endregion
|
||||
|
||||
protected void assembleSkeleton(boolean reset) {
|
||||
if (reset) {
|
||||
for (TransformNode node : getAllNodes()) {
|
||||
node.detachWithChildren();
|
||||
}
|
||||
}
|
||||
|
||||
protected void assembleSkeleton() {
|
||||
// #region Assemble skeleton from hmd to hip
|
||||
hmdNode.attachChild(headNode);
|
||||
headNode.attachChild(neckNode);
|
||||
@@ -500,7 +469,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
|
||||
|
||||
// #region Set trackers inputs
|
||||
public void setTrackersFromList(List<? extends Tracker> trackers) {
|
||||
protected void setTrackersFromList(List<? extends Tracker> trackers) {
|
||||
this.hmdTracker = TrackerUtils
|
||||
.findNonComputedHumanPoseTrackerForBodyPosition(
|
||||
trackers,
|
||||
@@ -623,19 +592,19 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
assembleSkeletonArms(true);
|
||||
|
||||
// Refresh node offsets for arms
|
||||
skeletonConfig.computeNodeOffset(BoneType.LEFT_LOWER_ARM);
|
||||
skeletonConfig.computeNodeOffset(BoneType.RIGHT_LOWER_ARM);
|
||||
humanPoseManager.computeNodeOffset(BoneType.LEFT_LOWER_ARM);
|
||||
humanPoseManager.computeNodeOffset(BoneType.RIGHT_LOWER_ARM);
|
||||
|
||||
// Rebuild the bone list
|
||||
resetBones();
|
||||
}
|
||||
|
||||
public void setTrackersFromServer(VRServer server) {
|
||||
protected void setTrackersFromServer(VRServer server) {
|
||||
this.hmdTracker = server.hmdTracker;
|
||||
setTrackersFromList(server.getAllTrackers());
|
||||
}
|
||||
|
||||
public void setComputedTracker(ComputedHumanPoseTracker tracker) {
|
||||
protected void setComputedTracker(ComputedHumanPoseTracker tracker) {
|
||||
switch (tracker.getTrackerRole()) {
|
||||
case HEAD -> computedHeadTracker = tracker;
|
||||
case CHEST -> computedChestTracker = tracker;
|
||||
@@ -652,7 +621,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
}
|
||||
|
||||
public void setComputedTrackers(List<? extends ComputedHumanPoseTracker> trackers) {
|
||||
protected void setComputedTrackers(List<? extends ComputedHumanPoseTracker> trackers) {
|
||||
for (ComputedHumanPoseTracker t : trackers) {
|
||||
setComputedTracker(t);
|
||||
}
|
||||
@@ -660,7 +629,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
public void fillNullComputedTrackers() {
|
||||
protected void fillNullComputedTrackers() {
|
||||
if (computedHeadTracker == null) {
|
||||
computedHeadTracker = new ComputedHumanPoseTracker(
|
||||
Tracker.getNextLocalTrackerId(),
|
||||
@@ -751,7 +720,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
}
|
||||
|
||||
// #region Get Trackers
|
||||
// #region Get trackers
|
||||
public ComputedHumanPoseTracker getComputedTracker(TrackerRole trackerRole) {
|
||||
switch (trackerRole) {
|
||||
case HEAD:
|
||||
@@ -784,7 +753,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
|
||||
// #region Processing
|
||||
// Useful for sub-classes that need to return a sub-tracker (like
|
||||
// Useful for subclasses that need to return a sub-tracker (like
|
||||
// PoseFrameTracker -> TrackerFrame)
|
||||
protected Tracker trackerPreUpdate(Tracker tracker) {
|
||||
return tracker;
|
||||
@@ -792,7 +761,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
|
||||
// Updates the pose from tracker positions
|
||||
@VRServerThread
|
||||
@Override
|
||||
public void updatePose() {
|
||||
tapDetectionManager.update();
|
||||
updateLocalTransforms();
|
||||
@@ -1345,13 +1313,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
// #endregion
|
||||
|
||||
// #region Skeleton Config
|
||||
@Override
|
||||
public void updateOffsetsState(SkeletonConfigOffsets configOffset, float newValue) {
|
||||
// Do nothing, the node offset callback handles all that's needed
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTogglesState(SkeletonConfigToggles configToggle, boolean newValue) {
|
||||
public void updateToggleState(SkeletonConfigToggles configToggle, boolean newValue) {
|
||||
if (configToggle == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1373,8 +1335,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateValuesState(SkeletonConfigValues configValue, float newValue) {
|
||||
public void updateValueState(SkeletonConfigValues configValue, float newValue) {
|
||||
if (configValue == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1390,7 +1351,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNodeOffset(BoneType nodeOffset, Vector3f offset) {
|
||||
if (nodeOffset == null) {
|
||||
return;
|
||||
@@ -1583,13 +1543,11 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
// #endregion
|
||||
|
||||
@Override
|
||||
public TransformNode getRootNode() {
|
||||
return hmdNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformNode[] getAllNodes() {
|
||||
protected TransformNode[] getAllNodes() {
|
||||
return new TransformNode[] {
|
||||
hmdNode,
|
||||
headNode,
|
||||
@@ -1631,7 +1589,7 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
};
|
||||
}
|
||||
|
||||
public TransformNode[] getArmNodes() {
|
||||
protected TransformNode[] getArmNodes() {
|
||||
return new TransformNode[] {
|
||||
leftShoulderHeadNode,
|
||||
rightShoulderHeadNode,
|
||||
@@ -1652,37 +1610,10 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkeletonConfig getSkeletonConfig() {
|
||||
return skeletonConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetSkeletonConfig(SkeletonConfigOffsets config) {
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (config) {
|
||||
case CHEST, WAIST, HIP, UPPER_LEG, LOWER_LEG -> {
|
||||
Vector3f vec = new Vector3f();
|
||||
hmdTracker.getPosition(vec);
|
||||
float height = vec.y / BodyProportionError.eyeHeightToHeightRatio;
|
||||
if (height > 0.5f) { // Reset only if floor level seems right,
|
||||
skeletonConfig
|
||||
.setOffset(
|
||||
config,
|
||||
height
|
||||
* BodyProportionError
|
||||
.getProportionLimitForOffset(config)
|
||||
.getTargetRatio()
|
||||
);
|
||||
} else { // if floor level is incorrect
|
||||
skeletonConfig.setOffset(config, null);
|
||||
}
|
||||
}
|
||||
default -> skeletonConfig.setOffset(config, null);
|
||||
}
|
||||
public float getHmdHeight() {
|
||||
Vector3f hmdVec = new Vector3f();
|
||||
hmdTracker.getPosition(hmdVec);
|
||||
return hmdVec.y;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1730,7 +1661,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTrackersFull() {
|
||||
// Pass all trackers through trackerPreUpdate
|
||||
Tracker hmdTracker = trackerPreUpdate(this.hmdTracker);
|
||||
@@ -1761,16 +1691,14 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
|
||||
private boolean shouldReverseYaw(TrackerPosition position) {
|
||||
return position != null
|
||||
&& (position == TrackerPosition.LEFT_UPPER_LEG
|
||||
|| position == TrackerPosition.RIGHT_UPPER_LEG
|
||||
|| position == TrackerPosition.LEFT_LOWER_ARM
|
||||
|| position == TrackerPosition.RIGHT_LOWER_ARM
|
||||
|| position == TrackerPosition.LEFT_HAND
|
||||
|| position == TrackerPosition.RIGHT_HAND);
|
||||
return position == TrackerPosition.LEFT_UPPER_LEG
|
||||
|| position == TrackerPosition.RIGHT_UPPER_LEG
|
||||
|| position == TrackerPosition.LEFT_LOWER_ARM
|
||||
|| position == TrackerPosition.RIGHT_LOWER_ARM
|
||||
|| position == TrackerPosition.LEFT_HAND
|
||||
|| position == TrackerPosition.RIGHT_HAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
@VRServerThread
|
||||
public void resetTrackersMounting() {
|
||||
// Pass all trackers through trackerPreUpdate
|
||||
@@ -1784,7 +1712,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
this.legTweaks.resetBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
@VRServerThread
|
||||
public void resetTrackersYaw() {
|
||||
// Pass all trackers through trackerPreUpdate
|
||||
@@ -1811,7 +1738,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
legTweaks.updateConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean[] getLegTweaksState() {
|
||||
boolean[] state = new boolean[2];
|
||||
state[0] = this.legTweaks.getFloorclipEnabled();
|
||||
@@ -1820,21 +1746,18 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback {
|
||||
}
|
||||
|
||||
// master enable/disable of all leg tweaks (for autobone)
|
||||
@Override
|
||||
@VRServerThread
|
||||
public void setLegTweaksEnabled(boolean value) {
|
||||
this.legTweaks.setEnabled(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@VRServerThread
|
||||
public void setFloorclipEnabled(boolean value) {
|
||||
this.skeletonConfig.setToggle(SkeletonConfigToggles.FLOOR_CLIP, value);
|
||||
humanPoseManager.setToggle(SkeletonConfigToggles.FLOOR_CLIP, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@VRServerThread
|
||||
public void setSkatingCorrectionEnabled(boolean value) {
|
||||
this.skeletonConfig.setToggle(SkeletonConfigToggles.SKATING_CORRECTION, value);
|
||||
humanPoseManager.setToggle(SkeletonConfigToggles.SKATING_CORRECTION, value);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.config.LegTweaksConfig;
|
||||
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
|
||||
|
||||
public class LegTweaks {
|
||||
@@ -1,12 +1,10 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import dev.slimevr.tracking.processor.BoneType;
|
||||
import dev.slimevr.tracking.processor.TransformNode;
|
||||
import dev.slimevr.tracking.processor.config.SkeletonConfigManager;
|
||||
|
||||
import dev.slimevr.vr.processor.TransformNode;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,7 +15,7 @@ public class SkeletonData {
|
||||
|
||||
public final Joint[] joints;
|
||||
public final List<Bone> bones = new ArrayList<>();
|
||||
private final SkeletonConfig config;
|
||||
private final SkeletonConfigManager config;
|
||||
|
||||
private Map<BoneType, List<Bone>> bonesByOffsetKey = new EnumMap<>(
|
||||
BoneType.class
|
||||
@@ -60,7 +58,7 @@ public class SkeletonData {
|
||||
protected final Joint trackerRightHandJoint = new Joint("Right-Hand-Tracker");
|
||||
// #endregion
|
||||
|
||||
public SkeletonData(SkeletonConfig config) {
|
||||
public SkeletonData(SkeletonConfigManager config) {
|
||||
this.config = config;
|
||||
List<Joint> jointsList = new ArrayList<>();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
|
||||
|
||||
// class that monitors the acceleration of the waist, hip, or chest trackers to detect taps
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
|
||||
import dev.slimevr.config.TapDetectionConfig;
|
||||
import dev.slimevr.osc.VRCOSCHandler;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
|
||||
|
||||
// handles tap detection for the skeleton
|
||||
@@ -1,7 +1,8 @@
|
||||
package dev.slimevr.vr.processor.skeleton;
|
||||
package dev.slimevr.tracking.processor.skeleton;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
@@ -10,10 +11,10 @@ import java.util.Random;
|
||||
public class ViveEmulation {
|
||||
|
||||
// skeleton
|
||||
private HumanSkeleton skeleton;
|
||||
private final HumanSkeleton skeleton;
|
||||
|
||||
// random number generator
|
||||
private Random random = new Random();
|
||||
private final Random random = new Random();
|
||||
|
||||
// hyperparameters
|
||||
private static final int CHANCE = (int) 1e5;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.slimevr.vr.processor;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.trackers.*;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import io.eiren.util.BufferedTimer;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.processor;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public enum ComputedHumanPoseTrackerPosition {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.config.TrackerConfig;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.tracking.Device;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public enum DeviceType {
|
||||
HMD, CONTROLLER, TRACKER, TRACKING_REFERENCE
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import io.eiren.util.BufferedTimer;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
@@ -8,9 +8,9 @@ import dev.slimevr.config.TrackerConfig;
|
||||
import dev.slimevr.filtering.CircularArrayList;
|
||||
import dev.slimevr.filtering.QuaternionMovingAverage;
|
||||
import dev.slimevr.filtering.TrackerFilters;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.trackers.udp.TrackersUDPServer;
|
||||
import dev.slimevr.vr.trackers.udp.UDPDevice;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import dev.slimevr.tracking.trackers.udp.TrackersUDPServer;
|
||||
import dev.slimevr.tracking.trackers.udp.UDPDevice;
|
||||
import io.eiren.util.BufferedTimer;
|
||||
import io.eiren.util.collections.FastList;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public class SensorTap {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public interface ShareableTracker extends Tracker {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.config.TrackerConfig;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.tracking.Device;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import solarxr_protocol.datatypes.BodyPart;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
/**
|
||||
* The tracker role classifies the position and the role of a tracker on user's
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public enum TrackerStatus {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
|
||||
import dev.slimevr.vr.processor.ComputedHumanPoseTracker;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public interface TrackerWithBattery {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
|
||||
import dev.slimevr.filtering.TrackerFilters;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public interface TrackerWithTPS {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
public interface TrackerWithWireless {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
package dev.slimevr.tracking.trackers;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import io.eiren.util.BufferedTimer;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
public interface SensorSpecificPacket {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import dev.slimevr.Main;
|
||||
import dev.slimevr.NetworkProtocol;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import dev.slimevr.tracking.trackers.IMUTracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus;
|
||||
import io.eiren.util.Util;
|
||||
import io.eiren.util.collections.FastList;
|
||||
import io.eiren.util.logging.LogManager;
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import dev.slimevr.NetworkProtocol;
|
||||
import dev.slimevr.vr.Device;
|
||||
import dev.slimevr.vr.trackers.IMUTracker;
|
||||
import dev.slimevr.vr.trackers.Tracker;
|
||||
import dev.slimevr.tracking.Device;
|
||||
import dev.slimevr.tracking.trackers.IMUTracker;
|
||||
import dev.slimevr.tracking.trackers.Tracker;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketAddress;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import dev.slimevr.vr.trackers.SensorTap;
|
||||
import dev.slimevr.tracking.trackers.SensorTap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import dev.slimevr.vr.trackers.TrackerStatus;
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
public class UDPPacket16Rotation2 extends UDPPacket1Rotation {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import com.jme3.math.Quaternion;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.slimevr.vr.trackers.udp;
|
||||
package dev.slimevr.tracking.trackers.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user