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
2) add the following code to FBXConverter.cpp
And now all my models, static and animated work as expected!
I hope it will be useful.
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->
}
}I hope it will be useful.

