diff --git a/conanfile.py b/conanfile.py index cb623ec..3e94af3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ from conans import ConanFile, CMake class FBX2glTFConan(ConanFile): settings = "os", "compiler", "build_type", "arch" requires = ( - ("boost/1.76.0"), + ("boost/1.78.0"), ("libiconv/1.15"), ("zlib/1.2.11"), ("libxml2/2.9.12"), diff --git a/src/fbx/Fbx2Raw.cpp b/src/fbx/Fbx2Raw.cpp index 03be3a0..c8acd66 100644 --- a/src/fbx/Fbx2Raw.cpp +++ b/src/fbx/Fbx2Raw.cpp @@ -733,8 +733,31 @@ static void ReadNodeHierarchy( node.rotation = toQuatf(localRotation); node.scale = toVec3f(localScaling); + const FbxVector4 nodeGeometricTranslationPivot = + pNode->GetGeometricTranslation(FbxNode::eSourcePivot); + const FbxVector4 nodeGeometricRotationPivot = pNode->GetGeometricRotation(FbxNode::eSourcePivot); + FbxVector4 nodeGeometricScalePivot = pNode->GetGeometricScaling(FbxNode::eSourcePivot); + if (abs(nodeGeometricScalePivot[0]) < FBXSDK_FLOAT_EPSILON) { + nodeGeometricScalePivot[0] = 1.0; + } + if (abs(nodeGeometricScalePivot[1]) < FBXSDK_FLOAT_EPSILON) { + nodeGeometricScalePivot[1] = 1.0; + } + if (abs(nodeGeometricScalePivot[2]) < FBXSDK_FLOAT_EPSILON) { + nodeGeometricScalePivot[2] = 1.0; + } + FbxAMatrix matrixGeo; + matrixGeo.SetIdentity(); + matrixGeo.SetT(nodeGeometricTranslationPivot); + matrixGeo.SetR(nodeGeometricRotationPivot); + matrixGeo.SetS(nodeGeometricScalePivot); + if (parentId) { RawNode& parentNode = raw.GetNode(raw.GetNodeById(parentId)); + parentNode.translation += toVec3f(matrixGeo.GetT()); + const FbxQuaternion nodeRotation = matrixGeo.GetQ(); + parentNode.rotation = parentNode.rotation * toQuatf(nodeRotation); + parentNode.scale *= toVec3f(matrixGeo.GetS()); // Add unique child name to the parent node. if (std::find(parentNode.childIds.begin(), parentNode.childIds.end(), nodeId) == parentNode.childIds.end()) { @@ -744,9 +767,14 @@ static void ReadNodeHierarchy( // If there is no parent then this is the root node. raw.SetRootNode(nodeId); } - + matrixGeo = matrixGeo.Inverse(); for (int child = 0; child < pNode->GetChildCount(); child++) { ReadNodeHierarchy(raw, pScene, pNode->GetChild(child), nodeId, newPath); + RawNode& childNode = raw.GetNode(child); + childNode.translation += toVec3f(matrixGeo.GetT()); + const FbxQuaternion nodeRotation = matrixGeo.GetQ(); + childNode.rotation = childNode.rotation * toQuatf(nodeRotation); + childNode.scale *= toVec3f(matrixGeo.GetS()); } }