Content Pipeline Architecture

來源:互聯網
上載者:User

Content Pipeline Architecture

Describes the architecture of the XNA Game Studio Content Pipeline build process. The process is designed to be extensible, so that it can easily support new input file formats and new types of conversion.

While most users of the Content Pipeline can ignore its inner workings, if you are a game developer who wants to create a new importer and processor to support a new file format or game-engine capability, it is useful to understand the stages that the Content Pipeline passes through as an asset is transformed from a digital-content creation (DCC) output file to part of the game binary.

下面要講解Content Pipeline的內部內部細節,其實可以先不要學習,如果以後需要建立自訂的importer和processor的時候再來看。

Build-Management Functionality

Once an art asset (such as a car model) is added to an XNA Game Studio project, the Content Pipeline integrates it into the Visual Studio build just as it would any other source file, providing error handling, status information, and other standard build features. For information on how to set Content Pipeline build options, see Game Asset Properties.

In the course of a build, the Content Pipeline invokes four principal components to perform different parts of the transformation from a DCC output file into a binary part of an XNA Game Studio game.

  1. Importer
  2. Content Processor
  3. Content Compiler
  4. Content Loader

The following figure shows the flow of this build process.

Importer and Content DOM Types

XNA Game Studio provides a number of standard importers, which are listed in Standard Importers and Processors. This includes an importer for the Autodesk .fbx format, and one for the DirectX .x format. These importers simplify the importing of art assets, since many DCC tools can export content to one of these formats as well as to their own native formats.

For art assets that are available only in formats not supported by XNA Game Studio standard importers, custom importers may be available as well. Such custom importers can be developed by DCC vendors, game-engine developers, or interested game hobbyists. For more information about how to do this, see How To: Write a Custom Importer and Processor. Once you install a custom importer on your computer, you can associate those art files with the importer in order to invoke the importer whenever you build the art files (see Using a Custom Importer or Content Processor).

In many cases, Content Pipeline importers convert any content they can into managed objects based on the Content Document Object Model (DOM), which includes strong typing for assets such as meshes, vertices, and materials.

The Content Pipeline can use XML cache files in subsequent passes to speed up game content builds as well as to debug. When a content processor requests that a specified file be imported (typically using the BuildAndLoadAsset method in its Process function) and there is an up-to-date cache file already, the Content Pipeline deserializes the cache file instead of invoking the importer. These XML cache files are not used externally, however, because their format may well change in future releases.

Instead of producing standard Content DOM objects, a custom importer may produce custom objects for a particular custom content processor to consume.

Content Processor

A content processor accepts as input the output generated by an importer. Each content processor is tied to specific object types. For instance, the Effect Processor accepts only EffectContent objects, representing a DirectX Effect asset. As discussed previously, in many cases, this output consists of standard Content DOM objects, but may also consist of custom objects.

A content processor then produces managed objects that can be used in a game at run time. In the case of standard Content DOM objects, this transformation can be performed by classes in the Content Pipeline class library. However, if a content processor generates custom managed objects, you must provide full functionality for them, including saving and loading to and from a binary file. For more information, see How To: Write a Custom Importer and Processor.

Content Compiler

After you add the various game assets to the project and the content processors generate managed code, the managed code is serialized into a compact binary format (also referred to as an intermediate format) by the Content Pipeline content compiler. This format is tightly coupled to the XNA Framework. It is not designed for use by other run-time libraries. At this point, the asset has been processed by the Content Pipeline and is in a format that can be used by your game at runtime. See the diagram above for details.

Content Loader

When you need the compiled asset in a game, call the ContentManager.Load method to invoke the content loader. The content loader then locates and loads the asset into the memory space of the game where you can access it.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.