mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-21 01:21:25 -08:00
Align spine yaw with HMD when no spine tracker
issue https://github.com/SlimeVR/SlimeVR-Server/issues/61
This commit is contained in:
1 parent
dadb0bb378
commit
0cd65c825c
1 file changed
+22
-6
@@ -113,6 +113,8 @@ public class SimpleSkeleton extends HumanSkeleton implements SkeletonConfigCallb
|
||||
protected final Vector3f ankleVector = new Vector3f();
|
||||
|
||||
protected final Quaternion kneeRotation = new Quaternion();
|
||||
|
||||
private boolean hasSpineTracker;
|
||||
//#endregion
|
||||
|
||||
//#region Constructors
|
||||
@@ -392,6 +394,8 @@ public class SimpleSkeleton extends HumanSkeleton implements SkeletonConfigCallb
|
||||
Tracker leftElbowTracker = trackerPreUpdate(this.leftElbowTracker);
|
||||
//#endregion
|
||||
|
||||
hasSpineTracker = chestTracker.hasRotation() || waistTracker.hasRotation() || hipTracker.hasRotation();
|
||||
|
||||
if(hmdTracker != null) {
|
||||
if(hmdTracker.getPosition(posBuf)) {
|
||||
hmdNode.localTransform.setTranslation(posBuf);
|
||||
@@ -407,17 +411,29 @@ public class SimpleSkeleton extends HumanSkeleton implements SkeletonConfigCallb
|
||||
headNode.localTransform.setRotation(Quaternion.IDENTITY);
|
||||
}
|
||||
|
||||
if(chestTracker.getRotation(rotBuf1)) {
|
||||
neckNode.localTransform.setRotation(rotBuf1);
|
||||
// Spine
|
||||
if(hasSpineTracker){
|
||||
if(chestTracker.getRotation(rotBuf1)) {
|
||||
neckNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
if(waistTracker.getRotation(rotBuf1)) {
|
||||
chestNode.localTransform.setRotation(rotBuf1);
|
||||
trackerChestNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
if(hipTracker.getRotation(rotBuf1)) {
|
||||
waistNode.localTransform.setRotation(rotBuf1);
|
||||
hipNode.localTransform.setRotation(rotBuf1);
|
||||
trackerWaistNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
}
|
||||
if(waistTracker.getRotation(rotBuf1)) {
|
||||
else if(hmdTracker != null){ // If no spine tracker, allign spine yaw with HMD
|
||||
rotBuf1 = new Quaternion().fromAngles(0, (FastMath.atan2(rotBuf1.getY(), rotBuf1.getW())/2f)*4, 0);
|
||||
neckNode.localTransform.setRotation(rotBuf1);
|
||||
chestNode.localTransform.setRotation(rotBuf1);
|
||||
trackerChestNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
if(hipTracker.getRotation(rotBuf1)) {
|
||||
waistNode.localTransform.setRotation(rotBuf1);
|
||||
trackerWaistNode.localTransform.setRotation(rotBuf1);
|
||||
hipNode.localTransform.setRotation(rotBuf1);
|
||||
trackerWaistNode.localTransform.setRotation(rotBuf1);
|
||||
}
|
||||
|
||||
// Left Leg
|
||||
|
||||
Reference in new issue
Block a user