create barcode c#.net Generating a Terrain in Font

Printer Data Matrix in Font Generating a Terrain

CHAPTER
Painting Data Matrix 2d Barcode In None
Using Barcode creator for Font Control to generate, create Data Matrix image in Font applications.
www.OnBarcode.com
EAN 13 Creation In None
Using Barcode generation for Font Control to generate, create EAN-13 image in Font applications.
www.OnBarcode.com
Generating a Terrain
Drawing Code 39 In None
Using Barcode maker for Font Control to generate, create Code 3/9 image in Font applications.
www.OnBarcode.com
Generate Barcode In None
Using Barcode printer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
n this chapter you ll learn how to create a 3-D terrain from a height map. Terrains are a good way to represent outdoor environments, and an efficient way to represent a terrain is through the use of height maps. To give a photorealistic look to the terrain, you re also going to learn how to create an effect that uses multitexturing and normal mapping, which you ll use to render the terrain. At the end of the chapter you ll create some auxiliary methods for the terrain, used to query the height of a position over the terrain, and check the collision between a ray and the terrain.
Print Barcode In None
Using Barcode drawer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
QR Encoder In None
Using Barcode creation for Font Control to generate, create QR Code 2d barcode image in Font applications.
www.OnBarcode.com
Height Maps
Draw PDF-417 2d Barcode In None
Using Barcode creator for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
USPS PLANET Barcode Generation In None
Using Barcode generation for Font Control to generate, create USPS Confirm Service Barcode image in Font applications.
www.OnBarcode.com
Height maps are 2-D maps used to store the height of a terrain. They re usually stored in 8-bit grayscale images, where each point of the image stores the terrain s height at that position. Figure 10-1 shows an image of a height map.
Painting ECC200 In Java
Using Barcode printer for Android Control to generate, create Data Matrix image in Android applications.
www.OnBarcode.com
Print Data Matrix In Java
Using Barcode maker for Java Control to generate, create Data Matrix ECC200 image in Java applications.
www.OnBarcode.com
Figure 10-1. An example of a height map
Make ANSI/AIM Code 128 In Visual Studio .NET
Using Barcode drawer for .NET Control to generate, create Code 128C image in .NET applications.
www.OnBarcode.com
Barcode Creation In None
Using Barcode creator for Excel Control to generate, create Barcode image in Office Excel applications.
www.OnBarcode.com
CHAPTER 10 s GENERATING A TERRAIN
Code 39 Extended Maker In Java
Using Barcode creator for Android Control to generate, create Code 39 Full ASCII image in Android applications.
www.OnBarcode.com
Generate PDF-417 2d Barcode In None
Using Barcode creator for Office Excel Control to generate, create PDF417 image in Excel applications.
www.OnBarcode.com
To build a terrain from a height map, you first need to build a vertex grid with the same dimensions as the height map, and then use the height value of each point (pixel) on the height map as the height of a vertex on the vertex grid. For example, you can use a height map with a 6 ! 6 pixel resolution to displace the height of each vertex in a 6 ! 6 vertex grid. Besides its position, each vertex on the grid contains other attributes needed for rendering, such as normal and texture coordinate. Figure 10-2 illustrates a vertex grid with 6 ! 6 vertices created over the world plane XZ, where the height of each vertex is relative to the world s Y axis.
Code-39 Drawer In Java
Using Barcode generation for Java Control to generate, create Code39 image in Java applications.
www.OnBarcode.com
Generating Barcode In Java
Using Barcode creator for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
Figure 10-2. A 6 ! 6 vertex grid created over the XZ plane
Data Matrix Printer In .NET Framework
Using Barcode maker for Reporting Service Control to generate, create Data Matrix ECC200 image in Reporting Service applications.
www.OnBarcode.com
Barcode Printer In Objective-C
Using Barcode generator for iPad Control to generate, create Barcode image in iPad applications.
www.OnBarcode.com
In a vertex grid you should define a distance between each pair of vertices (vertically and horizontally). This distance is represented by the Block Scale in Figure 10-2. A small distance between the vertices allows smooth transitions between the vertices heights over the vertex grid but reduces the grid size, while a big distance between the vertices increases the grid size but can yield sharp transitions between the vertices heights. This way, if the distance between each pair of vertices (vertically and horizontally) is 1 meter, the total size of the generated terrain will be 255 ! 255 meters. As the terrain s height map is usually stored in 8-bit images, its height values vary between 0 and 255, where 0 (black color) represents the lowest possible height for a vertex and 255 (white color) represents the highest possible height. You can raise this interval using a scale factor, which is multiplied by the default height value, increasing its range. This provides a bigger height interval, but with less precision between the values.
Decoding Barcode In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Making ANSI/AIM Code 39 In VB.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Code 3 of 9 image in Visual Studio .NET applications.
www.OnBarcode.com
CHAPTER 10 s GENERATING A TERRAIN
Figure 10-3 shows a 3-D terrain built from the height map of Figure 10-1, rendered in wireframe (up) and solid (low). Note that for the rendered terrain shown in Figure 10-3, the normal and the texture coordinate were calculated for each vertex, allowing correct illumination and texturing of the terrain.
Figure 10-3. Terrain generated from the height map in Figure 10-1 in wireframe and solid rendering
Generating a Height Map
You can build or obtain height maps in different ways. You can find different kinds of height maps all over the Internet, including height maps of real places (cities, and so on). Because height maps are grayscale images, you can use any image editor tool to build or
CHAPTER 10 s GENERATING A TERRAIN
edit your own height maps. Also, some tools allow procedural generation of the terrain s height map from user-defined parameters. One of the simplest and fastest ways to build height maps is through the use of procedural generation tools such as Terragen (http://www.planetside.co.uk/terragen/). Terragen allows the generation of a height map from various user-defined parameters, such as terrain size, realism, smoothing, glaciation, and canyonism. One advantage of Terragen is that you can use it freely for noncommercial applications. An artist can also refine the height map generated from Terragen at a later time. Another tool you can use to create height maps is EarthSculptor (http://www. earthsculptor.com/). EarthSculptor has some internal tools for 3-D modeling of terrains, and it allows saving the terrain model as a height map.
Copyright © OnBarcode.com . All rights reserved.