To import a file into an FBX scene (i.e., to load the scene with the contents of a file), you must first create an importer object:
// Create an importer
KFbxImporter* lImporter = KFbxImporter::Create(mySdkManager, "");
FBX can import many different kinds of files: FBX files in a binary (or native) format, FBX files in an ASCII format, FBX files using earlier versions of the FBX file format, and some non-FBX file formats, such as Collada. Any file that is to be imported using FBX is called an import file.
const char *ImportFileName; // Full path\filename of the file to be imported
Use the Initialize() method to specify the path and name of the file to be imported.
const bool lImportStatus = lImporter->Initialize(pFilename);
if( !lImportStatus )
...// Problem with the file to be imported
The importer needs to know the file format of the import file. The filename extension is not enough information: for example, an .fbx extension can refer to a binary FBX file or an ASCII FBX file.
int lFileFormat = -1; // File format of the import file
// Detect the file format of the file to be imported
if (!pSdkManager->GetIOPluginRegistry()->DetectFileFormat(
pFilename,
lFileFormat
))
{ // ... Error handling code for “file not recognized”... }
lImporter->SetFileFormat(lFileFormat);