SDK의 코드를 참조합니다.

4323 단어
거의 한 달 동안 FBX SDK를 부추겼어요.드디어 내게 어울리는 걸 봤군..SDK에서 코드를 찾았는데 비교적 입문적이다.간단하게 스타일을 바꾸면 내 작품이야..이어서 차근차근 공부합시다.그냥 이렇게 copy 코드는 좀 그렇지 않아요?별거 아니야, 어차피 별거 아니니까...
// UseFBXSDK.cpp -- 2014/01/15-21:36
#include "stdafx.h"
#include <fbxsdk.h>

int numTabs = 0; 

void PrintTabs()
{
    for(int i = 0; i < numTabs; i++)
        printf("\t");
}

FbxString GetAttributeTypeName(FbxNodeAttribute::EType type)
{ 
    switch(type)
	{ 
        case FbxNodeAttribute::eUnknown: return "unidentified"; 
        case FbxNodeAttribute::eNull: return "null"; 
        case FbxNodeAttribute::eMarker: return "marker"; 
        case FbxNodeAttribute::eSkeleton: return "skeleton"; 
        case FbxNodeAttribute::eMesh: return "mesh"; 
        case FbxNodeAttribute::eNurbs: return "nurbs"; 
        case FbxNodeAttribute::ePatch: return "patch"; 
        case FbxNodeAttribute::eCamera: return "camera"; 
        case FbxNodeAttribute::eCameraStereo: return "stereo"; 
        case FbxNodeAttribute::eCameraSwitcher: return "camera switcher"; 
        case FbxNodeAttribute::eLight: return "light"; 
        case FbxNodeAttribute::eOpticalReference: return "optical reference"; 
        case FbxNodeAttribute::eOpticalMarker: return "marker"; 
        case FbxNodeAttribute::eNurbsCurve: return "nurbs curve"; 
        case FbxNodeAttribute::eTrimNurbsSurface: return "trim nurbs surface"; 
        case FbxNodeAttribute::eBoundary: return "boundary"; 
        case FbxNodeAttribute::eNurbsSurface: return "nurbs surface"; 
        case FbxNodeAttribute::eShape: return "shape"; 
        case FbxNodeAttribute::eLODGroup: return "lodgroup"; 
        case FbxNodeAttribute::eSubDiv: return "subdiv"; 
        default: return "unknown"; 
    } 
}

void PrintAttribute(FbxNodeAttribute* pAttribute)
{
    if(pAttribute == nullptr)
		return;
 
    FbxString typeName = GetAttributeTypeName(pAttribute->GetAttributeType());
    FbxString attrName = pAttribute->GetName();

    PrintTabs();

    printf("<attribute type='%s' name='%s'/>
", typeName.Buffer(), attrName.Buffer()); } void PrintNode(FbxNode* pNode) { PrintTabs(); const char* nodeName = pNode->GetName(); FbxDouble3 translation = pNode->LclTranslation.Get(); FbxDouble3 rotation = pNode->LclRotation.Get(); FbxDouble3 scaling = pNode->LclScaling.Get(); printf("<node name='%s' translation='(%f, %f, %f)' rotation='(%f, %f, %f)' scaling='(%f, %f, %f)'>
", nodeName, translation[0], translation[1], translation[2], rotation[0], rotation[1], rotation[2], scaling[0], scaling[1], scaling[2] ); numTabs++; for(int i = 0; i < pNode->GetNodeAttributeCount(); i++) PrintAttribute(pNode->GetNodeAttributeByIndex(i)); for(int j = 0; j < pNode->GetChildCount(); j++) PrintNode(pNode->GetChild(j)); numTabs--; PrintTabs(); printf("</node>
"); } int main(int argc, char** argv) { const char* pFilename = "humanoid.fbx"; FbxManager* pSdkManager = FbxManager::Create(); FbxIOSettings *pIOSettings = FbxIOSettings::Create(pSdkManager, IOSROOT); pSdkManager->SetIOSettings(pIOSettings); FbxImporter* lImporter = FbxImporter::Create(pSdkManager,""); if(lImporter->Initialize(pFilename, -1, pSdkManager->GetIOSettings()) == nullptr) { printf("Call to FbxImporter::Initialize() failed.
"); printf("Error returned: %s

", lImporter->GetStatus().GetErrorString()); getchar() ; exit(-1); } FbxScene* pScene = FbxScene::Create(pSdkManager,"myScene"); lImporter->Import(pScene); lImporter->Destroy(); FbxNode* pRootNode = pScene->GetRootNode(); if(pRootNode != NULL) { for(int i = 0; i < pRootNode->GetChildCount(); i++) PrintNode(pRootNode->GetChild(i)); } pSdkManager->Destroy(); getchar() ; return 0; }

좋은 웹페이지 즐겨찾기