private void createIndices()
{
indices = new int[nIndices];
int i = 0;
// For each cell
for (int x = 0; x < width - 1; x++)
for (int z = 0; z < length - 1; z++)
{
// Find the indices of the corners
int upperLeft = z * width + x;
int upperRight = upperLeft + 1;
int lowerLeft = upperLeft + width;
int lowerRight = lowerLeft + 1;
// Specify upper triangle
indices[i++] = upperLeft;
indices[i++] = upperRight;
indices[i++] = lowerLeft;
// Specify lower triangle
indices[i++] = lowerLeft;
indices[i++] = upperRight;
indices[i++] = lowerRight;
}
}