Need help with armature export format

I’m trying to write an export script for Unreal Tournament PSK format, but I’m having trouble figuring out the rotations for the psk format. As a test, I made a copy of the armature by hand and exported it with the blender2cal3d script to compare the Loc and Quat values to the psk files. My hand made armature wasn’t exactly the same as the PSK armature, but it is close enough to make a comparison
Here is the output for the spine part. It is mostly straight up, curving slightly back:

PSK file:
            indx Prnt   LocX    LocY    LocZ     Qx      Qy      Qz      Qw
Bip01         0   0  -0.0500  2.7298  128.04  0.0309  0.0309 -0.7064  0.7064
Bip01 Pelvis  1   0  -0.1303  0.0000  1.4879  0.5000  0.5000  0.5000  0.5000
Bip01 Spine   2   1  12.6638 -0.0163  0.0000  0.0000  0.0000 -0.0004  1.0000
Bip01 Spine1  3   2  20.4141 -0.0157  0.0000  0.0000  0.0000  0.1262  0.9920
Bip01 Spine2  4   3  20.4152 -0.0160  0.0000  0.0000  0.0000  0.0915  0.9958
Bip01 Neck    5   4  20.4215 -0.0065  0.0000  0.0000  0.0000 -0.2362  0.9717
Bip01 Head    6   5   9.1138  0.0000  0.0000  0.0000  0.0000 -0.0562  0.9984
Dummy13       7   6  22.8577  0.0000  0.0000  0.0000  0.0000  0.0000  1.0000


Blender2cal3d output:
            indx Prnt   LocX    LocY    LocZ     Qx      Qy      Qz      Qw
Bip01         0   0   1.2408 -1.1826  128.20  0.5164  0.5129  0.4816 -0.4882
Bip01 Pelvis  1   0   0.0000  1.5906  0.0000  0.0117  0.0001  0.0029 -0.9999
Bip01 Spine   2   1   0.0000 12.6667  0.0000  0.0010  0.0000 -0.0011 -1.0000
Bip01 Spine1  3   2   0.0000 20.2750  0.0000 -0.1229  0.0000 -0.0003 -0.9924
Bip01 Spine2  4   3   0.0000 20.4055  0.0000 -0.0984 -0.0001  0.0006 -0.9951
Bip01 Neck    5   4   0.0000 20.3442  0.0000  0.2434 -0.0005  0.0026 -0.9699
Bip01 Head    6   5   0.0000  9.0964  0.0000  0.0583 -0.0004 -0.0029 -0.9983
Dummy13       7   6   0.0000 22.4992  0.0000 -0.1245  0.0000  0.0000 -0.9922

As you can see the values are mostly the same, but they are swapped. Mostly the psk LocX = cal3d LocY, but not bones 1 and 2. Same with the rotations, mostly psk Qz = cal3d Qx, but not for all the bones.
Can anyone help me figure out how these psk rotations are calculated?

-I think it depends from bonematrix function in blender2cal3d.
I’ve used for some time in the DXexporter and noticed this problem.
Anyway, the new Blender 2.34 has bone.getRestMatrix() which works
correctly.

Ben

My problem is not with Blender. I need help figuring out how the Quats and Locs were calculated for the PSK file. I included the Blender2cal3d output as a comparison to the PSK data. The Blender2cal3d output contains the expected values (approximately) as generated with Blender. I cannot figure out how the PSK values were calculated. I’ve tried using global and local coordinates, no rotation, local rotation and recursive rotation, but I cannot get results similar to the data in the PSK file.

My goal is to import the armature from an existing PSK file. Create a new mesh, link it to the imported armature, then export to a new PSK file. The new PSK file could then be imported into the game and use existing animations. I have the mesh portion working, but I’m stuck on the armature.