animation3dgltfskinningskeletal-animation

joints in gltf model bunched together on origin during animation


I am generating glTF files from model data in a different, obscure format. I have my joints set up and the inverse bind matrices seem to work when I have no animation tracks. The model, without animations, is assembled and looks correct. When I add animation tracks, all of the joints seem to collapse back to the origin point.

My expectation is that the animation frames would be assembled and played out relative to the skin that each node references, but perhaps this is an incorrect assumption?

Am I supposed to calculate the inverse bind pose for every joint in every frame of every animation? That seems like a very difficult task in that animations only store key frame data and those don't always line up for every joint. Some joints don't have any frames in some animations, for example, but would be expected to remain attached to other joints that do.


Solution

  • It turns out that I was not correctly aligning my per-frame transforms with my inverse bind matrices. Once I corrected my transforms, everything fell into place.

    To provide a bit of context, the source data is misaligned and the models are rotated strangely, where static models such as terrain are sideways and rigged models are face-down. I had written my original transform code for only the static models and forgot to branch the transforms for the rigged models.

    if has_bones then
     pos = { x=x, y=z, z=-y }
     rot = { x=x, y=z, z=-y, w=-w }
     scl = { x=x, y=z, z=y }
    else
     pos = { x=-x, y=z, z=y }
     rot = { x=-x, y=z, z=y, w=-w }
     scl = { x=x, y=z, z=y }
    end