Created
February 14, 2020 17:31
-
-
Save fereria/fff368107dbc3f359fbc2ebad3b49f62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fbxsdk.h" | |
#include <iostream> | |
using namespace std; | |
template<typename TYPE> | |
void printNode(TYPE *pNode) | |
{ | |
const char *nodeName = pNode->GetName(); | |
cout << nodeName << endl; | |
} | |
void RecursiveNode(FbxNode *pNode) | |
{ | |
int childNodeNum = pNode->GetChildCount(); | |
for (int i = 0; i < childNodeNum; i++) | |
{ | |
FbxNode *pChild = pNode->GetChild(i); | |
RecursiveNode(pChild); | |
} | |
} | |
void fbxTest_01() | |
{ | |
/* | |
再帰でシーンをパースする | |
*/ | |
char *fbxFile = "D:/work/data_sample/xbot.fbx"; | |
FbxManager *manager = FbxManager::Create(); | |
FbxIOSettings *ioSettings = FbxIOSettings::Create(manager, IOSROOT); | |
FbxImporter *importer = FbxImporter::Create(manager, ""); | |
importer->Initialize(fbxFile, -1, manager->GetIOSettings()); | |
// Fbxにシーンをロード | |
FbxScene *scene = FbxScene::Create(manager, "scene"); | |
importer->Import(scene); | |
importer->Destroy(); | |
FbxNode *rootNode = scene->GetRootNode(); | |
RecursiveNode(rootNode); | |
manager->Destroy(); | |
} | |
void fbxTest_02() | |
{ | |
char *fbxFile = "D:/work/data_sample/mat_sample.fbx"; | |
FbxManager *manager = FbxManager::Create(); | |
FbxIOSettings *ioSettings = FbxIOSettings::Create(manager, IOSROOT); | |
FbxImporter *importer = FbxImporter::Create(manager, ""); | |
importer->Initialize(fbxFile, -1, manager->GetIOSettings()); | |
// Fbxにシーンをロード | |
FbxScene *scene = FbxScene::Create(manager, "scene"); | |
importer->Import(scene); | |
importer->Destroy(); | |
// マテリアル取得 | |
int matCount = scene->GetSrcObjectCount<FbxSurfaceMaterial>(); | |
cout << matCount << endl; | |
for(int i = 0;i<matCount;i++) | |
{ | |
FbxSurfaceMaterial *mat = scene->GetSrcObject<FbxSurfaceMaterial>(i); | |
//Standard Material Property Names 内の名前で、Propertyを探せる (sBump 等) | |
FbxProperty prop = mat->FindProperty(FbxSurfaceMaterial::sAmbient); | |
FbxDouble3 color = prop.Get<FbxDouble3>(); | |
cout << color[0] << "," << color[1] << "," << color[2] << endl; | |
FbxProperty prop_sModel = mat->FindProperty(FbxSurfaceMaterial::sShadingModel); | |
cout << prop_sModel.Get<FbxString>() << endl; | |
} | |
manager->Destroy(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment