Пример #1
0
//-------------------------------------------------------------------------------------------------------------------------------------------
Model* FBXReader::LoadModel(){
    // Check blank file name
    if (FileName == ""){
        throw Exception("Filename could not be blank");
    }

    // Check file exists  
    std::ifstream file(FileName.c_str());
    if (!file.good()){
        throw Exception("File does not exist or access (please check if current file is used by another program !");
    }

    FbxManager* sdkManager = NULL;
    FbxScene* scene = NULL;
    bool loadSceneResult;
    initializeSdkObjects(sdkManager, scene);
    loadSceneResult = loadScene(sdkManager, scene, FileName);

    Model* fbxModel = NULL;
    if (loadSceneResult == false){
        throw Exception("An error occurred while loading the scene...");
    }
    else{
        transferDataFromSceneToModel(scene, fbxModel);
    }  
    
    LOG_DEBUG << "Load model successfully! " << "File's name: " << FileName;
    return fbxModel;
}
Пример #2
0
/*
Import the scene
*/
void SceneImporter::import()
{
	initializeSdkObjects(mSdkManager, mScene);
	if (mSdkManager)
	{
		// Create the importer.
		int lFileFormat = -1;
		mImporter = FbxImporter::Create(mSdkManager, "");
		if (!mSdkManager->GetIOPluginRegistry()->DetectReaderFileFormat(mFileName, lFileFormat))
		{
			// Unrecognizable file format. Try to fall back to FbxImporter::eFBX_BINARY
			lFileFormat = mSdkManager->GetIOPluginRegistry()->FindReaderIDByDescription("FBX binary (*.fbx)");;
		}

		// Initialize the importer by providing a filename.
		if (mImporter->Initialize(mFileName, lFileFormat) == true)
		{
			loadFile();
		}
		else
		{
		}
	}
	else
	{
	}
}