FBX animation problem
#14
This is almost fixed in version 5.4
But you need to change something so that it works as it should
1) Change AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS to false
Code:
mSettings.preservePivots = pImp->GetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);

2) add the following code to FBXConverter.cpp
Code:
    ConvertGlobalSettings();
    FixSceneRotation(out); // insert before  TransferDataToScene
    TransferDataToScene();
/*
*  Imported Model is rotated by 90 degrees
*  https://github.com/assimp/assimp/issues/849#issuecomment-875475292
*/
void FBXConverter::FixSceneRotation(const aiScene *pScene) {
    if (pScene->mMetaData) {
        int32_t UpAxis = 1, UpAxisSign = 1, FrontAxis = 2, FrontAxisSign = 1, CoordAxis = 0, CoordAxisSign = 1;
        double UnitScaleFactor = 1.0;
        for (unsigned MetadataIndex = 0; MetadataIndex < pScene->mMetaData->mNumProperties; ++MetadataIndex) {
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "UpAxis") == 0) {
                pScene->mMetaData->Get<int32_t>(MetadataIndex, UpAxis);
            }
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "UpAxisSign") == 0) {
                pScene->mMetaData->Get<int32_t>(MetadataIndex, UpAxisSign);
            }
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "FrontAxis") == 0) {
                pScene->mMetaData->Get<int32_t>(MetadataIndex, FrontAxis);
            }
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "FrontAxisSign") == 0) {
                pScene->mMetaData->Get<int32_t>(MetadataIndex, FrontAxisSign);
            }
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "CoordAxis") == 0) {
                pScene->mMetaData->Get<int32_t>(MetadataIndex, CoordAxis);
            }
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "CoordAxisSign") == 0) {
                pScene->mMetaData->Get<int32_t>(MetadataIndex, CoordAxisSign);
            }
            if (strcmp(pScene->mMetaData->mKeys[MetadataIndex].C_Str(), "UnitScaleFactor") == 0) {
                pScene->mMetaData->Get<double>(MetadataIndex, UnitScaleFactor);
            }
        }

        aiVector3D upVec, forwardVec, rightVec;

        upVec[UpAxis] = UpAxisSign * (float)UnitScaleFactor;
        forwardVec[FrontAxis] = FrontAxisSign * (float)UnitScaleFactor;
        rightVec[CoordAxis] = CoordAxisSign * (float)UnitScaleFactor;

        aiMatrix4x4 mat(rightVec.x, rightVec.y, rightVec.z, 0.0f,
                upVec.x, upVec.y, upVec.z, 0.0f,
                forwardVec.x, forwardVec.y, forwardVec.z, 0.0f,
                0.0f, 0.0f, 0.0f, 1.0f);
        pScene->mRootNode->mTransformation = mat;
        //pScene->mRootNode->
    }
}
And now all my models, static and animated work as expected!
I hope it will be useful.
  


Messages In This Thread
FBX animation problem - by Alex3d - 12-06-2018, 10:51 AM
RE: FBX animation problem - by abenedik - 12-12-2018, 06:38 PM
RE: FBX animation problem - by Alex3d - 02-21-2019, 03:53 PM
RE: FBX animation problem - by abenedik - 02-22-2019, 02:40 PM
RE: FBX animation problem - by Alex3d - 06-26-2019, 12:47 PM
RE: FBX animation problem - by abenedik - 08-27-2019, 12:49 PM
RE: FBX animation problem - by Alex3d - 09-24-2019, 04:49 PM
RE: FBX animation problem - by abenedik - 09-26-2019, 09:30 AM
RE: FBX animation problem - by Alex3d - 09-26-2019, 10:12 AM
RE: FBX animation problem - by abenedik - 10-02-2019, 06:08 PM
RE: FBX animation problem - by Alex3d - 11-27-2021, 12:09 PM
RE: FBX animation problem - by abenedik - 12-07-2021, 10:44 AM
RE: FBX animation problem - by abenedik - 07-07-2023, 10:50 AM
RE: FBX animation problem - by Alex3d - 04-08-2024, 03:02 AM
RE: FBX animation problem - by Alex3d - 04-08-2024, 03:12 AM
RE: FBX animation problem - by abenedik - 04-08-2024, 10:06 AM
RE: FBX animation problem - by Alex3d - 04-10-2024, 03:37 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)