42 std::lock_guard<std::mutex> locker(
m_mutex);
46 LOG_ERROR <<
"Unable to get FBX Animation Source Filename.";
52 if (fbxPos != std::string::npos)
56 auto slashPos = justfileName.rfind(
'\\');
57 if (slashPos == std::string::npos)
58 slashPos = justfileName.rfind(
'/');
59 if (slashPos != std::string::npos)
60 justfileName = justfileName.substr(slashPos + 1);
62 std::string anim_name =
animationName +
" [" + std::to_string(curAnimation.
Index) +
"]";
63 std::string file_name;
66 file_name =
srcfileName +
"_Animations/" + justfileName +
"_" +
71 file_name =
srcfileName +
"_Animations/" + justfileName +
"_" +
74 LOG_INFO <<
"FBX Animation Filename: " << file_name.c_str();
75 auto lastSlash = file_name.rfind(
'/');
76 if (lastSlash != std::string::npos)
78 std::string dirPath = file_name.substr(0, lastSlash);
79 std::filesystem::create_directories(dirPath);
82 FbxManager* lSdkManager = FbxManager::Create();
85 LOG_ERROR <<
"Unable to create the FBX SDK manager for the animation exporter";
89 FbxIOSettings* ios = FbxIOSettings::Create(lSdkManager, IOSROOT);
90 lSdkManager->SetIOSettings(ios);
92 ios->SetBoolProp(EXP_FBX_MATERIAL,
false);
93 ios->SetBoolProp(EXP_FBX_TEXTURE,
false);
94 ios->SetBoolProp(EXP_FBX_EMBEDDED,
false);
95 ios->SetBoolProp(EXP_FBX_SHAPE,
true);
96 ios->SetBoolProp(EXP_FBX_GOBO,
true);
97 ios->SetBoolProp(EXP_FBX_ANIMATION,
true);
98 ios->SetBoolProp(EXP_FBX_GLOBAL_SETTINGS,
true);
100 fbxsdk::FbxExporter* exporter =
nullptr;
101 FbxScene* l_animscene =
nullptr;
104 LOG_ERROR <<
"Unable to create Animation Headers. Aborting Export...";
106 lSdkManager->Destroy();
110 FbxDocumentInfo* sceneInfo = FbxDocumentInfo::Create(lSdkManager,
"SceneInfo");
111 sceneInfo->mTitle = anim_name.c_str();
114 if (!appName.empty())
116 int n = WideCharToMultiByte(CP_UTF8, 0, appName.c_str(),
static_cast<int>(appName.size()),
nullptr, 0,
nullptr,
nullptr);
117 std::string appNameUtf8(n,
'\0');
118 WideCharToMultiByte(CP_UTF8, 0, appName.c_str(),
static_cast<int>(appName.size()), appNameUtf8.data(), n,
nullptr,
nullptr);
119 sceneInfo->mAuthor = appNameUtf8.c_str();
126 int n = WideCharToMultiByte(CP_UTF8, 0, appVer.c_str(),
static_cast<int>(appVer.size()),
nullptr, 0,
nullptr,
nullptr);
127 std::string appVerUtf8(n,
'\0');
128 WideCharToMultiByte(CP_UTF8, 0, appVer.c_str(),
static_cast<int>(appVer.size()), appVerUtf8.data(), n,
nullptr,
nullptr);
129 sceneInfo->mRevision = appVerUtf8.c_str();
132 l_animscene->SetSceneInfo(sceneInfo);
134 std::map<int, FbxNode*> l_boneNodes;
135 FbxNode* l_skeletonNode =
nullptr;
138 FbxNode* root_node = l_animscene->GetRootNode();
139 root_node->AddChild(l_skeletonNode);
146 if (!exporter->Export(l_animscene))
148 LOG_ERROR <<
"Unable to export FBX animation scene.";
150 lSdkManager->Destroy();
153 LOG_INFO <<
"FBX Animation for" << anim_name.c_str() <<
"successfully exported!";
155 lSdkManager->Destroy();
void setValues(FbxString fileVersion, std::string fn, std::string an, WoWModel *m, std::vector< FbxCluster * > bc, FbxNode *&meshnode, int aID, bool uan=false)
Configure the exporter with source model, animation, and output settings.