in src/fbx/Fbx2Raw.cpp [676:741]
static void ReadNodeHierarchy(
RawModel& raw,
FbxScene* pScene,
FbxNode* pNode,
const long parentId,
const std::string& path) {
const FbxUInt64 nodeId = pNode->GetUniqueID();
const char* nodeName = pNode->GetName();
const int nodeIndex = raw.AddNode(nodeId, nodeName, parentId);
RawNode& node = raw.GetNode(nodeIndex);
FbxTransform::EInheritType lInheritType;
pNode->GetTransformationInheritType(lInheritType);
std::string newPath = path + "/" + nodeName;
if (verboseOutput) {
fmt::printf("node %d: %s\n", nodeIndex, newPath.c_str());
}
static int warnRrSsCount = 0;
static int warnRrsCount = 0;
if (lInheritType == FbxTransform::eInheritRrSs && parentId) {
if (++warnRrSsCount == 1) {
fmt::printf(
"Warning: node %s uses unsupported transform inheritance type 'eInheritRrSs'.\n",
newPath);
fmt::printf(" (Further warnings of this type squelched.)\n");
}
} else if (lInheritType == FbxTransform::eInheritRrs) {
if (++warnRrsCount == 1) {
fmt::printf(
"Warning: node %s uses unsupported transform inheritance type 'eInheritRrs'\n"
" This tool will attempt to partially compensate, but glTF cannot truly express this mode.\n"
" If this was a Maya export, consider turning off 'Segment Scale Compensate' on all joints.\n"
" (Further warnings of this type squelched.)\n",
newPath);
}
}
// Set the initial node transform.
const FbxAMatrix localTransform = pNode->EvaluateLocalTransform();
const FbxVector4 localTranslation = localTransform.GetT();
const FbxQuaternion localRotation = localTransform.GetQ();
const FbxVector4 localScaling = computeLocalScale(pNode);
node.translation = toVec3f(localTranslation) * scaleFactor;
node.rotation = toQuatf(localRotation);
node.scale = toVec3f(localScaling);
if (parentId) {
RawNode& parentNode = raw.GetNode(raw.GetNodeById(parentId));
// Add unique child name to the parent node.
if (std::find(parentNode.childIds.begin(), parentNode.childIds.end(), nodeId) ==
parentNode.childIds.end()) {
parentNode.childIds.push_back(nodeId);
}
} else {
// If there is no parent then this is the root node.
raw.SetRootNode(nodeId);
}
for (int child = 0; child < pNode->GetChildCount(); child++) {
ReadNodeHierarchy(raw, pScene, pNode->GetChild(child), nodeId, newPath);
}
}