Monday, December 13, 2010

Content Importing in XNA

Geometry Importers and Lights


So, I spent some time looking into the geometry content importers that come standard with XNA.
There are just two - the FBX importer (documentation says they support version 2006.11), and the .X importer.


The X importer in XNA
I've used exporters from 3dsMax 2011, and have tried both binary and ascii versions.  
Viewing the ascii data, it appears the .X file format has slightly fuller support in XNA, but it doesn't seem to support Lights at all (as a data format).  It wraps them in "frames", but doesn't export anything but a matrix, and a "comment", another matrix with no useful data in it.




So lights aren't imported in the .X format... but their transformations are.  Unfortunately that's *all* that's imported.  So you can have a position and direction, but no additional info e.g. color, intensity, attenuation, or shadowmap parameters.


The FBX Format in XNA
The .FBX file format seems to export a lot more information in a structured format (including designations of 'Light' vs object, and all the related properties, color, intensity, attenuation, shadowmap settings).  However XNA's content processor ignores any and all Light data.




(the closest thing to "light" data imported into XNA from FBX is target-type light-target's matrix loaded as one of the model's bones)


Conclusion: both the built in importers *suck* for trying to load in "complete scene" sort of data.


---
So back to looking for how to coax the information out.  I've found an example custom importer at 
http://create.msdn.com/en-US/education/catalog/sample/custom_model_importer
and a custom model format (I'll probably also want it, but maybe don't yet need it) at
http://create.msdn.com/en-US/education/catalog/sample/custom_model_class


So, I think I'll look around to see if anyone's created a more usable Custom Content Importer.  In the meantime, I'm starting to lean towards writing a custom exporter for 3dsmax (yuck!) if only to export Light and Entity information as, say, a xml file (XNA has a built in general purpose xml content importer).


Hmm, but that's all kind of backburner stuff anyway I guess, it kind of fell out of the "Model" class, and checking into instancing support.


Geometry Instancing
Btw, it looks like in theory you could have instancing of Meshes by pointing to the same vertex buffer, offset and length.  In practice the .X exporter for 3dsMax doesn't seem to support it (have to double check).  The FBX format seems to have support for it, but I'm not holding my breath that the XNA importer honors it/implements it correctly.

No comments:

Post a Comment