private void AddRectangularMeshNormals(int index0, int rows, int columns)
{
for (int i = 0; i < rows; i++)
{
int i1 = i + 1;
if (i1 == rows)
{
i1--;
}
int i0 = i1 - 1;
for (int j = 0; j < columns; j++)
{
int j1 = j + 1;
if (j1 == columns)
{
j1--;
}
int j0 = j1 - 1;
var u = Point3D.Subtract(
this.positions[index0 + (i1 * columns) + j0], this.positions[index0 + (i0 * columns) + j0]);
var v = Point3D.Subtract(
this.positions[index0 + (i0 * columns) + j1], this.positions[index0 + (i0 * columns) + j0]);
var normal = Vector3D.CrossProduct(u, v);
normal.Normalize();
this.normals.Add(normal);
}
}
}