public static short[] GetInds(this ModelMeshPart Part)
        {
            MeshDataContainer data = Part.GetPartData();

            if (data == null)
            {
                return(null);
            }
            if (data.Indices == null)
            {
                IndexBuffer ib      = Part.IndexBuffer;
                short[]     inds    = new short[Part.PrimitiveCount * 3];
                short[]     ib_inds = ib.Tag as short[];
                if (ib_inds == null)
                {
                    ib_inds = new short[ib.IndexCount];
                    ib.GetData <short>(ib_inds);
                    ib.Tag = ib_inds;
                }
                int offset = Part.StartIndex;
                for (int i = 0; i < inds.Length; ++i)
                {
                    inds[i] = ib_inds[i + offset];
                }
                data.Indices = inds;
            }
            return(data.Indices);
        }
예제 #2
0
 /// <summary>
 /// Reads data from the index buffer into the array.
 /// </summary>
 /// <typeparam name="T">The type of data in the index buffer - int or short.</typeparam>
 /// <param name="data">Array to write the data to</param>
 /// <param name="startIndex">Starting index in the array at which to start writing to</param>
 /// <param name="elementCount">Number of indices to read</param>
 /// <param name="offsetInBytes">Offset from the start of the index buffer at which to start copying from/param>
 /// <remarks>See implementors for exceptions that may occur.</remarks>
 public override void GetData <T>(T[] data, int startIndex, int elementCount, int offsetInBytes)
 {
     _indexBuffer.GetData <T>(offsetInBytes, data, startIndex, elementCount);
 }