Game Development Reference
In-Depth Information
}
void Terrain::setHeightmapEntry(int row, int col, int value)
{
_heightmap[row * _numVertsPerRow + col] = value;
}
These methods allow us to refer to an entry by row and column and
hide the way we must index a linear array when using it to describe a
matrix.
13.2 Generating the Terrain Geometry
Figure 13.4: Properties of the trian-
gle grid labeled. The dots along the
grid lines are vertices.
Figure 13.4 shows some properties of a terrain, vocabulary, and special
points that we refer to. We define the size of our terrain by specifying
the number of vertices per row, the number of vertices per column, and
the cell spacing. We pass these values into the constructor of the Ter-
rain class. In addition, we also pass the device associated with the
terrain, a string identifying the filename that the heightmap data is con-
tained in, and a height scale value that is used to scale the heightmap
elements.
class Terrain
{
public:
Terrain(
IDirect3DDevice9* device,
std::string heightmapFileName,
int numVertsPerRow,
int numVertsPerCol,
int cellSpacing, // space between cells
float heightScale); // value to scale heights by
... methods snipped
Search WWH ::




Custom Search