Placing plants on the terrain

The next step in building our environment is to add some plants and trees to the terrain. We will look at two approaches to placing billboards on the terrain, and we will use both approaches to add vegetation to the terrain—one for trees and one for grass. First, we will need a function to find the height of the terrain at any given coordinate. This is a deceptively complex problem as we will need to interpolate between the heights at each vertex rather than just retrieving a rounded value from the heights array. The function to do this is as follows. Note that it also outputs the "steepness" of the terrain at the sampled point—this value is simply the angle between the lower and higher of the vertices at the edge ...

Get 3D Graphics with XNA Game Studio 4.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.