Splashing around on the surface

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.

What next?

  • 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…

Comments (9)

  1. noxa says:

    Great post! I’m interested in the whole ContentManager thing – can’t wait until the beta!

  2. Shawn’s blog gives up the information on how the Content Pipeline will really work, no more hints or…

  3. JoelMartinez says:

    Wow, that sounds pretty darn awesome … just for the sake of discussion, how many ContentManagers can you have active at once?  I wonder because I am interested at some point in the future in building a continuous world game where the environment streams in as you move.  From this very brief description, I imagine that I would simply have a ContentManager instance for each chunk of the world that I load.


  4. ShawnHargreaves says:

    You can have as many managers as you like: they’re designed to be lightweight so you can efficiently make lots of them.

    Streaming worlds hasn’t been a major design scenario for version 1 (ie. not something we’ve spent much time testing) but you’re exactly right, that’s how I imagine this would work.

  5. XNA Diaries says:

    Michael&amp;nbsp;(another PM on the XNA team) has followed Mitch’s lead and bypassed&amp;nbsp;his blog to add…

  6. amadrias says:

    Are you implementing any streaming feature on the Content Pipeline so we can stream content on large worlds and avoid loading screens?

    If not, is it something that the current design would allow us to develop?

    Moreover, would I be able to do asynchronous loading and unloading?

  7. ShawnHargreaves says:

    There is no streaming support in our first release, but this is something you could layer on top of the pipeline. It would probably involve having a separate ContentManager for each section of your world, loading them in a background thread, and then disposing the ContentManager when you are done with that world sector.

  8. As I wrote the other day, I’d like to help out people that are having trouble understanding the content

Skip to main content