Initial commit

added hip tracking support.
Independent from waist.
Has a hip length value going from waist to hip.
Legs depend on hip instead of waist
should work normally without hip tracker.
Should work just fine with a virtual waist offset.
This commit is contained in:
Louka committed 2021-11-20 00:04:33 -05:00
1 parent e56d7665ed
commit e19cec4d3e
4 files changed
+50 -10

No files matched your search

@@ -117,6 +117,13 @@ public class SkeletonConfig extends EJBagNoStretch {
add(new TimedResetButton("Reset", "Waist"), c(4, row, 2));
row++;
add(new JLabel("Hip"), c(0, row, 2));
add(new AdjButton("+", "Hip", 0.01f), c(1, row, 2));
add(new SkeletonLabel("Hip"), c(2, row, 2));
add(new AdjButton("-", "Hip", -0.01f), c(3, row, 2));
add(new ResetButton("Reset", "Hip"), c(4, row, 2));
row++;
add(new JLabel("Hips width"), c(0, row, 2));
add(new AdjButton("+", "Hips width", 0.01f), c(1, row, 2));
add(new SkeletonLabel("Hips width"), c(2, row, 2));
@@ -111,10 +111,10 @@ public class HumanSkeletonWithLegs extends HumanSkeletonWithWaist {
//extendedPelvisModel = server.config.getBoolean("body.model.extendedPelvis", extendedPelvisModel);
extendedKneeModel = server.config.getBoolean("body.model.extendedKnee", extendedKneeModel);
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);
@@ -290,7 +290,7 @@ public class HumanSkeletonWithLegs extends HumanSkeletonWithWaist {
kneeBuf.nlerp(hipBuf, 0.5f);
chestNode.localTransform.getRotation(hipBuf);
kneeBuf.nlerp(hipBuf, 0.3333333f);
waistNode.localTransform.setRotation(kneeBuf);
hipNode.localTransform.setRotation(kneeBuf);
// TODO : Use vectors to add like 50% of wasit tracker yaw to waist node to reduce drift and let user take weird poses
// TODO Set virtual waist node yaw to that of waist node
}
@@ -29,6 +29,7 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
protected final Tracker waistTracker;
protected final Tracker chestTracker;
protected final Tracker hipTracker;
protected final HMDTracker hmdTracker;
protected final ComputedHumanPoseTracker computedWaistTracker;
protected final ComputedHumanPoseTracker computedChestTracker;
@@ -38,12 +39,17 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
protected final TransformNode waistNode = new TransformNode("Waist", false);
protected final TransformNode chestNode = new TransformNode("Chest", false);
protected final TransformNode trackerWaistNode = new TransformNode("Waist-Tracker", false);
protected final TransformNode hipNode = new TransformNode("Hip", false);
protected float chestDistance = 0.42f;
/**
* Distance from eyes to waist
*/
protected float waistDistance = 0.85f;
/**
* Distance from waist to hip
*/
protected float hipDistance = 0f;
/**
* Distance from eyes to waist, defines reported
* tracker position, if you want to move resulting
@@ -63,6 +69,7 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
List<Tracker> allTracekrs = server.getAllTrackers();
this.waistTracker = TrackerUtils.findTrackerForBodyPositionOrEmpty(allTracekrs, TrackerPosition.WAIST, TrackerPosition.CHEST);
this.chestTracker = TrackerUtils.findTrackerForBodyPositionOrEmpty(allTracekrs, TrackerPosition.CHEST, TrackerPosition.WAIST);
this.hipTracker = TrackerUtils.findTrackerForBodyPositionOrEmpty(allTracekrs, TrackerPosition.HIP, TrackerPosition.WAIST);
this.hmdTracker = server.hmdTracker;
this.server = server;
ComputedHumanPoseTracker cwt = null;
@@ -81,6 +88,7 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
neckLength = server.config.getFloat("body.neckLength", neckLength);
chestDistance = server.config.getFloat("body.chestDistance", chestDistance);
waistDistance = server.config.getFloat("body.waistDistance", waistDistance);
hipDistance = server.config.getFloat("body.hipDistance", hipDistance);
trackerWaistDistance = server.config.getFloat("body.trackerWaistDistance", trackerWaistDistance);
// Build skeleton
hmdNode.attachChild(headNode);
@@ -94,15 +102,19 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
chestNode.attachChild(waistNode);
waistNode.localTransform.setTranslation(0, -(waistDistance - chestDistance), 0);
chestNode.attachChild(trackerWaistNode);
trackerWaistNode.localTransform.setTranslation(0, -(waistDistance + trackerWaistDistance - chestDistance), 0);
waistNode.attachChild(hipNode);
hipNode.localTransform.setTranslation(0, -hipDistance, 0);
hipNode.attachChild(trackerWaistNode);
trackerWaistNode.localTransform.setTranslation(0, trackerWaistDistance, 0);
configMap.put("Head", headShift);
configMap.put("Neck", neckLength);
configMap.put("Chest", chestDistance);
configMap.put("Waist", waistDistance);
configMap.put("Virtual waist", trackerWaistDistance);
configMap.put("Hip", hipDistance);
}
@Override
@@ -114,6 +126,7 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
resetSkeletonConfig("Virtual waist");
resetSkeletonConfig("Waist");
resetSkeletonConfig("Chest");
resetSkeletonConfig("Hip");
break;
case "Head":
setSkeletonConfig(joint, HEAD_SHIFT_DEFAULT);
@@ -127,6 +140,9 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
case "Chest":
setSkeletonConfig(joint, waistDistance / 2.0f);
break;
case "Hip":
setSkeletonConfig(joint, 0.0f);
break;
case "Waist": // Puts Waist in the middle of the height
Vector3f vec = new Vector3f();
hmdTracker.getPosition(vec);
@@ -161,19 +177,24 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
waistDistance = newLength;
server.config.setProperty("body.waistDistance", waistDistance);
waistNode.localTransform.setTranslation(0, -(waistDistance - chestDistance), 0);
trackerWaistNode.localTransform.setTranslation(0, -(waistDistance + trackerWaistDistance - chestDistance), 0);
break;
case "Chest":
chestDistance = newLength;
server.config.setProperty("body.chestDistance", chestDistance);
chestNode.localTransform.setTranslation(0, -chestDistance, 0);
waistNode.localTransform.setTranslation(0, -(waistDistance - chestDistance), 0);
trackerWaistNode.localTransform.setTranslation(0, -(waistDistance + trackerWaistDistance - chestDistance), 0);
trackerWaistNode.localTransform.setTranslation(0, trackerWaistDistance, 0);
break;
case "Hip":
hipDistance = newLength;
server.config.setProperty("body.hipDistance", hipDistance);
hipNode.localTransform.setTranslation(0, -hipDistance, 0);
trackerWaistNode.localTransform.setTranslation(0, trackerWaistDistance, 0);
break;
case "Virtual waist":
trackerWaistDistance = newLength;
server.config.setProperty("body.trackerWaistDistance", trackerWaistDistance);
trackerWaistNode.localTransform.setTranslation(0, -(waistDistance + trackerWaistDistance - chestDistance), 0);
trackerWaistNode.localTransform.setTranslation(0, trackerWaistDistance, 0);
break;
}
}
@@ -211,9 +232,16 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
neckNode.localTransform.setRotation(qBuf);
if(waistTracker.getRotation(qBuf)) {
trackerWaistNode.localTransform.setRotation(qBuf);
chestNode.localTransform.setRotation(qBuf);
}
if(hipTracker.getRotation(qBuf)) {
waistNode.localTransform.setRotation(qBuf);
trackerWaistNode.localTransform.setRotation(qBuf);
hipNode.localTransform.setRotation(qBuf);
}
else if(waistTracker.getRotation(qBuf)){
waistNode.localTransform.setRotation(qBuf);
trackerWaistNode.localTransform.setRotation(qBuf);
}
}
@@ -243,6 +271,8 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
this.chestTracker.getRotation(referenceRotation);
this.waistTracker.resetFull(referenceRotation);
this.hipTracker.resetFull(referenceRotation);
}
@Override
@@ -257,5 +287,7 @@ public class HumanSkeletonWithWaist extends HumanSkeleton {
this.chestTracker.getRotation(referenceRotation);
this.waistTracker.resetYaw(referenceRotation);
this.hipTracker.resetYaw(referenceRotation);
}
}
@@ -10,6 +10,7 @@ public enum TrackerPosition {
HMD("HMD", TrackerRole.HMD),
CHEST("body:chest", TrackerRole.CHEST),
WAIST("body:waist", TrackerRole.WAIST),
HIP("body:hip", null),
LEFT_LEG("body:left_leg", TrackerRole.LEFT_KNEE),
RIGHT_LEG("body:right_leg", TrackerRole.RIGHT_KNEE),
LEFT_ANKLE("body:left_ankle", null),