XNA 3.0 Content Pipeline
I spent all day researching the XNA Content Pipeline in XNA 3.0. The MSDN documentation is a little sparse/dense on how things work together; so I pulled together some resources that I found helpful when trying to understand it.
There's 4 main components in the Content Pipeline: Importers, Processors, Writers, and Readers. Read the 2nd point to understand how they work together or go through the tutorial in my 1st point to get your hands dirty. The 3rd point is another tutorial to help you understand creating a new game asset from start to finish.
1. Nick Gravelyn wrote a brief tutorial on using XML to describe content. (Update: 11/9/10 Nick's links don't work) It uses the default Content Processor and Importer from XNA for XML and then it creates custom Readers and Writers.
I followed along and got stuck on the project Reference part. There are two sets of references, one for the code and the other for the Content sub-folder in an XNA project. I didn't realize it until I looked very closely at my project. Since I overlooked the Content references I got the following error while trying to build the CrateSprite XML asset.
Building CrateSprite.xml -> C:\Documents and Settings\Paul Solt\My Documents\Visual Studio 2008\Projects\XMLProject\XMLProject\bin\x86\Release\Content\CrateSprite.xnb
Content\CrateSprite.xml(3,10): error : There was an error while deserializing intermediate XML. Cannot find type "XmlContentSampleShared.Sprite".
[ad#Large Box]
The problem is that the reference to the SpriteContentWriter.cs and the Sprite.cs classes are missing (They are in separate projects). To fix it all you need to do is to include the project containing the Writer, which has a reference to the shared project containing the Sprite class. My Content build process just didn't know how to process the CrateSprite.xml file. Here's a picture of the projects and the highlighted references (Right click and add Reference -> Projects).
[caption id="attachment_67" align="aligncenter" width="494" caption="Visual Studio 2008"][/caption]
2. Shawn Hargreaves also recently posted about the basics of the Content Pipeline here. He pulls apart the different steps involved so that you can understand the entire content pipeline using colors. (Shawn Hargreaves is the expert on XNA)
[ad#Link Banner]
He describes why the Content Readers and Writers are separated. Writers help create the .xnb (XNA Binary) format, while readers read in the compiled .xnb format that is packaged with an XNA game. A distributed game doesn't need the Content Writers, so you can separate that functionality into a separate project, while keeping the Content Readers associated with the Game project that gets distributed.
3. Another tutorial I looked into is from Ziggy. He creates a custom game asset (bounding box) and the associated Content Processor, Importer, Reader, and Writer. This tutorial helps drill in the fact that you're creating new content and having XNA interpret it and build it into an asset that your game can load. Very powerful stuff.
I incountered a few differences in the tutorial, since it was written using XNA 1.0, but overall you shouldn't have too many issues following it. (There is a converted XNA 2.0 project for the tutorial if you get stuck)
Update: Here's another useful blog post from Eli Tayrien with a collection of links for the XNA Content Pipeline.
[ad#Large Box]