mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 20:06:28 -08:00
Autobone support
Added basic autobone support for the hip tracker, fixed "allTracekrs" and changed initial values of upper body.
This commit is contained in:
1 parent
21eff5e1ba
commit
4055d51758
6 files changed
+72
-47
No files matched your search
@@ -72,8 +72,7 @@ public class AutoBone {
|
||||
public final HashMap<String, Float> configs = new HashMap<String, Float>();
|
||||
public final HashMap<String, Float> staticConfigs = new HashMap<String, Float>();
|
||||
|
||||
public final FastList<String> heightConfigs = new FastList<String>(new String[]{"Neck", "Waist", "Legs length"
|
||||
});
|
||||
public final FastList<String> heightConfigs = new FastList<String>(new String[]{"Neck", "Waist", "Hip", "Legs length"});
|
||||
|
||||
public AutoBone(VRServer server) {
|
||||
this.server = server;
|
||||
@@ -91,15 +90,22 @@ public class AutoBone {
|
||||
// Load waist configs
|
||||
staticConfigs.put("Head", server.config.getFloat("body.headShift", HumanSkeletonWithWaist.HEAD_SHIFT_DEFAULT));
|
||||
staticConfigs.put("Neck", server.config.getFloat("body.neckLength", HumanSkeletonWithWaist.NECK_LENGTH_DEFAULT));
|
||||
configs.put("Waist", server.config.getFloat("body.waistDistance", 0.64f));
|
||||
|
||||
configs.put("Waist", server.config.getFloat("body.waistDistance", 0.6f));
|
||||
if(server.config.getBoolean("autobone.forceChestTracker", false) || (frame != null && TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.CHEST) != null) || TrackerUtils.findTrackerForBodyPosition(server.getAllTrackers(), TrackerPosition.CHEST) != null) {
|
||||
// If force enabled or has a chest tracker
|
||||
configs.put("Chest", server.config.getFloat("body.chestDistance", 0.32f));
|
||||
configs.put("Chest", server.config.getFloat("body.chestDistance", 0.35f));
|
||||
} else {
|
||||
// Otherwise, make sure it's not used
|
||||
configs.remove("Chest");
|
||||
staticConfigs.put("Chest", server.config.getFloat("body.chestDistance", 0.32f));
|
||||
staticConfigs.put("Chest", server.config.getFloat("body.chestDistance", 0.35f));
|
||||
}
|
||||
if(server.config.getBoolean("autobone.forceHipTracker", false) || (frame != null && TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.HIP) != null) || TrackerUtils.findTrackerForBodyPosition(server.getAllTrackers(), TrackerPosition.HIP) != null) {
|
||||
// If force enabled or has a hip tracker
|
||||
configs.put("Hip", server.config.getFloat("body.hipDistance", 0.1f));
|
||||
} else {
|
||||
// Otherwise, make sure it's not used
|
||||
configs.remove("Hip");
|
||||
staticConfigs.put("Hip", server.config.getFloat("body.hipDistance", 0.1f));
|
||||
}
|
||||
|
||||
// Load leg configs
|
||||
@@ -150,6 +156,7 @@ public class AutoBone {
|
||||
setConfig("Neck", "body.neckLength");
|
||||
setConfig("Waist", "body.waistDistance");
|
||||
setConfig("Chest", "body.chestDistance");
|
||||
setConfig("Hip", "body.hipDistance");
|
||||
setConfig("Hips width", "body.hipsWidth");
|
||||
setConfig("Legs length", "body.legsLength");
|
||||
setConfig("Knee height", "body.kneeHeight");
|
||||
|
||||
@@ -25,15 +25,15 @@ public class SimpleSkeleton {
|
||||
protected final TransformNode chestNode = new TransformNode("Chest", false);
|
||||
protected final TransformNode hipNode = new TransformNode("Hip", false);
|
||||
|
||||
protected float chestDistance = 0.32f;
|
||||
protected float chestDistance = 0.35f;
|
||||
/**
|
||||
* Distance from eyes to waist
|
||||
*/
|
||||
protected float waistDistance = 0.64f;
|
||||
protected float waistDistance = 0.6f;
|
||||
/**
|
||||
* Distance from waist to hip
|
||||
*/
|
||||
protected float hipDistance = 0.05f;
|
||||
protected float hipDistance = 0.1f;
|
||||
/**
|
||||
* Distance from eyes to the base of the neck
|
||||
*/
|
||||
@@ -82,12 +82,15 @@ public class SimpleSkeleton {
|
||||
|
||||
chestNode.attachChild(waistNode);
|
||||
waistNode.localTransform.setTranslation(0, -(waistDistance - chestDistance), 0);
|
||||
|
||||
waistNode.attachChild(hipNode);
|
||||
hipNode.localTransform.setTranslation(0, -hipDistance, 0);
|
||||
|
||||
// Assemble skeleton to feet
|
||||
waistNode.attachChild(leftHipNode);
|
||||
hipNode.attachChild(leftHipNode);
|
||||
leftHipNode.localTransform.setTranslation(-hipsWidth / 2, 0, 0);
|
||||
|
||||
waistNode.attachChild(rightHipNode);
|
||||
hipNode.attachChild(rightHipNode);
|
||||
rightHipNode.localTransform.setTranslation(hipsWidth / 2, 0, 0);
|
||||
|
||||
leftHipNode.attachChild(leftKneeNode);
|
||||
@@ -138,17 +141,17 @@ public class SimpleSkeleton {
|
||||
hmdNode.localTransform.setTranslation(hmd.position);
|
||||
}
|
||||
}
|
||||
|
||||
TrackerFrame chest = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.CHEST, TrackerPosition.WAIST);
|
||||
TrackerFrame chest = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.CHEST, TrackerPosition.WAIST, TrackerPosition.HIP);
|
||||
setRotation(chest, neckNode);
|
||||
|
||||
TrackerFrame waist = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.WAIST, TrackerPosition.CHEST);
|
||||
TrackerFrame waist = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.WAIST, TrackerPosition.CHEST, TrackerPosition.HIP);
|
||||
setRotation(waist, chestNode);
|
||||
|
||||
TrackerFrame leftLeg = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.LEFT_LEG);
|
||||
TrackerFrame rightLeg = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.RIGHT_LEG);
|
||||
|
||||
averagePelvis(waist, leftLeg, rightLeg);
|
||||
TrackerFrame hip = TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.HIP, TrackerPosition.WAIST, TrackerPosition.CHEST);
|
||||
averagePelvis(hip, leftLeg, rightLeg);
|
||||
|
||||
setRotation(leftLeg, leftHipNode);
|
||||
setRotation(rightLeg, rightHipNode);
|
||||
@@ -168,19 +171,18 @@ public class SimpleSkeleton {
|
||||
}
|
||||
}
|
||||
|
||||
public void averagePelvis(TrackerFrame waist, TrackerFrame leftLeg, TrackerFrame rightLeg) {
|
||||
public void averagePelvis(TrackerFrame hip, TrackerFrame leftLeg, TrackerFrame rightLeg) {
|
||||
if((leftLeg == null || rightLeg == null) || (!leftLeg.hasData(TrackerFrameData.ROTATION) || !rightLeg.hasData(TrackerFrameData.ROTATION))) {
|
||||
setRotation(waist, waistNode);
|
||||
setRotation(hip, waistNode);
|
||||
return;
|
||||
}
|
||||
|
||||
if(waist == null || !waist.hasData(TrackerFrameData.ROTATION)) {
|
||||
if(hip == null || !hip.hasData(TrackerFrameData.ROTATION)) {
|
||||
if(leftLeg.hasData(TrackerFrameData.ROTATION) && rightLeg.hasData(TrackerFrameData.ROTATION)) {
|
||||
leftLeg.getRotation(rotBuf1);
|
||||
rightLeg.getRotation(rotBuf2);
|
||||
rotBuf1.nlerp(rotBuf2, 0.5f);
|
||||
|
||||
waistNode.localTransform.setRotation(rotBuf1);
|
||||
hipNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -190,11 +192,10 @@ public class SimpleSkeleton {
|
||||
leftLeg.getRotation(rotBuf1);
|
||||
rightLeg.getRotation(rotBuf2);
|
||||
rotBuf1.nlerp(rotBuf2, 0.5f);
|
||||
|
||||
waist.getRotation(rotBuf2);
|
||||
hip.getRotation(rotBuf2);
|
||||
rotBuf1.nlerp(rotBuf2, 0.3333333f);
|
||||
|
||||
waistNode.localTransform.setRotation(rotBuf1);
|
||||
hipNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
|
||||
public void setSkeletonConfigs(Map<String, Float> configs) {
|
||||
@@ -236,6 +237,13 @@ public class SimpleSkeleton {
|
||||
chestNode.update();
|
||||
}
|
||||
break;
|
||||
case "Hip":
|
||||
hipDistance = newLength;
|
||||
hipNode.localTransform.setTranslation(0, -hipDistance, 0);
|
||||
if(updatePose) {
|
||||
hipNode.update();
|
||||
}
|
||||
break;
|
||||
case "Hips width":
|
||||
hipsWidth = newLength;
|
||||
leftHipNode.localTransform.setTranslation(-hipsWidth / 2, 0, 0);
|
||||
@@ -278,6 +286,8 @@ public class SimpleSkeleton {
|
||||
return waistDistance;
|
||||
case "Chest":
|
||||
return chestDistance;
|
||||
case "Hip":
|
||||
return hipDistance;
|
||||
case "Hips width":
|
||||
return hipsWidth;
|
||||
case "Knee height":
|
||||
@@ -313,6 +323,8 @@ public class SimpleSkeleton {
|
||||
return rotationNode ? neckNode : chestNode;
|
||||
case WAIST:
|
||||
return rotationNode ? chestNode : waistNode;
|
||||
case HIP:
|
||||
return rotationNode ? hipNode : waistNode; //TODO check, need 3?
|
||||
|
||||
case LEFT_LEG:
|
||||
return rotationNode ? leftHipNode : leftKneeNode;
|
||||
@@ -348,6 +360,7 @@ public class SimpleSkeleton {
|
||||
config.setProperty("body.neckLength", neckLength);
|
||||
config.setProperty("body.waistDistance", waistDistance);
|
||||
config.setProperty("body.chestDistance", chestDistance);
|
||||
config.setProperty("body.hipDistance", hipDistance);
|
||||
|
||||
// Save leg configs
|
||||
config.setProperty("body.hipsWidth", hipsWidth);
|
||||
|
||||
@@ -342,6 +342,7 @@ public class AutoBoneWindow extends JFrame {
|
||||
Float neckLength = autoBone.getConfig("Neck");
|
||||
Float chestLength = autoBone.getConfig("Chest");
|
||||
Float waistLength = autoBone.getConfig("Waist");
|
||||
Float hipLength = autoBone.getConfig("Hip");
|
||||
Float hipWidth = autoBone.getConfig("Hips width");
|
||||
Float legsLength = autoBone.getConfig("Legs length");
|
||||
Float kneeHeight = autoBone.getConfig("Knee height");
|
||||
|
||||
Reference in new issue
Block a user