XNA Game: The understanding of content

Source: Internet
Author: User
 

Original address: http://msdn.microsoft.com/zh-cn/library/bb447756.

XNA Game Studio Content Pipeline is a set of processing that is applied to game footage, starting with the raw file format of the footage, and using the XNA Framework class library to convert footage into data that XNA game Studio can use through a series of processing.

Content is all the non-executable managed code in your game, which includes fine art materials such as textures, sprites, mesh,effect, and font, as well as sound footage, such as music or sound effects, as well as content such as the level's data or character properties.

Most content is created using the digital content Creation (DCC) tool, such as a drawing program or 3D modeling program. The content file format used in your game varies, most of which are standard file formats, such as the JPEG format used for textures or the Autodesk FBX format for models. However, it is also possible to use custom formats or to save custom data in XML format. the benefits of content Pipeline (footage pipeline)

The main reason for using Content pipeline is to make your game run faster. If you do not use the content pipeline, your game must use the original file format of the footage. When you need to load footage and draw them on the screen, the game must first determine the file format and convert the data into a form that it can use directly, and this process will run at Runtime , which will affect the speed of the game.

Using content pipeline can eliminate these drawbacks by moving this time-consuming work to the generation of the game. At build time , each footage is imported from the original file format and then processed into a managed code object, which is then serialized as a file contained in the game's executable file.

At runtime (run time), the game can read the serialized data directly from the file and can be used immediately.

This architecture also provides additional benefits. Game artists can use their favorite DCC tools. Programmers can use the artwork-ready files directly in the XNA Game Studio project. If the file format of all the game footage can be supported by the standard importer and processor provided by XNA Game Studio, the programmer does not have to consider the file format or the processing details of the content pipeline. If desired, Content pipeline can also be easily customized or extended so that you can import new file formats or custom export types. using the content Pipeline

For XNA Game Studio games that use common format footage, there is no need to know the details of the content pipeline. XNA Game Studio provides standard importer and processor for common DCC file formats, and the only thing you need to do is to add these footage to your game's content project. XNA Game Studio built-in supported formats see the second half of this article.

For example, to use a DirectX Effect (. fx) file, simply add this file to the content project of the XNA Game Studio Gaming solution. XNA Game Studio can identify the. fx file type and then apply the correct component, which will be used to process the file when the game is generated. The game can then be accessed through the standard contentmanager.load approach to this effect, and the programmer does not have to worry about the details of the content pipeline steps.

But in the following cases, you need to understand how content pipeline works. Third parties can provide custom XNA Game Studio Content pipeline components that support other footage formats. You can write your own XNA Game Studio content Pipeline component to support new types of footage. You want to write your own XNA Game Studio content Pipeline components to convert a content to a specific purpose content when the game is generated. Content Pipeline Components (component)

Depending on the execution time of the XNA Game Studio Content pipeline process, it is divided into two types: the Build-time component (Build-time components) and the Runtime component (Run-time components). Build-time component (Build-time components)

When you build the game's executable in Visual Studio, the content pipeline component processes the footage when it is generated. These processes convert footage from the original DCC format to a managed code object that can be used directly by the game at run time.

These build-time components use the XNA Class Library, and class libraries can be extended to create custom content Pipeline Build- time components .

Components Description
Importer The importer importer converts footage from the DCC file format to the XNA Game Studio Content Document object, which can be handled by the standard Content processor, or other formats that can be processed by the custom processor.
Content processor The processor processor accepts imported specific types of footage, such as a set of mesh, and then compiles them into managed code objects that can be loaded and used by XNA Game Studio games on Windows,xbox 360 or Windows Phone.

When you import a footage file in a content project, its properties page selects the appropriate importer and processor. When the game is generated (press F5), the corresponding importer and processor for each footage are automatically called, and the footage is converted to a form that can be loaded at run time , and this load operation is done through the Contentmanager.load method. Run-time component (Run-time components)

XNA Game Studio Content Pipeline Runtime Component (Run-time components) supports loading and using converted footage. These run-time components use the XNA Class Library, and class libraries can be extended to create custom content pipeline runtime components. standard importer and processor

Original address: http://msdn.microsoft.com/zh-cn/library/bb447762.

Importers and content processors are implemented in the form of Assemblies (assemblies), and you can use custom importers and processors developed by yourself or by third parties in addition to the standard importers and processors that XNA comes with. Use the Properties window to apply the correct importer and processor to each footage. Standard Importer

The following table is a description of the standard importer that comes with Xna Game Studio, and all standard importers are declared under the Microsoft.Xna.Framework.Content.Pipeline namespace.

