private static extern void Internal_CreateInstanceMeshData(Mesh instance, IntPtr data, SubMesh[] subMeshes, MeshUsage usage);
/// <summary> /// Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described /// by the mesh data exactly. Mesh will have specified the sub-meshes. /// </summary> /// <param name="data">Vertex and index data to initialize the mesh with.</param> /// <param name="subMeshes">Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered. /// Sub-meshes may be rendered independently.</param> /// <param name="usage">Optimizes performance depending on planned usage of the mesh.</param> public Mesh(MeshData data, SubMesh[] subMeshes, MeshUsage usage = MeshUsage.Default) { IntPtr dataPtr = IntPtr.Zero; if (data != null) dataPtr = data.GetCachedPtr(); Internal_CreateInstanceMeshData(this, dataPtr, subMeshes, usage); }
private static extern void Internal_CreateInstance(Mesh instance, int numVertices, int numIndices, SubMesh[] subMeshes, MeshUsage usage, VertexType vertex, IndexType index);
/// <summary> /// Creates a new mesh with enough space to hold the a number of primitives using the specified layout. Indices can /// be references by multiple sub-meshes. /// </summary> /// <param name="numVertices">Number of vertices in the mesh.</param> /// <param name="numIndices">Number of indices in the mesh. </param> /// <param name="subMeshes">Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered. /// Sub-meshes may be rendered independently.</param> /// <param name="usage">Optimizes performance depending on planned usage of the mesh.</param> /// <param name="vertex">Controls how are vertices organized in the vertex buffer and what data they contain.</param> /// <param name="index">Size of indices, use smaller size for better performance, however be careful not to go over /// the number of vertices limited by the size.</param> public Mesh(int numVertices, int numIndices, SubMesh[] subMeshes, MeshUsage usage = MeshUsage.Default, VertexType vertex = VertexType.Position, IndexType index = IndexType.Index32) { Internal_CreateInstance(this, numVertices, numIndices, subMeshes, usage, vertex, index); }