home | login | register | DMCA | contacts | help | donate |

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я

 fantasy space fantasy fantasy is horrors heroic prose   military   child   russian detective   action   child   ironical   historical   political western adventure adventure (child) child's stories love religion antique Scientific literature biography business home pets animals art history computers linguistics mathematics religion home_garden sport technique publicism philosophy chemistry close

## `Creating a Terrain`

``` To create our terrain, we will use the same techniques as we did to create our cube. The terrain will be made up from a 20x20 grid of quads (squares made up from 2 triangles). We will use an index buffer, which will reduce the number of vertices from 2400 to 441. I'm not going to post the code here because it is very similar to the code above. The only real differences are the way the index and vertex buffers are populated. You can download the full source code by clicking the "Download Source" link above. Fig 8.2 below shows our flat terrain grid. You can render your scene in "wireframe" mode with one simple call to SetRenderState which is also shown below. //Set fill state. Possible values: D3DFILL_POINT, D3DFILL_WIREFRAME, D3DFILL_SOLID m_pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME); Fig 8.2 Now that we have a flat grid, we can turn this into a simple terrain by setting a random value for y for each vertex. I've done this for each vertex in the grid except the ones that are around the edge so that the four edges are all the same level. If you want to create a more detailed terrain, have a look at http://www.gameprogrammer.com/fractal.html where there is a tutorial on how to generate a random fractal terrain. Fig 8.3 below shows the grid with random y values. Fig 8.3 The last thing to do is apply a grass texture to the terrain and set the render state to solid rather than wireframe. Once you have done this, you should end up with a scene that looks like the screenshot below. ```

Implementing an Index Buffer in DirectX | DirectX 8 Programming Tutorial | Summary