Fix skeleton with legs resolution

Fix trackers reset after the first time
This commit is contained in:
Eiren Rain
2021-01-14 04:52:14 +03:00
parent edd3dbd123
commit dda1a43a1c
4 changed files with 20 additions and 6 deletions

View File

@@ -93,18 +93,18 @@ public class HumanPoseProcessor {
Vector3f hmdFront = new Vector3f(0, 0, 1);
hmdRotation.multLocal(hmdFront);
hmdFront.multLocal(1, 0, 1).normalizeLocal();
hmdRotation.lookAt(hmdFront, Vector3f.UNIT_Y);
//hmdRotation.lookAt(hmdFront, Vector3f.UNIT_Y);
Iterator<AdjustedTracker> iterator = trackers.values().iterator();
while(iterator.hasNext()) {
AdjustedTracker tt = iterator.next();
tt.getRotation(sensorRotation);
tt.tracker.getRotation(sensorRotation);
// Adjust only yaw rotation
Vector3f sensorFront = new Vector3f(0, 0, 1);
sensorRotation.multLocal(sensorFront);
sensorFront.multLocal(1, 0, 1).normalizeLocal();
sensorRotation.lookAt(sensorFront, Vector3f.UNIT_Y);
//sensorRotation.lookAt(sensorFront, Vector3f.UNIT_Y);
tt.position.baseRotation.mult(hmdRotation, targetTrackerRotation);

View File

@@ -45,10 +45,10 @@ public class HumanSekeletonWithLegs extends HumanSkeleonWithWaist {
computedRightAnkleTracker = rat;
waistNode.attachChild(leftLegNode);
leftLegNode.localTransform.setTranslation(-hipsWidth / 2, 0, 0);
leftLegNode.localTransform.setTranslation(hipsWidth / 2, 0, 0);
waistNode.attachChild(rightLegNode);
rightLegNode.localTransform.setTranslation(hipsWidth / 2, 0, 0);
rightLegNode.localTransform.setTranslation(-hipsWidth / 2, 0, 0);
leftLegNode.attachChild(leftKneeNode);
leftKneeNode.localTransform.setTranslation(0, -kneeLength, 0);
@@ -74,9 +74,11 @@ public class HumanSekeletonWithLegs extends HumanSkeleonWithWaist {
leftAnkleTracker.getRotation(qBuf);
leftKneeNode.localTransform.setRotation(qBuf);
leftAnkleNode.localTransform.setRotation(qBuf);
rightAnkleTracker.getRotation(qBuf);
rightKneeNode.localTransform.setRotation(qBuf);
rightAnkleNode.localTransform.setRotation(qBuf);
}
@Override

View File

@@ -55,6 +55,7 @@ public class HumanSkeleonWithWaist extends HumanSkeleton {
hmdTracker.getPosition(vBuf);
hmdNode.localTransform.setTranslation(vBuf);
hmdNode.localTransform.setRotation(qBuf);
waistNode.localTransform.setRotation(qBuf);
}
protected void updateComputedTrackers() {

View File

@@ -33,7 +33,18 @@ public class TransformNode {
if(localRotation)
worldTransform.combineWithParent(parent.worldTransform);
else
worldTransform.combineWithParentGlobalRotation(localTransform);
combineWithParentGlobalRotation(parent.worldTransform);
}
}
public void combineWithParentGlobalRotation(Transform parent) {
worldTransform.getScale().multLocal(parent.getScale());
worldTransform.getTranslation().multLocal(parent.getScale());
parent
.getRotation()
.multLocal(worldTransform.getTranslation())
.addLocal(parent.getTranslation());
}
}