What to extend in the content pipeline
A cheat sheet listing some common content pipeline extensibility patterns
"I want to tweak my content in some way"
- Change the format or size of my textures
- Apply a custom effect to my models
- Convert a texture into a heightfield mesh
Solution: implement a custom ContentProcessor, either from scratch or by deriving from one of the built-in ones.
"I want to attach custom data to my content"
- Store a collision skin along with my model
- Store animation data along with my model
Solution: implement a custom ContentProcessor, deriving from one of
the built-in ones. Override the Process method, and after you chain to
the base class implementation, store your custom information in the Tag
property of the output object.
If your custom data is not already a supported pipeline type, you
will also need to implement a ContentTypeWriter and ContentTypeReader
for it. I'll blog more about that sometime soon.
"I want to add a new content pipeline output type"
- The built-in Model class doesn't support everything I need, so I want to implement my own replacement.
Solution: implement a custom ContentProcessor, ContentTypeWriter, and ContentTypeReader.
"I want to support a new input file format"
- For some crazy reason I'm using Deluxe Paint on the Amiga to draw
my textures, so I want to be able to import them from Amiga .lbm files.
Solution: implement a custom ContentImporter.
"I want to read game data from XML files"
- Mission descriptions
- AI or physics settings
- Configuration data for a particle system
Solution: wrap your XML data in <XnaContent> and <Asset>
tags. Add the XML file to C# Express, go to the properties for this
file and set "XNA Framework Content" to true, then choose the "XML
Content Importer" and "No Processing Required". Finally, implement a
ContentTypeWriter and ContentTypeReader for your custom type.
"I want to use fractals to compute the ultimate meaning of life"
Yeah, me too...