mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-24 02:51:20 -08:00
Fix neck node and add head shift node
Add separate node for reported waist tracker to move it independently from actual waist
This commit is contained in:
1 parent
1233a425ef
commit
a5b215fbe5
2 files changed
+39
-9
No files matched your search
@@ -23,8 +23,17 @@ public class HumanSekeletonWithLegs extends HumanSkeleonWithWaist {
|
||||
protected final TransformNode rightKneeNode = new TransformNode();
|
||||
protected final TransformNode rightAnkleNode = new TransformNode();
|
||||
|
||||
/**
|
||||
* Distance between centers of both hips
|
||||
*/
|
||||
protected float hipsWidth = 0.3f;
|
||||
/**
|
||||
* Length from waist to knees
|
||||
*/
|
||||
protected float hipLength = 0.86f;
|
||||
/**
|
||||
* Distance from waist to ankle
|
||||
*/
|
||||
protected float ankleLength = 0.42f;
|
||||
|
||||
public HumanSekeletonWithLegs(VRServer server, Map<TrackerBodyPosition, ? extends Tracker> trackers, List<ComputedHumanPoseTracker> computedTrackers) {
|
||||
|
||||
@@ -19,12 +19,29 @@ public class HumanSkeleonWithWaist extends HumanSkeleton {
|
||||
protected final HMDTracker hmdTracker;
|
||||
protected final ComputedHumanPoseTracker computedWaistTracker;
|
||||
protected final TransformNode hmdNode = new TransformNode();
|
||||
protected final TransformNode headNode = new TransformNode();
|
||||
protected final TransformNode neckNode = new TransformNode();
|
||||
protected final TransformNode waistNode = new TransformNode();
|
||||
protected final TransformNode trackerWaistNode = new TransformNode();
|
||||
|
||||
/**
|
||||
* Distance from eyes to waist
|
||||
*/
|
||||
protected float waistDistance = 0.72f;
|
||||
protected float waistSwingMultiplier = 1f;
|
||||
/**
|
||||
* Distance from eyes to waist, defines reported
|
||||
* tracker position, if you want to move resulting
|
||||
* tracker up or down from actual waist
|
||||
*/
|
||||
protected float trackerWaistDistance = 0.65f;
|
||||
/**
|
||||
* Distacne from eyes to the base of the neck
|
||||
*/
|
||||
protected float neckLength = 0.2f;
|
||||
/**
|
||||
* Distance from eyes to ear
|
||||
*/
|
||||
protected float headShift = 0.09f;
|
||||
|
||||
public HumanSkeleonWithWaist(VRServer server, Tracker waistTracker, List<ComputedHumanPoseTracker> computedTrackers) {
|
||||
this.wasitTracker = waistTracker;
|
||||
@@ -38,13 +55,18 @@ public class HumanSkeleonWithWaist extends HumanSkeleton {
|
||||
computedWaistTracker = cwt;
|
||||
cwt.setStatus(TrackerStatus.OK);
|
||||
waistDistance = server.config.getFloat("body.waistDistance", waistDistance);
|
||||
waistSwingMultiplier = server.config.getFloat("body.waistSwingMultiplier", waistSwingMultiplier);
|
||||
// Build skeleton
|
||||
hmdNode.attachChild(neckNode);
|
||||
waistNode.localTransform.setTranslation(0, -neckLength, 0);
|
||||
hmdNode.attachChild(headNode);
|
||||
headNode.localTransform.setTranslation(0, 0, headShift);
|
||||
|
||||
headNode.attachChild(neckNode);
|
||||
neckNode.localTransform.setTranslation(0, -neckLength, 0);
|
||||
|
||||
neckNode.attachChild(waistNode);
|
||||
waistNode.localTransform.setTranslation(0, -waistDistance + neckLength, 0);
|
||||
|
||||
neckNode.attachChild(trackerWaistNode);
|
||||
trackerWaistNode.localTransform.setTranslation(0, -trackerWaistDistance + neckLength, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,18 +81,17 @@ public class HumanSkeleonWithWaist extends HumanSkeleton {
|
||||
hmdTracker.getRotation(qBuf);
|
||||
hmdNode.localTransform.setTranslation(vBuf);
|
||||
hmdNode.localTransform.setRotation(qBuf);
|
||||
headNode.localTransform.setRotation(qBuf);
|
||||
|
||||
wasitTracker.getRotation(qBuf);
|
||||
if(waistSwingMultiplier != 1.0) {
|
||||
// TODO : Adjust waist swing if swing multiplier != 0
|
||||
}
|
||||
|
||||
neckNode.localTransform.setRotation(qBuf);
|
||||
waistNode.localTransform.setRotation(qBuf);
|
||||
trackerWaistNode.localTransform.setRotation(qBuf);
|
||||
}
|
||||
|
||||
protected void updateComputedTrackers() {
|
||||
computedWaistTracker.position.set(waistNode.worldTransform.getTranslation());
|
||||
computedWaistTracker.rotation.set(waistNode.worldTransform.getRotation());
|
||||
computedWaistTracker.position.set(trackerWaistNode.worldTransform.getTranslation());
|
||||
computedWaistTracker.rotation.set(trackerWaistNode.worldTransform.getRotation());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user