
CHAPTER 5 ■ GETTING THE MOST OUT OF VERTICES
436
for (int i = 0; i < vertices.Length; i++)
vertices[i].Normal.Normalize();
return vertices;
}
5-8. Create a Terrain Based on a VertexBuffer and
an IndexBuffer
The Problem
Based on a 2D height map, you want to create a terrain and render it in an efficient way.
The Solution
First you need to have a height map, containing all the height data you want to define your ter-
rain from. This height map will have a certain number of data points in both dimensions; let’s
call these the width and height of your future terrain.
Obviously, if you want to build a terrain based on this data, your terrain will be drawn ...