Page 448 OpenGL Super Bible! Defining the Terrain
Friday, December 21st, 2007Page 448 OpenGL Super Bible! Defining the Terrain To keep things simple, we ll define our terrain as a grid of elevation points with a texture attribute such as this is water or this is a mountain. Each point in the grid will also have an associated lighting normal to add realism. #define TERRAIN_SIZE 21 int TerrainType[TERRAIN_SIZE][TERRAIN_SIZE]; GLfloat TerrainHeight[TERRAIN_SIZE][TERRAIN_SIZE]; GLfloat TerrainNormal[TERRAIN_SIZE][TERRAIN_SIZE][3]; Here the TerrainType array contains the type of terrain at each point and is assigned one of the following control IDs from our user-interface resource file: IDC_GRASS Grasslands IDC_WATER Water IDC_TREES Trees/woodland IDC_ROCKS Rocks/cliffs IDC_MOUNTAINS Mountains Drawing Terrain Our terrain drawing controls consist of a toolbar dialog window with five buttons that select the current type of terrain. To draw the terrain, you just click and drag in the main window (see Figure 12-4). Figure 12-4 Textured terrain editing window
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.