// Load an FBX File into the assets void FBXParser::loadFBX(string const & s, Assets& assets){ cout << "Loading fbx file: " << s << endl; // IO Settings object KFbxIOSettings * ios = KFbxIOSettings::Create(lManager, IOSROOT); lManager->SetIOSettings(ios); // Establish importer KFbxImporter * lImporter = KFbxImporter::Create(lManager, ""); // File to import if(!lImporter->Initialize(s.c_str(), -1, lManager->GetIOSettings())){ cout << "Failed on creating FBX Importer." << endl; cout << " Error: " << lImporter->GetLastErrorString() << endl; exit(1); } // Create the scene KFbxScene * lScene = KFbxScene::Create(lManager, s.c_str()); lSceneList.push_back(lScene); // Import scene lImporter->Import(lScene); KFbxNode * lRootNode = lScene->GetRootNode(); traverseElements(assets, *lRootNode, s); lImporter->Destroy(); cout << " Finished loading fbx file." << endl; }
void FBXJSONSerializer::serialize(const std::string& input_filename, const std::string& output_filename) { KFbxSdkManager* manager = KFbxSdkManager::Create(); KFbxIOSettings* ios = KFbxIOSettings::Create(manager, IOSROOT); manager->SetIOSettings(ios); KFbxImporter* importer = KFbxImporter::Create(manager, ""); if(!importer->Initialize(input_filename.c_str(), -1, manager->GetIOSettings())) { std::cerr << "failed to import %s" << input_filename << std::endl; std::cerr << importer->GetLastErrorString() << std::endl; return; } KFbxScene* scene = KFbxScene::Create(manager, "scene"); importer->Import(scene); importer->Destroy(); KFbxNode* root_node = scene->GetRootNode(); KFbxGeometryConverter converter(root_node->GetFbxSdkManager()); Object json_root; Array meshes; this->recurse_over_model(root_node, meshes); json_root["meshes"] = meshes; std::ofstream stream(output_filename.c_str()); Writer::Write(json_root, stream); }
void FBXModel::load(const GraphicsDevice& device, const std::string& filename, unsigned keyframes) { if (effect.resource == 0) effect = Effect::createFromFile<FBXEffect>(device, Config::getValue(ConfigKeys::fbxEffectPath)); defaultTexture = Texture::createFromFile(device, defaultTexturePath); vertexDeclaration = device.createVertexDeclaration(FBXInstance::vertexElements); KFbxSdkManager* sdkManager = KFbxSdkManager::Create(); KFbxIOSettings* ios = KFbxIOSettings::Create(sdkManager, IOSROOT); sdkManager->SetIOSettings(ios); // Create an importer using our sdk manager. KFbxImporter* importer = KFbxImporter::Create(sdkManager, ""); importer->Initialize(filename.c_str(), -1, sdkManager->GetIOSettings()); // Create a new scene so it can be populated by the imported file. KFbxScene* scene = KFbxScene::Create(sdkManager, ""); // Import the contents of the file into the scene. importer->Import(scene); KFbxNode* rootBone = 0; KFbxNode* rootNode = scene->GetRootNode(); KFbxAnimStack* animStack = KFbxCast<KFbxAnimStack>(scene->GetSrcObject(FBX_TYPE(KFbxAnimStack), 0)); KFbxAnimLayer* animLayer = 0; if (animStack) { animLayer = animStack->GetMember(FBX_TYPE(KFbxAnimLayer), 0); scene->GetEvaluator()->SetContext(animStack); } loadBones(rootNode, &rootBone, animLayer); loadMeshes(rootNode, device, KFbxGeometryConverter(sdkManager)); if (animLayer) { for (unsigned i = 0; i <= keyframes; ++i) boneMatricesMap[i] = traverseBones(i, rootBone, Matrix::identity, MatrixCollection(bones.size())); } sdkManager->Destroy(); loaded = true; }
int FBXLoader::Import(char* name) { KFbxSdkManager* manage; KFbxIOSettings* ios; KFbxImporter* import; KFbxScene* scene; KFbxNode* root; int i; Node* Father; Scene* sceneM; sceneM = Scene::GetInstance(); i = 0; manage = KFbxSdkManager::Create(); ios = KFbxIOSettings::Create(manage, IOSROOT); manage->SetIOSettings(ios); import = KFbxImporter::Create(manage, ""); if (!import->Initialize(name, -1, manage->GetIOSettings())) { printf("initialize failed\nerror is %s\n",import->GetLastErrorString()); return (42); } scene = KFbxScene::Create(manage, "MY SCENE"); import->Import(scene); import->Destroy(); root = scene->GetRootNode(); if (root) { this->Root = new Node(); this->Root->SetFather(NULL); this->Root->SetName("root"); while (i < root->GetChildCount()) //papa { Father = new Node(); Root->AddChild(Father); this->PrintNode(root->GetChild(i), Father); ++i; } } sceneM->AddRoot(this->Root); manage->Destroy(); return (0); }
bool CObjReaderFbx::Read() { OBJ_ASSERT(m_pFbxFile); if(!m_pFbxFile) return false; std::string fileName(m_fileName.string()); // Extract native file path string int lMajor, lMinor, lRevision; KString lCurrentTakeName; bool bStatus; MSG_INFO("Parsing .OBJ file '" << fileName << "'."); // Create an importer. KFbxImporter* lImporter = m_pFbxFile->GetFbxSdkManager()->CreateKFbxImporter(); lImporter->SetFileFormat(KFbxImporter::eALIAS_OBJ); // Initialize the importer by providing a filename. if(lImporter->Initialize(fileName.c_str()) == false) { MSG_ERROR("Call to KFbxImporter::Initialize() failed. Error returned: " << lImporter->GetLastErrorString()); if (lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_YET || lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_ANYMORE) { KFbxIO::GetCurrentVersion(lMajor, lMinor, lRevision); lImporter->GetFileVersion(lMajor, lMinor, lRevision); MSG_ERROR("FBX version number for this version of the FBX SDK is " << lMajor << "." << lMinor << "." << lRevision << " \n" << "FBX version number for file '" << m_fileName.string() << "' is " << lMajor << "." << "." << lMinor << "." << lRevision); } return false; } // Import the scene. bStatus = lImporter->Import(*m_pFbxFile->GetFbxScene()); if(!bStatus) { MSG_ERROR("Error importing the 3DS scene: " << lImporter->GetLastErrorString()); return false; } return true; }
bool Model::Load( const char *filename ) { buffer.Create( Video::VF_GENERIC ); KFbxImporter *importer = KFbxImporter::Create( manager, "" ); if( !importer->Initialize( filename, -1, manager->GetIOSettings()) ){ printf( "error loading model %s\n", filename ); return false; } scene = KFbxScene::Create( manager, "scene1" ); importer->Import( scene ); // wtf is this for? bool shit = scene->GetGlobalSettings().SetDefaultCamera( PRODUCER_BOTTOM );//(char *) lCamera->GetName()); // convert axis system (should be done by fbx exporter??) KFbxAxisSystem SceneAxisSystem = scene->GetGlobalSettings().GetAxisSystem(); KFbxAxisSystem OurAxisSystem(KFbxAxisSystem::XAxis, KFbxAxisSystem::ParityOdd, KFbxAxisSystem::RightHanded); if( SceneAxisSystem != OurAxisSystem ) { OurAxisSystem.ConvertScene(scene); } importer->Destroy(); // Get animation names scene->FillAnimStackNameArray( AnimationStackNames ); // identify and triangulate meshes in scene FindMeshes( scene->GetRootNode() ); SetAnimationStack(1); AnimationFrameTime.SetTime(0, 0, 0, 1, 0, scene->GetGlobalSettings().GetTimeMode()); return true; }
SceneObject *FBXLoader::Load(const char *filename){ SceneObject *so = NULL; KFbxScene *scene = KFbxScene::Create(manager, ""); KFbxImporter *importer = KFbxImporter::Create(manager, ""); int fileFormat = -1; const bool fileFormatFound = manager->GetIOPluginRegistry()->DetectReaderFileFormat(filename, fileFormat); if (fileFormatFound) { bool initSuccess = importer->Initialize(filename, fileFormat); if (initSuccess) { bool importSuccess = importer->Import(scene); if (importSuccess) { KFbxNode *node = scene->GetRootNode(); so = parseNode(node); } else { stringstream ss; ss<<"ModelLoad import error "<<importer->GetLastErrorString(); ERROR(ss.str()); } } else { stringstream ss; ss<<"ModelLoad init importer error "<<importer->GetLastErrorString(); ERROR(ss.str()); } } importer->Destroy(); scene->Destroy(); return so; }
bool C3dsReaderFbx::Read() { OBJ_ASSERT(m_pFbxFile); if(!m_pFbxFile) return false; std::string fileName(m_fileName.string()); // Extract native file path string KString lCurrentTakeName; bool lStatus; MSG_INFO("Parsing .3DS file '" << fileName << "'."); // Create an importer. KFbxImporter* lImporter = m_pFbxFile->GetFbxSdkManager()->CreateKFbxImporter(); lImporter->SetFileFormat(KFbxImporter::e3D_STUDIO_3DS); // Initialize the importer by providing a filename. if(lImporter->Initialize(fileName.c_str()) == false) { MSG_ERROR("Call to KFbxImporter::Initialize() failed. Error returned: " << lImporter->GetLastErrorString()); return false; } // Import the scene. lStatus = lImporter->Import(*m_pFbxFile->GetFbxScene()); if(!lStatus) { MSG_ERROR("Error importing the 3DS scene: " << lImporter->GetLastErrorString()); return false; } return true; }
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename) { int lFileMajor, lFileMinor, lFileRevision; int lSDKMajor, lSDKMinor, lSDKRevision; int lFileFormat = -1; bool lStatus; // Get the file version number generate by the FBX SDK. KFbxIO::GetCurrentVersion(lSDKMajor, lSDKMinor, lSDKRevision); // Create an importer. KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager,""); if (!pSdkManager->GetIOPluginRegistry()->DetectFileFormat(pFilename, lFileFormat)) { // Unrecognizable file format. Try to fall back to native format. lFileFormat = pSdkManager->GetIOPluginRegistry()->GetNativeReaderFormat(); } lImporter->SetFileFormat(lFileFormat); // Initialize the importer by providing a filename. const bool lImportStatus = lImporter->Initialize(pFilename); lImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision); if( !lImportStatus ) { Logger::Log(MsgError,"Call to KFbxImporter::Initialize() failed.\n"); Logger::Log(MsgError,"Error returned: %s\n\n", lImporter->GetLastErrorString()); if (lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_YET || lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_ANYMORE) { Logger::Log(MsgError,"FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); Logger::Log(MsgError,"FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); } return false; } Logger::Log(MsgStd,"FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); if (lImporter->IsFBX()) { Logger::Log(MsgStd,"FBX version number for file %s is %d.%d.%d\n", pFilename, lFileMajor, lFileMinor, lFileRevision); // Set the import states. By default, the import states are always set to // true. The code below shows how to change these states. IOSREF.SetBoolProp(IMP_FBX_MATERIAL, true); IOSREF.SetBoolProp(IMP_FBX_TEXTURE, true); IOSREF.SetBoolProp(IMP_FBX_LINK, true); IOSREF.SetBoolProp(IMP_FBX_SHAPE, true); IOSREF.SetBoolProp(IMP_FBX_GOBO, true); IOSREF.SetBoolProp(IMP_FBX_ANIMATION, true); IOSREF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true); } Logger::Log(MsgStd,"Importing the Scene...\n"); // Import the scene. lStatus = lImporter->Import(pScene); if(lStatus == false) { Logger::Log(MsgError,"Failed to import scene.\n"); Logger::Log(MsgError,"Error returned: %s\n\n", lImporter->GetLastErrorString()); } else { Logger::Log(MsgResult,"Scene Successfully Imported.\n"); } // Destroy the importer. lImporter->Destroy(); return lStatus; }
osgDB::ReaderWriter::ReadResult ReaderWriterFBX::readNode(const std::string& filenameInit, const Options* options) const { try { std::string ext(osgDB::getLowerCaseFileExtension(filenameInit)); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; std::string filename(osgDB::findDataFile(filenameInit, options)); if (filename.empty()) return ReadResult::FILE_NOT_FOUND; KFbxSdkManager* pSdkManager = KFbxSdkManager::Create(); if (!pSdkManager) { return ReadResult::ERROR_IN_READING_FILE; } CleanUpFbx cleanUpFbx(pSdkManager); pSdkManager->SetIOSettings(KFbxIOSettings::Create(pSdkManager, IOSROOT)); KFbxScene* pScene = KFbxScene::Create(pSdkManager, ""); // The FBX SDK interprets the filename as UTF-8 #ifdef OSG_USE_UTF8_FILENAME const std::string& utf8filename(filename); #else std::string utf8filename(osgDB::convertStringFromCurrentCodePageToUTF8(filename)); #endif KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager, ""); if (!lImporter->Initialize(utf8filename.c_str(), -1, pSdkManager->GetIOSettings())) { return std::string(lImporter->GetLastErrorString()); } if (!lImporter->IsFBX()) { return ReadResult::ERROR_IN_READING_FILE; } for (int i = 0; i < lImporter->GetTakeCount(); i++) { KFbxTakeInfo* lTakeInfo = lImporter->GetTakeInfo(i); lTakeInfo->mSelect = true; } if (!lImporter->Import(pScene)) { return std::string(lImporter->GetLastErrorString()); } //KFbxAxisSystem::OpenGL.ConvertScene(pScene); // Doesn't work as expected. Still need to transform vertices. if (KFbxNode* pNode = pScene->GetRootNode()) { pScene->SetCurrentTake(pScene->GetCurrentTakeName()); bool useFbxRoot = false; if (options) { std::istringstream iss(options->getOptionString()); std::string opt; while (iss >> opt) { if (opt == "UseFbxRoot") { useFbxRoot = true; } } } osg::ref_ptr<osgAnimation::AnimationManagerBase> pAnimationManager; bool bIsBone = false; int nLightCount = 0; osg::ref_ptr<Options> localOptions = NULL; if (options) localOptions = options->cloneOptions(); else localOptions = new osgDB::Options(); localOptions->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_IMAGES); std::string filePath = osgDB::getFilePath(filename); FbxMaterialToOsgStateSet fbxMaterialToOsgStateSet(filePath, localOptions.get()); std::set<const KFbxNode*> fbxSkeletons; findLinkedFbxSkeletonNodes(pNode, fbxSkeletons); std::map<KFbxNode*, osg::Node*> nodeMap; BindMatrixMap boneBindMatrices; std::map<KFbxNode*, osgAnimation::Skeleton*> skeletonMap; ReadResult res = readFbxNode(*pSdkManager, *pScene, pNode, pAnimationManager, bIsBone, nLightCount, fbxMaterialToOsgStateSet, nodeMap, boneBindMatrices, fbxSkeletons, skeletonMap, *localOptions); if (res.success()) { fbxMaterialToOsgStateSet.checkInvertTransparency(); resolveBindMatrices(*res.getNode(), boneBindMatrices, nodeMap); osg::Node* osgNode = res.getNode(); osgNode->getOrCreateStateSet()->setMode(GL_RESCALE_NORMAL,osg::StateAttribute::ON); osgNode->getOrCreateStateSet()->setMode(GL_NORMALIZE,osg::StateAttribute::ON); if (pAnimationManager.valid()) { if (osgNode->getUpdateCallback()) { osg::Group* osgGroup = new osg::Group; osgGroup->addChild(osgNode); osgNode = osgGroup; } //because the animations may be altered after registering pAnimationManager->buildTargetReference(); osgNode->setUpdateCallback(pAnimationManager.get()); } KFbxAxisSystem fbxAxis = pScene->GetGlobalSettings().GetAxisSystem(); if (fbxAxis != KFbxAxisSystem::OpenGL) { int upSign; KFbxAxisSystem::eUpVector eUp = fbxAxis.GetUpVector(upSign); bool bLeftHanded = fbxAxis.GetCoorSystem() == KFbxAxisSystem::LeftHanded; float fSign = upSign < 0 ? -1.0f : 1.0f; float zScale = bLeftHanded ? -1.0f : 1.0f; osg::Matrix mat; switch (eUp) { case KFbxAxisSystem::XAxis: mat.set(0,fSign,0,0,-fSign,0,0,0,0,0,zScale,0,0,0,0,1); break; case KFbxAxisSystem::YAxis: mat.set(1,0,0,0,0,fSign,0,0,0,0,fSign*zScale,0,0,0,0,1); break; case KFbxAxisSystem::ZAxis: mat.set(1,0,0,0,0,0,-fSign*zScale,0,0,fSign,0,0,0,0,0,1); break; } osg::Transform* pTransformTemp = osgNode->asTransform(); osg::MatrixTransform* pMatrixTransform = pTransformTemp ? pTransformTemp->asMatrixTransform() : NULL; if (pMatrixTransform) { pMatrixTransform->setMatrix(pMatrixTransform->getMatrix() * mat); } else { pMatrixTransform = new osg::MatrixTransform(mat); if (useFbxRoot && isBasicRootNode(*osgNode)) { // If root node is a simple group, put all FBX elements under the OSG root osg::Group* osgGroup = osgNode->asGroup(); for(unsigned int i = 0; i < osgGroup->getNumChildren(); ++i) { pMatrixTransform->addChild(osgGroup->getChild(i)); } pMatrixTransform->setName(osgGroup->getName()); } else { pMatrixTransform->addChild(osgNode); } } osgNode = pMatrixTransform; } osgNode->setName(filenameInit); return osgNode; } } } catch (...) { OSG_WARN << "Exception thrown while importing \"" << filenameInit << '\"' << std::endl; } return ReadResult::ERROR_IN_READING_FILE; }
bool Fbx::LoadScene( KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename ) { int lFileMajor, lFileMinor, lFileRevision; int lSDKMajor, lSDKMinor, lSDKRevision; //int lFileFormat = -1; int i, lTakeCount; KString lCurrentTakeName; bool lStatus; char lPassword[1024]; // Get the file version number generate by the FBX SDK. KFbxSdkManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision); // Create an importer. KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager,""); // Initialize the importer by providing a filename. const bool lImportStatus = lImporter->Initialize(pFilename); lImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision); if( !lImportStatus ) { printf("Call to KFbxImporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", lImporter->GetLastErrorString()); if (lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_YET || lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_ANYMORE) { printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); } return false; } printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); if (lImporter->IsFBX()) { printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); // From this point, it is possible to access take information without // the expense of loading the entire file. printf("Take Information\n"); lTakeCount = lImporter->GetTakeCount(); printf(" Number of takes: %d\n", lTakeCount); printf(" Current take: \"%s\"\n", lImporter->GetCurrentTakeName()); printf("\n"); for(i = 0; i < lTakeCount; i++) { KFbxTakeInfo* lTakeInfo = lImporter->GetTakeInfo(i); printf(" Take %d\n", i); printf(" Name: \"%s\"\n", lTakeInfo->mName.Buffer()); printf(" Description: \"%s\"\n", lTakeInfo->mDescription.Buffer()); // Change the value of the import name if the take should be imported // under a different name. printf(" Import Name: \"%s\"\n", lTakeInfo->mImportName.Buffer()); // Set the value of the import state to false if the take should be not // be imported. printf(" Import State: %s\n", lTakeInfo->mSelect ? "true" : "false"); printf("\n"); } // Set the import states. By default, the import states are always set to // true. The code below shows how to change these states. IOSREF.SetBoolProp(IMP_FBX_MATERIAL, true); IOSREF.SetBoolProp(IMP_FBX_TEXTURE, true); IOSREF.SetBoolProp(IMP_FBX_LINK, true); IOSREF.SetBoolProp(IMP_FBX_SHAPE, true); IOSREF.SetBoolProp(IMP_FBX_GOBO, true); IOSREF.SetBoolProp(IMP_FBX_ANIMATION, true); IOSREF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true); } // Import the scene. lStatus = lImporter->Import(pScene); if(lStatus == false && lImporter->GetLastErrorID() == KFbxIO::ePASSWORD_ERROR) { printf("Please enter password: "******"%s", lPassword); KString lString(lPassword); IOSREF.SetStringProp(IMP_FBX_PASSWORD, lString); IOSREF.SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true); lStatus = lImporter->Import(pScene); if(lStatus == false && lImporter->GetLastErrorID() == KFbxIO::ePASSWORD_ERROR) { printf("\nPassword is wrong, import aborted.\n"); } } // Destroy the importer. lImporter->Destroy(); return lStatus; }
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename) { int lFileMajor, lFileMinor, lFileRevision; int lSDKMajor, lSDKMinor, lSDKRevision; //int lFileFormat = -1; int i, lAnimStackCount; bool lStatus; char lPassword[1024]; // Get the file version number generate by the FBX SDK. KFbxSdkManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision); // Create an importer. KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager,""); // Initialize the importer by providing a filename. const bool lImportStatus = lImporter->Initialize(pFilename, -1, pSdkManager->GetIOSettings()); lImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision); if( !lImportStatus ) { common->Warning("Call to KFbxImporter::Initialize() failed.\n"); common->Warning("Error returned: %s\n\n", lImporter->GetLastErrorString()); if (lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_YET || lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_ANYMORE) { common->Printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); common->Printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); } return false; } common->Printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); if (lImporter->IsFBX()) { common->Printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); // From this point, it is possible to access animation stack information without // the expense of loading the entire file. common->Printf("Animation Stack Information\n"); lAnimStackCount = lImporter->GetAnimStackCount(); common->Printf(" Number of Animation Stacks: %d\n", lAnimStackCount); common->Printf(" Current Animation Stack: \"%s\"\n", lImporter->GetActiveAnimStackName().Buffer()); common->Printf("\n"); for(i = 0; i < lAnimStackCount; i++) { KFbxTakeInfo* lTakeInfo = lImporter->GetTakeInfo(i); common->Printf(" Animation Stack %d\n", i); common->Printf(" Name: \"%s\"\n", lTakeInfo->mName.Buffer()); common->Printf(" Description: \"%s\"\n", lTakeInfo->mDescription.Buffer()); // Change the value of the import name if the animation stack should be imported // under a different name. common->Printf(" Import Name: \"%s\"\n", lTakeInfo->mImportName.Buffer()); // Set the value of the import state to false if the animation stack should be not // be imported. common->Printf(" Import State: %s\n", lTakeInfo->mSelect ? "true" : "false"); common->Printf("\n"); } // Set the import states. By default, the import states are always set to // true. The code below shows how to change these states. IOS_REF.SetBoolProp(IMP_FBX_MATERIAL, true); IOS_REF.SetBoolProp(IMP_FBX_TEXTURE, true); IOS_REF.SetBoolProp(IMP_FBX_LINK, true); IOS_REF.SetBoolProp(IMP_FBX_SHAPE, true); IOS_REF.SetBoolProp(IMP_FBX_GOBO, true); IOS_REF.SetBoolProp(IMP_FBX_ANIMATION, true); IOS_REF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true); } // Import the scene. lStatus = lImporter->Import(pScene); if(lStatus == false && lImporter->GetLastErrorID() == KFbxIO::ePASSWORD_ERROR) { common->Warning("Password protected FBX files not supported\n"); return false; } // Destroy the importer. lImporter->Destroy(); return lStatus; }