-
Notifications
You must be signed in to change notification settings - Fork 0
/
fbx.cc
57 lines (49 loc) · 1.81 KB
/
fbx.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "fbx.h"
#include "common.h"
#include <string>
//-----------------------------------------------------------------------------
FBX::FBX(const char* path, const char* destination)
{
std::string out = destination;
int idx = (out.find_last_of(".")) + 1;
std::string ext = out.substr(idx).c_str();
FbxString fbxPath = FbxString(path);
if (fbxPath.IsEmpty() == false)
{
FbxManager* sdkManager = NULL;
FbxScene* scene = NULL;
InitializeSdkObjects(sdkManager, scene);
bool result = LoadScene(sdkManager, scene, fbxPath.Buffer());
if (result == false)
{
FBXSDK_printf("Call to LoadScene() failed.\n");
}
else
{
int format = sdkManager->GetIOPluginRegistry()->FindWriterIDByExtension(ext.c_str());
if (format == 0) // binary fbx
{
format = 1; // ascii fbx
}
FBXSDK_printf("format: %d\n", format);
FbxExporter* exporter = FbxExporter::Create(sdkManager, "");
result = exporter->Initialize(destination, format, sdkManager->GetIOSettings());
if (result)
{
result = exporter->Export(scene);
if (result == false)
{
FBXSDK_printf("Call to FbxExporter::Export() failed.\n");
FBXSDK_printf("Error returned: %s\n\n", exporter->GetStatus().GetErrorString());
}
}
else
{
FBXSDK_printf("Call to FbxExporter::Initialize() failed.\n");
FBXSDK_printf("Error returned: %s\n\n", exporter->GetStatus().GetErrorString());
}
exporter->Destroy();
}
DestroySdkObjects(sdkManager, result);
}
}