Always eliminate the 0.01 factor.

This commit is contained in:
Par Winzell 2018-03-27 14:54:36 -07:00
parent 4ec8c8e34d
commit ca12a38afe
1 changed files with 10 additions and 2 deletions

View File

@ -1422,9 +1422,17 @@ bool LoadFBXFile(RawModel &raw, const char *fbxFileName, const char *textureExte
// Use Y up for glTF // Use Y up for glTF
FbxAxisSystem::MayaYUp.ConvertScene(pScene); FbxAxisSystem::MayaYUp.ConvertScene(pScene);
// Use meters as the default unit for glTF // FBX's internal unscaled unit is centimetres, and if you choose not to work in that unit,
// you will find scaling transfgrms on all the children of the root node. Those transforms are
// superfluous and cause a lot of people a lot of trouble. Luckily we can get rid of them by
// converting to CM here (which just gets rid of the scaling), and then we pre-multiply the
// scale factor into every vertex position (and related attributes) instead.
FbxSystemUnit sceneSystemUnit = pScene->GetGlobalSettings().GetSystemUnit(); FbxSystemUnit sceneSystemUnit = pScene->GetGlobalSettings().GetSystemUnit();
scaleFactor = FbxSystemUnit::m.GetConversionFactorFrom(sceneSystemUnit); if (sceneSystemUnit != FbxSystemUnit::cm) {
FbxSystemUnit::cm.ConvertScene(pScene);
}
// this is always 0.01, but let's opt for clarity.
scaleFactor = FbxSystemUnit::m.GetConversionFactorFrom(FbxSystemUnit::cm);
ReadNodeHierarchy(raw, pScene, pScene->GetRootNode(), 0, ""); ReadNodeHierarchy(raw, pScene, pScene->GetRootNode(), 0, "");
ReadNodeAttributes(raw, pScene, pScene->GetRootNode(), textureLocations); ReadNodeAttributes(raw, pScene, pScene->GetRootNode(), textureLocations);