Loading Additional Content Types

XNA Game Studio provides standard Content Pipeline components that import and process the most commonly used game asset file types. These file types include, for example, importers for the Autodesk (.fbx) format and the DirectX (.x) format. A complete list of file types is available in the Standard Importers and Processors topic. Most digital Content creation (DCC) tools are capable of creating output in at least one of these standard formats.

Choosing to Customize

A custom importer is required for game assets available only in formats unsupported by XNA Game Studio standard importers. One may already be available from a third party. Custom importers can be developed by DCC vendors, game-engine developers, and interested game hobbyists. Once a custom importer is installed on your computer, you can associate art files with the importer to invoke it when you build the art files (see Adding a Custom Importer).

You may need to write your own custom XNA Game Studio Content Pipeline components to:

  • Support a new type of game asset or format from a DCC tool.
  • Derive special-purpose content from another piece of content at the time the game is built.

Here are some typical scenarios, and a summary of which Content Pipeline components require customization.

Component When to customize Output options
Importer
  • A game asset created by a DCC tool is available only in a format unsupported by a XNA Game Studio standard importer.
  1. Content Document Object Model (DOM) object that can be consumed by a standard content processor.
  2. A custom object that must be consumed by a custom content processor.
Content processor
  • Must process the custom output of a custom importer.
  • Needs to process the output of a standard importer in a special-purpose way.
  1. A standard processor output type.
  2. A custom processor output type that must be consumed by a custom content loader at game run time.
Content loader
  • Must load custom output of a customized content processor.

  • A custom content loader is implemented by extending the ContentManager.Load method to load the new custom data type.

  1. A standard XNA Framework class object.
  2. A custom class object.

Customization Scenarios

This section examines some typical examples where customization is needed, and illustrates which Content Pipeline components must be changed.

Supporting a New File Format

In this example, a nonstandard file format contains information that can be represented by a standard Content DOM type.

Ff433775.CP_CustomImporter(en-us,XNAGameStudio.41).png

As illustrated, only a custom importer that can read the nonstandard file format and output a Content DOM object (in this case, a TextureContent object) is required. The remainder of the Content Pipeline process can be performed by a standard content processor and content loader.

Creating Special-Purpose Data from Standard Objects

For this example, a texture object that represents a map of normalized vectors derived from the original texture object is created.

Ff433775.CP_Sprite_Effects(en-us,XNAGameStudio.41).png

Since the texture is contained in a standard format for the game asset, a standard importer can be used to create the TextureContent object. A custom content processor (NormalMapProcessor) creates the special-purpose data, but uses the standard TextureContent class to contain the result so that it can be loaded by the standard content loader.

Supporting Custom Data from a Nonstandard Game Asset

Illustrated in this example is a nonstandard game asset file containing data that does not correspond to any standard data types.

Ff433775.CP_CustomData(en-us,XNAGameStudio.41).png

To read the nonstandard game asset file, a custom importer is required that outputs a CustomContent object. Since the output of the importer is a custom class, a custom content processor also is needed, and the ContentManager.Load method must be extended to support the custom data object.

See Also

Adding New Content Types
What Is Content?
What is the Content Pipeline?