Exemple #1
0
        /// <summary>
        /// Extracts all triangles from the mesh. (Not efficient.)
        /// </summary>
        /// <param name="areas">The areas for each triangle.</param>
        /// <returns>The triangle mesh data.</returns>
        public TriangleMesh ExtractMesh(out byte[] areas)
        {
            if (this.tris == IntPtr.Zero)
            {
                areas = null;
                return(null);
            }

            TriangleMesh result = new TriangleMesh();

            result.triCount  = mTriCount;
            result.vertCount = mVertCount;

            float[] lverts = new float[mVertCount * 3];
            Marshal.Copy(this.verts, lverts, 0, mVertCount * 3);
            result.verts = Vector3Util.GetVectors(lverts);

            result.tris = new int[mTriCount * 3];
            Marshal.Copy(this.tris, result.tris, 0, mTriCount * 3);

            areas = new byte[mTriCount];
            Marshal.Copy(this.areas, areas, 0, mTriCount);

            return(result);
        }
Exemple #2
0
        private void FillData(PolyMeshDetailData buffer)
        {
            buffer.vertCount = mVertCount;
            buffer.triCount  = mTriCount;
            buffer.meshCount = mMeshCount;

            float[] fverts = new float[mVertCount * 3];
            Marshal.Copy(mVerts, fverts, 0, mVertCount * 3);
            buffer.verts = Vector3Util.GetVectors(fverts, 0, buffer.verts, 0, mVertCount);
            Marshal.Copy(mTris, buffer.tris, 0, mTriCount * 4);
            UtilEx.Copy(mMeshes, buffer.meshes, mMeshCount * 4);
        }
 /// <summary>
 /// Returns a copy of the off-mesh connection vertices.
 /// </summary>
 /// <param name="buffer">
 /// The buffer to load the results into. [Length: >= <see cref="ConnCount"/> * 6]
 /// </param>
 /// <returns>The number of vertices returned, or -1 on error.</returns>
 public int GetConnVerts(Vector3[] buffer)
 {
     if (mConnVerts == IntPtr.Zero ||
         buffer == null ||
         buffer.Length < mConnCount * 2)
     {
         return(-1);
     }
     float[] fverts = new float[mConnCount * 2 * 3];
     Marshal.Copy(mConnVerts, fverts, 0, mConnCount * 2 * 3);
     Vector3Util.GetVectors(fverts, 0, buffer, 0, mConnCount * 2);
     return(mConnCount);
 }
 /// <summary>
 /// Returns a copy of the vertex data for the detail mesh.
 /// </summary>
 /// <param name="buffer">
 /// The buffer to load the results into. [Length: >= <see cref="DetailVertCount"/> * 3]
 /// </param>
 /// <returns>The number of vertices returned, or -1 on error.</returns>
 public int GetDetailVerts(Vector3[] buffer)
 {
     if (mDetailVerts == IntPtr.Zero ||
         buffer == null ||
         buffer.Length < mDetailVertCount)
     {
         return(-1);
     }
     float[] fverts = new float[mDetailVertCount * 3];
     Marshal.Copy(mDetailVerts, fverts, 0, fverts.Length);
     Vector3Util.GetVectors(fverts, 0, buffer, 0, mDetailVertCount);
     return(mDetailVertCount);
 }