name type name Output Type Description
Autodesk FBX Fbximporter Nodecontent Import footage of Autodesk FBX file format (. fbx) This importer can import files exported by the 2006.11 version of FBX exporter.
Effect Effectimporter Effectcontent Imports footage of the DirectX effect file format (. fx).
Sprite Font Description Fontdescriptionimporter Fontdescription Imports a font description that is specified in the. spritefont file.
Texture Textureimporter Texturecontent Import textures. The file types can be:. bmp,.dds,.dib,.hdr,.jpg,.pfm,.png,.ppm and. TGA.
X File Ximporter Nodecontent Import Game Resources for DirectX file Format (*.x). This importer uses a left-handed coordinate system.
XACT Project N/A N/A

Import audio Resources for the file type of the Microsoft cross-platform Audio creation tool (XACT).

Tips

Associating a. xap file with XACT allows you to automatically open XACT when you edit any. xap file. Right-click the. xap file in the solution Manager and select Open with .... After the dialog box appears, select XACT, and then click Set as Default if the xact-specific option is not available, you must first run XACT. This program is in the Microsoft XNA Game Studio Group. In this group, click Tools and select Microsoft Cross-platform Audio Creation Tool (XACT).

XML Content Xmlimporter Object

The import XML is used to edit the value of a custom object at run time. For example, you can pass the XML code to the importer to query the specified property of the custom type and change its value. The custom object is then converted in a processor, or processing Required processor is passed to the game without change.

The importer is designed to import game data from an XML file (similar to the sprite Font description importer) at run time, or to import terrain data from an XML file, and then use this data to generate a random terrain in the processor.

Standard content Processors

XNA Game Studio comes with a processor that supports common footage types, and many standard processors, such as textureprocessor, can use parameters to adjust the processor's default behavior.

The following table is a description of the standard processor and the supported footage types.

name type name input type Output Type Description
Model modelprocessor nodecontent class modelcontent class

Selectable parameters Processor, output the model as a Modelcontent Class object.

Available parameters: Color Key color– any available color. The default value is magenta. A color Key Enabled–boolean value that indicates whether the color keying is available and is true by default. Generate Mipmaps–boolean value that indicates whether to generate Mipmaps, the default value is False. Generate Tangent Frames–boolean value that indicates whether tangent data is generated. The default value is False. Resize textures to power of Two–boolean value, which indicates whether the texture is resized so that it becomes the nearest power to 2. The default value is False. scale– any float value, default is 1.0. Swap Winding Order–boolean value indicating whether to flip the vertex bypass order. When a model is drawn from the inside Out, setting this option to True will show normal. The default value is False. Texture format– any Surfaceformat value. Textures are either immutable, converted to color format, or DXT compressed. For more information, see Textureprocessoroutputformat. X axis rotation– The angle of rotation around the x-axis. The default value is 0. Y axis rotation– The rotation angle around the y-axis. The default value is 0. Z axis rotation– rotation angle around the z axis. The default value is 0.

No processing Required Passthroughprocessor Object Object

No action is made on the file. Select this processor if your footage is already in a format that is directly available to the game (for example, an externally prepared DDS file) or a special XML format (*.xml) file that is designed to be used by XNA Game Studio Express.

Sprite Font Description Fontdescriptionprocessor Fontdescription Spritefontcontent

Converts the specified. spritefont file to a font.

Sprite Font Texture Fonttextureprocessor Texturecontent Spritefontcontent

An optional parameter of the processor that outputs a sprite font texture as a Spritefontcontent object.

Optional parameter: first character– any character. The default value is a space.

Sprite Font Texture Fonttextureprocessor Texture2dcontent Spritefontcontent Converts a 2D bmp file of a specified tag to a font. The Color.magenta pixels are converted to color.transparent.
Texture Textureprocessor Texturecontent Class Texturecontent Class

An optional parameter of the processor that outputs the texture as a texturecontent Class object.

Available parameters: Color Key color– any color. The default value is magenta. A color Key Enabled–boolean value that indicates whether the color keying is available and is true by default. Generate Mipmaps–boolean value that indicates whether to generate Mipmaps, the default value is False. The Resize to power of Two–boolean value, which indicates whether the texture is resized to become the nearest power to 2. The default value is False. Texture format– any Surfaceformat value. Textures are either immutable, converted to color format, or DXT compressed. For more information, see Textureprocessoroutputformat.

XACT Project N/A N/A N/A Create an audio resource from a XACT project.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.