/// <summary> /// Creates a deep-copy of the current <see cref="IGraphicsStream"/>. /// </summary> /// <returns>A deep-copy of the current <see cref="IGraphicsStream"/>.</returns> public override IGraphicsStream Clone() { IGraphicsStream stream = new IndexStream32(this.Size); stream.Copy(this); return(stream); }
/// <summary> /// Creates an IndexStream from a certain number of vertices that are organised in quads. /// </summary> /// <param name="quadNum">The number of quads.</param> /// <returns>The created indexStream.</returns> public static IndexStream FromQuads(int quadNum) { IndexStream indexStream; if (quadNum * 6 > ushort.MaxValue) { indexStream = new IndexStream32(quadNum * 6); } else { indexStream = new IndexStream16(quadNum * 6); } int iIndex = 0; int iVertex = 0; for (int i = 0; i < quadNum; i++, iIndex += 6, iVertex += 4) { indexStream[iIndex + 0] = iVertex; indexStream[iIndex + 1] = (iVertex + 1); indexStream[iIndex + 2] = (iVertex + 3); indexStream[iIndex + 3] = (iVertex + 3); indexStream[iIndex + 4] = (iVertex + 1); indexStream[iIndex + 5] = (iVertex + 2); } return(indexStream); }
//--------------------------------------------------------------- #endregion //--------------------------------------------------------------- //--------------------------------------------------------------- #region Methods //--------------------------------------------------------------- /// <summary> /// Creates an IndexStream from a list of triangles /// </summary> /// <param name="triangles"></param> public static IndexStream32 FromTriangles(System.Collections.ICollection triangles) { IndexStream32 index = new IndexStream32(triangles.Count * 3); int i = 0; foreach (Triangle tri in triangles) { index[i++] = tri.A; index[i++] = tri.B; index[i++] = tri.C; } return(index); }