So what does this here XNA Content Pipeline thingummyjig actually DO, anyway?
I’m going to start off with an example of how you could use it, working entirely with the default XNA importers and processors.
Imagine I’m making a game called “Super Dromedary Racer X”. Let’s pretend I have the following game assets:
I have a .X file containing my main hero character (I didn’t actually make this one myself, just copied it from one of the XNA starter kits).
I built a section of desert landscape using Milkshape 3D, and exported this to a .FBX file.
There was a great sunset yesterday evening, so I went out with my digital camera and captured a .JPG of the sky to use as a background.
I have a .FX file containing a really nifty heat haze effect that someone posted on a developer forum.
Open up Visual Studio C# Express.
Select the “New XNA Game” project template.
Add my asset files to the project, just like I would for C# code files.
Press F6 to build the project, including my asset files.
Ok, I admit it’s not quite that easy! I have to write some code at this point…
ContentManager loader = new ContentManager();
Model myFunkyDude = loader.Load<Model>(“HeroCharacter”);
Model bigEmptyDesert = loader.Load<Model>(“BigEmptyDesert”);
Texture2D background = loader.Load<Texture2D>(“AmazingSunset”);
Effect heatHaze = loader.Load<Effect>(“HeatHaze”);
And there we have it.
This may seem pretty straightforward, but there is actually quite a lot going on behind the scenes:
The content build process is incremental. This means that it only bothers to reconvert my data if I changed it since the last time I built the project.
The Content Pipeline tracks references from one asset to another. For instance if my HeroCharacter.x or BigEmptyDesert.fbx files used any textures, it would notice this and automatically go build those textures as well. Even better, if both meshes happened to use the same texture, it is smart enough to only bother building that texture once.
If there are problems with any of my content, this will be detected at build time, and the errors will show up in Visual Studio just like compile errors from my C# code.
The ContentManager keeps track of object lifespans for me. No more messing around with IDisposable for graphics resources, and it is only a single line of code to free up everything by calling loader.Unload when I reach the end of the level.
But wait, there is more! Everything in the content pipeline is extensible, and we want you to extend it. Stay tuned for details…