public void AddQuads(
IList<Point3D> quadPositions, IList<Vector3D> quadNormals, IList<Point> quadTextureCoordinates)
{
if (quadPositions == null)
{
throw new ArgumentNullException("quadPositions");
}
if (this.normals != null && quadNormals == null)
{
throw new ArgumentNullException("quadNormals");
}
if (this.textureCoordinates != null && quadTextureCoordinates == null)
{
throw new ArgumentNullException("quadTextureCoordinates");
}
if (quadNormals != null && quadNormals.Count != quadPositions.Count)
{
throw new InvalidOperationException(WrongNumberOfNormals);
}
if (quadTextureCoordinates != null && quadTextureCoordinates.Count != quadPositions.Count)
{
throw new InvalidOperationException(WrongNumberOfTextureCoordinates);
}
Debug.Assert(quadPositions.Count > 0 && quadPositions.Count % 4 == 0, "Wrong number of positions.");
int index0 = this.positions.Count;
foreach (var p in quadPositions)
{
this.positions.Add(p);
}
if (this.textureCoordinates != null && quadTextureCoordinates != null)
{
foreach (var tc in quadTextureCoordinates)
{
this.textureCoordinates.Add(tc);
}
}
if (this.normals != null && quadNormals != null)
{
foreach (var n in quadNormals)
{
this.normals.Add(n);
}
}
int indexEnd = this.positions.Count;
for (int i = index0; i + 3 < indexEnd; i++)
{
this.triangleIndices.Add(i);
this.triangleIndices.Add(i + 1);
this.triangleIndices.Add(i + 2);
this.triangleIndices.Add(i + 2);
this.triangleIndices.Add(i + 3);
this.triangleIndices.Add(i);
}
}