1
\$\begingroup\$

I have downloaded FBX animations from Mixamo.com for use in game.

But seems like the "root" skeleton bone does not have translations in Z axis; which makes animations like climbing a ladder or ledge unusable in game engine.

The animation file does not have any mesh data and has just one animation layer.

So I am trying to write a small utility application using FBX SDK 2017.1 that will:

  1. Read an FBX file that I got from Mixamo.com
  2. For each keyframe translate the root skeleton bone to always maintain an offset in Z direction from pelvis bone
  3. The above step will make the skeleton hierarchy jump due to root bone being translated. So in this step I want to recursively set pelvis bone at an offset for each key frame
    1. Export the edited scene into an FBX file

Here's a code snippet

for (int keyIndex = numKeys-1; keyIndex >= 0; keyIndex--)
    {
        // For each key frame fix the Z transform for ROOT bone
        // Similar loop for PELVIS bone
        FbxAnimCurveKey pRootAnimKey = pRootAnimCurve->KeyGet(keyIndex);

        pRootAnimCurve->KeyModifyBegin();
            float originalValue = pRootAnimKey.GetValue();  // for debugging purposes
            float fixValue = 0.0f;
            FbxAnimCurve *pPelvisAnimCurve = pPelvisBone->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
            if (pPelvisAnimCurve != NULL) {
                FbxAnimCurveKey pPelvisAnimKey = pPelvisAnimCurve->KeyGet(animKeyIndex);
                // this "delta" can be a +ve or -ve value calculated from skeleton's Rest/T-pose
                fixValue = pPelvisAnimKey.GetValue() + delta;

                pAnimCurve->KeySetValue(keyIndex, fixValue);
            }

        pAnimCurve->KeyModifyEnd();
    }

Here's what my problem look like

I want the root bone to stay in between legs at an offset from pelvis bone, just as it is in rest T-pose.

Issue is that the exported file does have root bone follow pelvis bone's Z translation but after second loop is run and the file is exported my pelvis bone does not seem to follow root bone. I have tried doing once conversion at a time i.e.

  1. BUGGY animation -> FBX with root following pelvis bone
  2. (1) -> pelvis following root bone

any ideas how to fix this?

There are ways to download mixamo animations without root bone i.e. pelvis is the root bone in that case and manually edit animation in Autodesk Maya to make it work. But I have 2400+ animations that needs to be fixed, so that would be a lot time consuming.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.