Workaround: XNA 4 importing only part of 3d model from FBX

Posted by Vitus on Geeks with Blogs See other posts from Geeks with Blogs or by Vitus
Published on Sun, 19 Jun 2011 11:01:42 GMT Indexed on 2011/06/20 16:24 UTC
Read the original article Hit count: 436

Filed under:

Recently I found a problem with importing 3D models from FBX files: it sometimes imported partly. That is when you draw a 3D model, loaded from FBX file, processed by content pipeline, you got only part of meshes. “Sometimes” means that you got this error only for some files. Results of my research below.

For example, I have 10Mb binary FBX file with a model, looks like:

And when I load it, result Model instance contains only part of meshes and looks like:

Because models from other files imported normally, I think that it’s a “bad format” file.

When you add FBX file to your XNA Content project and build it, imported file processing by XNA Fbx Importer & Processor. On MSDN I found that FbxImporter designed to work with 2006.11 version of FBX format. My file is FBX 2012 format.

Ok, I need to convert it to 2006 format. It can be done by using Autodesk FBX Converter 2012.1. I tried to convert it to other versions of FBX formats, but without success.

And I also tried to import my FBX file to 3D MAX, and it imported correctly. Then I export model using 3D MAX, and it generate me other FBX, which I add to my XNA project. After that I got full model, that rendered well!

So, internal data structure of FBX file is more important for right XNA import, than it version!

Unfortunately, Autodesk FBX is not an open file format. If you want to work with FBX, you should use Autodesk FBX SDK. This way you can manually read content of FBX file, and use it everyway.

Then I tried to convert my source FBX file to DAE Collada, and result DAE file back to FBX, using FBX Converter (FBX –> DAE –> FBX). The result FBX file can be imported normally.

 

Conclusion:

  1. XNA FbxImporter correct work doesn't depend on version (2006, 2011, etc) and form (binary, ascii) of FBX file. Internal FBX data structure much more important.
  2. To make FBX "readable" for XNA Importer you can use double conversion like FBX -> Collada -> FBX
  3. You also can use FBX SDK to manually load data from FBX

P.S. Autodesk FBX Converter 2012 is more, than simple converter. It provide you tools like:

  • FBX Explorer, which show you structure of FBX file;
  • FBX Viewer, which render content of FBX and provide basic intercation like model move and zoom;
  • FBX Take Manager, which allow to work with embedded animations

© Geeks with Blogs or respective owner