Meta Avatar Hand Bones -- What coordinate system?
I'm trying to manually convert OVRSkeleton bone transforms to drive Meta Avatars (for testing, I want to drive avatars with pre-recorded input). But the coordinate system seems to be different. It's very difficult to debug because the avatar system's IK defaults to a t-pose when there's anything going wrong.
I'm using a hand tracking input delegate (IOvrAvatarHandTrackingDelegate) and populating the fields. Sometimes I get some sort of motion but the wrists are completely screwed up and other times there is nothing at all (I feel like it is very sensitive to the position of the wrists but I have no clue what coordinate system they are in). I've tried just piping in the local position and rotation directly as well as setting wristPos to the transform of the controllers (because that bone is actually attached to a node that is not stored as a bone in the OVR camera rig).
Any help would be appreciated!
EDIT: I made some progress. I found that the avatars have a root node with scale of z=-1. The wrist position transforms that are to be returned from the hand input delegate serve as the root of the hand and transforming them as follows helps:
Matrix4x4 m = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(1, 1, -1)); // this is the pivot point in whose coordinate system hands actually need to be. Found this by examining the Root node created by avatars
leftWristPose = m.inverse * leftWristPose;
rightWristPose = m.inverse * rightWristPose;
However this still results in backwards fingers (in this photo, I was typing on a keyboard but the fingers are curling upwards toward the avatar's face):
Note that the thumb is on the wrong side of each hand too.
So I tried fixing the bone rotations by rotating the x-axis of the first (proximal) joint of each finger by 180 degrees:
Quaternion rot1 = Quaternion.Euler(180, 0, 0);
_currentTrackingHands.boneRotations[0] = rot1 * _currentTrackingHands.boneRotations[0];
_currentTrackingHands.boneRotations[4] = rot1 * _currentTrackingHands.boneRotations[4];
_currentTrackingHands.boneRotations[7] = rot1 * _currentTrackingHands.boneRotations[7];
_currentTrackingHands.boneRotations[10] = rot1 * _currentTrackingHands.boneRotations[10];
_currentTrackingHands.boneRotations[13] = rot1 * _currentTrackingHands.boneRotations[13];
_currentTrackingHands.boneRotations[17] = rot1 * _currentTrackingHands.boneRotations[17];
_currentTrackingHands.boneRotations[21] = rot1 * _currentTrackingHands.boneRotations[21];
_currentTrackingHands.boneRotations[24] = rot1 * _currentTrackingHands.boneRotations[24];
_currentTrackingHands.boneRotations[27] = rot1 * _currentTrackingHands.boneRotations[27];
_currentTrackingHands.boneRotations[31] = rot1 * _currentTrackingHands.boneRotations[31];
And now we have sausage fingers that are roughly in the correct place and seem to bend correctly.
I've tried numerous other adjustments including pre-rotating the wrist but nothing helps. What is happening here?
