Interpreting matrix values for animations?

Hi there.
Quick question about matrix values for animations. Just wondering how to interpret (make use of) the data I see in the .babylon file.

Two questions:

  1. How can I convert from the matrix data to something i understand better, like rotation data points - as I see in blender? Aka. What do those 16 values represent?
  2. Or better, how could I set that bone to the location/rotation/scale shown in the matrix data?

Below: location/rotation/scale data from Blender and then that same frame/bone as represented in the babylon export.

{"name":"mixamorig:RightForeArm","index":35,"matrix":[0.9932,-0.1148,-0.0193,0,0.1144,0.9933,-0.0169,0,0.0211,0.0145,0.9997,0,0,25.7291,0,1],"rest":[0.9966,-0.0828,0,0,0.0828,0.9966,0,0,0,0,1,0,0,25.7291,0,1],"parentBoneIndex":34,"length":24.1683
    ,"animation":{"dataType":3,"framePerSecond":30,"keys":[
    {"frame":1,"values":[0.9933,-0.1139,-0.0192,0,0.1136,0.9934,-0.0167,0,0.0209,0.0144,0.9997,0,0,25.7291,0,1]},

You can decompose it into its parts, rotationQuaternion, location, & scale. See the Matrix class in mathVector.ts.

Ah, so location and scale have dummy values in the matrix? Those are each Vector3s, right? And there’s another property in there too?

I looked through Babylon.js/math.vector.ts at master · BabylonJS/Babylon.js · GitHub, but don’t see a Matrix class in there. Me just being dumb? Searched through a bunch of other code… but not finding the right thing. [UPDATE: YES, was being dumb. found it there now “export class Matrix”]

I tried setting a a transform node rotationQuaternion to the first four values in the array (and each of the additional sets of 4 values). Didn’t work as expected… but if those are the quaternion values(?), i must have a problem somewhere else. That leg should be pointing forwards! (Also, should be the right leg! Somewhere in the transition between Blender and Babylon, left and right are getting inverted - maybe related to the leg facing backwards? The rotation actually looks correct, just that it’s the wrong leg and facing backwards).

I flipped the model around the Y axis by 1… and it seems a bit better. Just by trial and error, it seems that the 3rd set of values is the rotation Quaternion?

(although still the left leg is moving when i set values for the right side of the armature)

Oh scratch not seeing Matrix class. Was indeed just being dumb. See it there now. Now just looking for the ordering of the properties.

Think i just found the right bit, but confused as to why the third set of values is the only one working for me for setting rotation. Whereas code below shows that it should be the 2nd set of 4 values, right?

     * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
     * @param scale defines the scale vector3
     * @param rotation defines the rotation quaternion
     * @param translation defines the translation vector3
     * @param result defines the target matrix
     */
    public static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void {
        let m = result._m;
        var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
        var x2 = x + x, y2 = y + y, z2 = z + z;
        var xx = x * x2, xy = x * y2, xz = x * z2;
        var yy = y * y2, yz = y * z2, zz = z * z2;
        var wx = w * x2, wy = w * y2, wz = w * z2;

        var sx = scale.x, sy = scale.y, sz = scale.z;

        m[0] = (1 - (yy + zz)) * sx;
        m[1] = (xy + wz) * sx;
        m[2] = (xz - wy) * sx;
        m[3] = 0;

        m[4] = (xy - wz) * sy;
        m[5] = (1 - (xx + zz)) * sy;
        m[6] = (yz + wx) * sy;
        m[7] = 0;

        m[8] = (xz + wy) * sz;
        m[9] = (yz - wx) * sz;
        m[10] = (1 - (xx + yy)) * sz;
        m[11] = 0;

        m[12] = translation.x;
        m[13] = translation.y;
        m[14] = translation.z;
        m[15] = 1;

        result._markAsUpdated();
    }