- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Body of the Custom Content Pipeline in Office Word
Body of the Custom Content Pipeline Drawing ECC200 In None Using Barcode creation for Word Control to generate, create Data Matrix 2d barcode image in Office Word applications. www.OnBarcode.comCreate Code-128 In None Using Barcode creator for Word Control to generate, create USS Code 128 image in Office Word applications. www.OnBarcode.comBecause the input of this content pipeline is an image, you will need to create a custom image processor. This time, however, you cannot inherit from the default image processor, because this requires your processor to produce a TextureContent object. As shown in Figure 5-22, you want to output an object of a custom class, TerrainContent. In this custom processor, you will create an object of a custom class, so you will want to go through the ten short initialization steps of recipe 4-15. In step 4, you will indicate you re going to define a content processor that takes in a TextureContent object and processes this into a TerrainContent object: [ContentProcessor] public class HeightMapProcessor : ContentProcessor<TextureContent, TerrainContent> { public override TerrainContent Process(TextureContent input, ContentProcessorContext context) { } } EAN13 Creation In None Using Barcode generation for Microsoft Word Control to generate, create UPC - 13 image in Office Word applications. www.OnBarcode.comGenerate PDF417 In None Using Barcode creation for Word Control to generate, create PDF-417 2d barcode image in Office Word applications. www.OnBarcode.comCHAPTER 5 GETTING THE MOST OUT OF VERTICES
Data Matrix ECC200 Creation In None Using Barcode printer for Office Word Control to generate, create Data Matrix image in Word applications. www.OnBarcode.comUPC-A Supplement 5 Maker In None Using Barcode drawer for Microsoft Word Control to generate, create UCC - 12 image in Microsoft Word applications. www.OnBarcode.comAfter you ve gone through the ten steps, you ll want to add the two custom classes you need in this chapter: the Terrain class containing the code of recipe 5-8 and the TerrainContent class containing all the data required to create a Terrain object from. You can add the first class by importing the class file in your content pipeline project. You will define this last class yourself; for now, add this empty class to your content pipeline project (you ll be adding stuff throughout this recipe): public class TerrainContent { public TerrainContent() { } } With a custom class defined, you need to define a TypeWriter capable of serializing objects of your custom class to a binary file. Add this TypeWriter class to your pipeline project: [ContentTypeWriter] public class CPTerrainTypeWriter : ContentTypeWriter<TerrainContent> { protected override void Write(ContentWriter output, TerrainContent value) { } public override string GetRuntimeReader(TargetPlatform targetPlatform) { return typeof(TerrainTypeReader).AssemblyQualifiedName; } } The first line indicates this class will be a TypeWriter, capable of serializing a TerrainContent object to file. In your Write method, you will define how this should be done. The GetRuntimeReader is called at runtime and informs XNA which TypeReader should be called to deserialize the binary data. However, unlike in recipes 4-15 and 4-16 and as explained in the introduction to this recipe, this time you do not want the binary data to be deserialized into a TerrainContent object but into an object of the Terrain class! You can inform XNA of this by overriding the GetRuntimeType method in your TypeWriter class as well: public override string GetRuntimeType(TargetPlatform targetPlatform) { return typeof(Terrain).AssemblyQualifiedName; } This informs XNA that any data that was serialized from the TerrainContent object should be used to generate a Terrain object at runtime. You are responsible for making your TerrainContent object serialize enough data so a Terrain object can be constructed from it. QR-Code Generator In None Using Barcode printer for Microsoft Word Control to generate, create QR image in Microsoft Word applications. www.OnBarcode.comDrawing USD - 8 In None Using Barcode encoder for Microsoft Word Control to generate, create USD - 8 image in Office Word applications. www.OnBarcode.comCHAPTER 5 GETTING THE MOST OUT OF VE RTICES
Data Matrix Generator In Visual Basic .NET Using Barcode encoder for .NET framework Control to generate, create Data Matrix image in .NET applications. www.OnBarcode.comECC200 Maker In None Using Barcode drawer for Online Control to generate, create Data Matrix ECC200 image in Online applications. www.OnBarcode.comThe Content Processor
UPC-A Encoder In Java Using Barcode generation for Java Control to generate, create UPC A image in Java applications. www.OnBarcode.comQR Code Recognizer In Visual Basic .NET Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comWith the body of the content pipeline defined, you re ready to update the processor. It is responsible for calculating all the data you want to be stored in the TerrainContent object, starting from a TextureContent object. Change the Process method to this so it calculates all height data, vertices, and indices for the terrain: public override TerrainContent Process(TextureContent input, ContentProcessorContext context) { TextureContent usualImage = context.Convert<TextureContent, TextureContent>(input, "TextureProcessor"); usualImage.ConvertBitmapType(typeof(PixelBitmapContent<Color>)); PixelBitmapContent<Color> image = (PixelBitmapContent<Color>)usualImage.Faces[0][0]; float[,] heightData = HeightMapToArray(image); VertexPositionNormalTexture[] vertices = CreateTerrainVertices(heightData); int[] indices = CreateTerrainIndices(heightData); vertices = GenerateNormalsForTriangleStrip(vertices, indices); } Paint Code 128A In None Using Barcode creator for Software Control to generate, create Code 128 image in Software applications. www.OnBarcode.comCode-39 Creator In .NET Framework Using Barcode maker for ASP.NET Control to generate, create USS Code 39 image in ASP.NET applications. www.OnBarcode.com Note This processor does not yet output a TerrainContent object; you ll do this in a moment.
Print PDF 417 In Java Using Barcode printer for Java Control to generate, create PDF-417 2d barcode image in Java applications. www.OnBarcode.comUCC.EAN - 128 Creator In Objective-C Using Barcode maker for iPhone Control to generate, create GTIN - 128 image in iPhone applications. www.OnBarcode.comAs good practice (but optional in this case), you first process the image using the default image processor. Next, you convert it to a more usable format and retrieve the only face of interest, as explained in recipe 3-9. Once you know the colors of the individual pixels, you can create all required vertices and indices using the terrain generation code explained in recipe 5-8. This processing code is the main topic of recipe 5-8, so I will not list it here, but remember that now this code will be executed only once at compile time instead of each time at runtime as in recipe 5-8, bringing a speedup at runtime. At this moment, you have virtually everything you need to create a Terrain object. However, keep in mind you re writing a custom content pipeline, so the data first needs to be serialized to a binary file and deserialized by the TypeReader at runtime. Therefore, you need to think about which data you ll need in the TypeReader to generate a Terrain object. Barcode Drawer In Objective-C Using Barcode creator for iPhone Control to generate, create Barcode image in iPhone applications. www.OnBarcode.comRead ECC200 In C# Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comScanning GS1 - 12 In None Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comDecode Quick Response Code In None Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.com |
|