I’m currently trying to write a Scene Processor / Reader / Writer to make the art pipeline from Blender into our game a little easier. The intention is to be able to take an FBX exported from Blender and get not only the standard model data from it, but additional information such as lighting, animation, etc.
I’ve seen a lot of code around for doing one of two things:
- Extending the ModelProcessor and adding some additional information (such as animation) to its Tag property.
- Doing a full custom data type with the writer / reader / processor, but it’s always something completely unique to models (Weapon data from an XML for example)
The issue I’m having is that basically I need to do a combination of the two. I need a custom reader, writer, and processor to get the data from the FBX to eventually loading my Scene object in-game.
The processor is pretty simple and easy to work with, I was able to understand and get a rough version of that working without any issues. However, the Reader / Writer parts are giving me issues. The biggest issues I’m running into is the fact that Model-related classes and the ContentTypeReader class has such a large number of internal fields. This prevents me from working with them since all my game-specific code is obviously in my game’s namespace instead of Microsoft.Xna.Framework.Content
So I’m curious if anyone has successfully done a custom content reader / writer that blends custom data and built-in classes such as Model? If so, how have you managed to get around the internal issues?
I got my Writer (mostly) working by simply copying a bulk of the ModelWriter code. The only real issue here was it couldn’t write the BoundingSphere info because that is internal to the Content namespace.
The main issue when trying to do the same thing on the Reader side of things is that the base ContentTypeReader class has internal on its GraphicsDevice field, so anything outside of the Content namespace can’t access this. And since this is one of the required parameters for creating a ModelMesh, I’m unsure of how exactly I could provide this aside from making some otherwise unnecessary dependencies to my Game class from all my custom content classes.
Pretty much all the code I’ve mentioned can be seen in the ModelWriter, ModelReader, and ModelProcessor classes. I’m happy to post my code if anyone thinks it will be helpful, but right now it’s literally just copy / pasted from the Model-related classes and adds one additional test string so I can confirm it working.
TLDR - Does anyone have a working example of a custom reader / writer that uses the Model class?