Skip to content

Instantly share code, notes, and snippets.

@fereria
Created February 23, 2020 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fereria/7d3f43f18876113b3441a21cd1886173 to your computer and use it in GitHub Desktop.
Save fereria/7d3f43f18876113b3441a21cd1886173 to your computer and use it in GitHub Desktop.
#define NOMINMAX
#include "classTest.h"
#include <iostream>
#include <string>
using namespace std;
void
ClassTest::getRecursiveNode(FbxNode* pNode, FbxArray<FbxNode*>& nodeArray) {
nodeArray.Add(pNode);
int childNodeNum = pNode->GetChildCount();
for (int i = 0; i < childNodeNum; i++) {
FbxNode* pChild = pNode->GetChild(i);
getRecursiveNode(pChild, nodeArray);
}
}
void
ClassTest::getFullNodePath(FbxNode* cNode, string& DAGPath) {
FbxNode* pNode = cNode->GetParent();
if (pNode) {
getFullNodePath(pNode, DAGPath);
string currentNodeName(cNode->GetName());
DAGPath = DAGPath + "/" + currentNodeName;
}
}
ClassTest::ClassTest(char* fbxFile) {
//コンストラクタでシーンをロードする
this->fbxFile = fbxFile;
this->manager = FbxManager::Create();
FbxIOSettings* ioSettings = FbxIOSettings::Create(manager, IOSROOT);
FbxImporter* importer = FbxImporter::Create(manager, "");
importer->Initialize(this->fbxFile, -1, manager->GetIOSettings());
// Fbxにシーンをロード
this->scene = FbxScene::Create(manager, "scene");
importer->Import(scene);
importer->Destroy();
}
ClassTest::~ClassTest() {
// デストラクタのときにmanagerをDestroyする
this->manager->Destroy();
}
void
ClassTest::showSkeletonNodeTree() {
FbxNode* rootNode = this->scene->GetRootNode();
for (int i = 0; i < rootNode->GetChildCount(); i++) {
FbxNode* childNode = rootNode->GetChild(i);
FbxSkeleton* skel = childNode->GetSkeleton();
// Skeletonだった場ののみ処理
if (skel) {
FbxArray<FbxNode*>* nodes = new FbxArray<FbxNode*>();
getRecursiveNode(childNode, *nodes);
for (int j = 0; j < nodes->Size(); j++) {
string skelPath = "";
getFullNodePath(nodes->GetAt(j), skelPath);
cout << skelPath << endl;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment