Get bone transforms than can be used to animate in a custom vertex shader

Godot Version

4.3

HI, I’m basically trying to export an animated mesh from Godot into my own file format, for use in my own direct3d program. I have the non-animated mesh part working fine, with proper vertex data.

but when I try to extract bone poses from animation I can’t seem to do it right.
here is my process:

  1. in script instantiate a scene that contains the model
  2. get mesh data using the MDT… this all works
  3. play model animation, stopping every few frames to update data …
  4. for each “frame” save global_bone_pose for each bone as 2 vectors, rotation and position … I do this for about 8 frames to get a good approximation the of key frames.

now, I can save all the data, load it into me own program an render the mesh fine. but when I try to use the bone transforms, they are clearly wrong. I know my vertex shader works fine, so I think problem is in the actual bones matrix data.

there’s a lot I don’t know about how Godot handles stuff under the hood… is the global_bone_pose actually the final concatenated transform for each bone? I know its relative to the skeleton, but since I’m not transforming the skeleton, I shouldn’t need to worry about this, i dont think…

Any ideas here? thanks…

I think the main problem here is how deal with the transform

in script i do this:

var myTransform : Transform3D = skel.get_bone_global_pose(i)
myTransform = myTransform.affine_inverse()
var gbp : Vector3 = myTransform.origin
var gbr : Vector3 = myTransform.basis.get_euler()

then i write the pos and rotation values to my file…and construct a matrix in directX like this:

r.x = DirectX::XMConvertToRadians(r.x);
r.y = DirectX::XMConvertToRadians(r.y);
r.z = DirectX::XMConvertToRadians(r.z);
matPos = DirectX::XMMatrixTranslation(p.z, p.y, p.x);
matRot = DirectX::XMMatrixRotationRollPitchYaw(r.z, r.y, r.x);
matBones = DirectX::XMMatrixTranspose(matRot * matPos);