/// <summary> /// Gets a serialized version of the mesh that can be used to recreate it later. /// </summary> /// <param name="includeBuffer"> /// True if serialized data should include the full buffer size. Otherwise the buffers will /// be stripped and the smallest possible serialized data returned. /// </param> /// <returns>A serialized version of the mesh.</returns> public byte[] GetSerializedData(bool includeBuffer) { if (IsDisposed) { return(null); } // Design note: This is implemented using interop calls // bacause it is so much easier and faster to serialize in C++ // than in C#. IntPtr ptr = IntPtr.Zero; int dataSize = 0; if (!PolyMeshDetailEx.rcpdGetSerializedData(this , includeBuffer , ref ptr , ref dataSize)) { return(null); } byte[] result = UtilEx.ExtractArrayByte(ptr, dataSize); NMGenEx.nmgFreeSerializationData(ref ptr); return(result); }
/// <summary> /// Gets a serialized version of the mesh that can be used to /// recreate it later. /// </summary> /// <param name="includeBuffer"> /// True if serialized data should include the full buffer size. Otherwise the unused /// portion of the buffers will removed and the smallest possible serialized data returned. /// </param> /// <returns>A serialized version of the mesh.</returns> public byte[] GetSerializedData(bool includeBuffer) { if (IsDisposed) { return(null); } // Design note: This is implemented using an interop call // rather than local code bacause it is much more easier to // serialize in C++ than it is in C#. IntPtr ptr = IntPtr.Zero; int dataSize = 0; if (!PolyMeshEx.rcpmGetSerializedData(ref root , mMaxVerts , mWalkableHeight , mWalkableRadius , mWalkableStep , includeBuffer , ref ptr , ref dataSize)) { return(null); } byte[] result = UtilEx.ExtractArrayByte(ptr, dataSize); NMGenEx.nmgFreeSerializationData(ref ptr); return(result); }
/// <summary> /// Set the area of all triangles with a slope above the specified value to /// <see cref="NullArea"/>. /// </summary> /// <param name="context">The context to use duing the operation.</param> /// <param name="mesh">The source mesh.</param> /// <param name="walkableSlope">The maximum walkable slope.</param> /// <param name="areas"> /// The areas associated with each triangle. [Length: >= mesh.triCount] (In/Out) /// </param> /// <returns>True if the operation was successful.</returns> public static bool ClearUnwalkableTriangles(BuildContext context, TriangleMesh mesh , float walkableSlope , byte[] areas) { if (mesh == null || context == null || areas == null || areas.Length < mesh.triCount) { return(false); } NMGenEx.nmgClearUnwalkableTriangles(context.root , walkableSlope , mesh.verts , mesh.vertCount , mesh.tris , mesh.triCount , areas); return(true); }