Created
January 26, 2017 14:15
-
-
Save peko/5d85a94c311d400398711616ed5dd7f5 to your computer and use it in GitHub Desktop.
Get version of FBX file (FBX SDK based)
This file contains hidden or 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
cmake_minimum_required(VERSION 3.6) | |
project(fbx_version) | |
add_definitions(-DFBXSDK_SHARED) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
set(SOURCE_FILES main.cpp) | |
add_executable(fbx_version ${SOURCE_FILES}) | |
target_link_libraries(fbx_version fbxsdk m rt uuid stdc++ pthread dl) |
This file contains hidden or 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 <iostream> | |
#include <fbxsdk.h> | |
int main(int argc, char** argv) { | |
std::cout << "fbx-version" << std::endl; | |
if(argc < 2 ) { | |
printf("Usage:\n\tfbx-version file.fbx"); | |
return 1; | |
} | |
// Change the following filename to a suitable filename value. | |
const char* lFilename = argv[1]; | |
// Initialize the SDK manager. This object handles memory management. | |
FbxManager* lSdkManager = FbxManager::Create(); | |
// Create the IO settings object. | |
FbxIOSettings *ios = FbxIOSettings::Create(lSdkManager, IOSROOT); | |
lSdkManager->SetIOSettings(ios); | |
// Create an importer using the SDK manager. | |
FbxImporter* lImporter = FbxImporter::Create(lSdkManager,""); | |
// Use the first argument as the filename for the importer. | |
if(!lImporter->Initialize(lFilename, -1, lSdkManager->GetIOSettings())) { | |
printf("Call to FbxImporter::Initialize() failed.\n"); | |
printf("Error returned: %s\n\n", lImporter->GetStatus().GetErrorString()); | |
return 1; | |
} | |
int Major, Minor, Revision; | |
lSdkManager->GetFileFormatVersion(Major, Minor, Revision); | |
printf("Version: %d %d %d\n", Major, Minor, Revision); | |
// Create a new scene so that it can be populated by the imported file. | |
// FbxScene* lScene = FbxScene::Create(lSdkManager,"myScene"); | |
// Import the contents of the file into the scene. | |
// lImporter->Import(lScene); | |
// The file is imported; so get rid of the importer. | |
lImporter->Destroy(); | |
// Print the nodes of the scene and their attributes recursively. | |
// Note that we are not printing the root node because it should | |
// not contain any attributes. | |
// FbxNode* lRootNode = lScene->GetRootNode(); | |
// if(lRootNode) { | |
// for(int i = 0; i < lRootNode->GetChildCount(); i++) | |
// PrintNode(lRootNode->GetChild(i)); | |
// } | |
// Destroy the SDK manager and all the other objects it was handling. | |
lSdkManager->Destroy(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment