Mesh.generated.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Rendering
  7. * @{
  8. */
  9. /// <summary>
  10. /// Primary class for holding geometry. Stores data in the form of vertex buffers and optionally an index buffer, which
  11. /// may be bound to the pipeline for drawing. May contain multiple sub-meshes.
  12. /// </summary>
  13. [ShowInInspector]
  14. public partial class Mesh : Resource
  15. {
  16. private Mesh(bool __dummy0) { }
  17. protected Mesh() { }
  18. /// <summary>
  19. /// Creates a new mesh with enough space to hold the a number of primitives using the specified layout. All indices will
  20. /// be part of a single sub-mesh.
  21. /// </summary>
  22. /// <param name="numVertices">Number of vertices in the mesh.</param>
  23. /// <param name="numIndices">
  24. /// Number of indices in the mesh. Must be a multiple of primitive size as specified by provided topology.
  25. /// </param>
  26. /// <param name="topology">
  27. /// Determines how should the provided indices be interpreted by the pipeline. Default option is a triangle list, where
  28. /// three indices represent a single triangle.
  29. /// </param>
  30. /// <param name="usage">Optimizes performance depending on planned usage of the mesh.</param>
  31. /// <param name="vertex">Controls how are vertices organized in the vertex buffer and what data they contain.</param>
  32. /// <param name="index">
  33. /// Size of indices, use smaller size for better performance, however be careful not to go over the number of vertices
  34. /// limited by the data type size.
  35. /// </param>
  36. public Mesh(int numVertices, int numIndices, MeshTopology topology = MeshTopology.TriangleList, MeshUsage usage = MeshUsage.Static, VertexLayout vertex = VertexLayout.Position, IndexType index = IndexType.Index32)
  37. {
  38. Internal_create(this, numVertices, numIndices, topology, usage, vertex, index);
  39. }
  40. /// <summary>
  41. /// Creates a new mesh with enough space to hold the a number of primitives using the specified layout. Indices can be
  42. /// referenced by multiple sub-meshes.
  43. /// </summary>
  44. /// <param name="numVertices">Number of vertices in the mesh.</param>
  45. /// <param name="numIndices">
  46. /// Number of indices in the mesh. Must be a multiple of primitive size as specified by provided topology.
  47. /// </param>
  48. /// <param name="subMeshes">
  49. /// Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered. Sub-meshes may be rendered
  50. /// independently, each with a different material.
  51. /// </param>
  52. /// <param name="usage">Optimizes performance depending on planned usage of the mesh.</param>
  53. /// <param name="vertex">Controls how are vertices organized in the vertex buffer and what data they contain.</param>
  54. /// <param name="index">
  55. /// Size of indices, use smaller size for better performance, however be careful not to go over the number of vertices
  56. /// limited by the data type size.
  57. /// </param>
  58. public Mesh(int numVertices, int numIndices, SubMesh[] subMeshes, MeshUsage usage = MeshUsage.Static, VertexLayout vertex = VertexLayout.Position, IndexType index = IndexType.Index32)
  59. {
  60. Internal_create0(this, numVertices, numIndices, subMeshes, usage, vertex, index);
  61. }
  62. /// <summary>
  63. /// Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described by the
  64. /// mesh data exactly. Mesh will have no sub-meshes.
  65. /// </summary>
  66. /// <param name="data">Vertex and index data to initialize the mesh with.</param>
  67. /// <param name="topology">
  68. /// Determines how should the provided indices be interpreted by the pipeline. Default option is a triangle list, where
  69. /// three indices represent a single triangle.
  70. /// </param>
  71. /// <param name="usage">Optimizes performance depending on planned usage of the mesh.</param>
  72. public Mesh(MeshData data, MeshTopology topology = MeshTopology.TriangleList, MeshUsage usage = MeshUsage.Static)
  73. {
  74. Internal_create1(this, data, topology, usage);
  75. }
  76. /// <summary>
  77. /// Creates a new mesh with enough space to hold the a number of primitives using the specified layout. Indices can be
  78. /// referenced by multiple sub-meshes.
  79. /// </summary>
  80. /// <param name="data">Vertex and index data to initialize the mesh with.</param>
  81. /// <param name="subMeshes">
  82. /// Defines how are indices separated into sub-meshes, and how are those sub-meshes rendered. Sub-meshes may be rendered
  83. /// independently, each with a different material.
  84. /// </param>
  85. /// <param name="usage">Optimizes performance depending on planned usage of the mesh.</param>
  86. public Mesh(MeshData data, SubMesh[] subMeshes, MeshUsage usage = MeshUsage.Static)
  87. {
  88. Internal_create2(this, data, subMeshes, usage);
  89. }
  90. /// <summary>Returns a reference wrapper for this resource.</summary>
  91. public RRef<Mesh> Ref
  92. {
  93. get { return Internal_GetRef(mCachedPtr); }
  94. }
  95. /// <summary>Gets the skeleton required for animation of this mesh, if any is available.</summary>
  96. [ShowInInspector]
  97. [NativeWrapper]
  98. public Skeleton Skeleton
  99. {
  100. get { return Internal_getSkeleton(mCachedPtr); }
  101. }
  102. /// <summary>Returns an object containing all shapes used for morph animation, if any are available.</summary>
  103. [ShowInInspector]
  104. [NativeWrapper]
  105. public MorphShapes MorphShapes
  106. {
  107. get { return Internal_getMorphShapes(mCachedPtr); }
  108. }
  109. /// <summary>Returns all sub-meshes contained in the mesh.</summary>
  110. [ShowInInspector]
  111. [NativeWrapper]
  112. public SubMesh[] SubMeshes
  113. {
  114. get { return Internal_getSubMeshes(mCachedPtr); }
  115. }
  116. /// <summary>Returns the number of sub-meshes contained in this mesh.</summary>
  117. [ShowInInspector]
  118. [NativeWrapper]
  119. public uint SubMeshCount
  120. {
  121. get { return Internal_getSubMeshCount(mCachedPtr); }
  122. }
  123. /// <summary>
  124. /// Accesses the vertex and index data of the mesh. If reading, mesh must have been created with the MeshUsage::CPUCached
  125. /// flag. If writing the caller must ensure the data matches mesh's vertex/index counts, vertex layout and index format.
  126. /// </summary>
  127. [ShowInInspector]
  128. [NativeWrapper]
  129. public MeshData MeshData
  130. {
  131. get { return Internal_getMeshData(mCachedPtr); }
  132. set { Internal_setMeshData(mCachedPtr, value); }
  133. }
  134. /// <summary>Returns a reference wrapper for this resource.</summary>
  135. public static implicit operator RRef<Mesh>(Mesh x)
  136. { return Internal_GetRef(x.mCachedPtr); }
  137. [MethodImpl(MethodImplOptions.InternalCall)]
  138. private static extern RRef<Mesh> Internal_GetRef(IntPtr thisPtr);
  139. [MethodImpl(MethodImplOptions.InternalCall)]
  140. private static extern Skeleton Internal_getSkeleton(IntPtr thisPtr);
  141. [MethodImpl(MethodImplOptions.InternalCall)]
  142. private static extern MorphShapes Internal_getMorphShapes(IntPtr thisPtr);
  143. [MethodImpl(MethodImplOptions.InternalCall)]
  144. private static extern void Internal_create(Mesh managedInstance, int numVertices, int numIndices, MeshTopology topology, MeshUsage usage, VertexLayout vertex, IndexType index);
  145. [MethodImpl(MethodImplOptions.InternalCall)]
  146. private static extern void Internal_create0(Mesh managedInstance, int numVertices, int numIndices, SubMesh[] subMeshes, MeshUsage usage, VertexLayout vertex, IndexType index);
  147. [MethodImpl(MethodImplOptions.InternalCall)]
  148. private static extern void Internal_create1(Mesh managedInstance, MeshData data, MeshTopology topology, MeshUsage usage);
  149. [MethodImpl(MethodImplOptions.InternalCall)]
  150. private static extern void Internal_create2(Mesh managedInstance, MeshData data, SubMesh[] subMeshes, MeshUsage usage);
  151. [MethodImpl(MethodImplOptions.InternalCall)]
  152. private static extern SubMesh[] Internal_getSubMeshes(IntPtr thisPtr);
  153. [MethodImpl(MethodImplOptions.InternalCall)]
  154. private static extern uint Internal_getSubMeshCount(IntPtr thisPtr);
  155. [MethodImpl(MethodImplOptions.InternalCall)]
  156. private static extern void Internal_getBounds(IntPtr thisPtr, out AABox box, out Sphere sphere);
  157. [MethodImpl(MethodImplOptions.InternalCall)]
  158. private static extern MeshData Internal_getMeshData(IntPtr thisPtr);
  159. [MethodImpl(MethodImplOptions.InternalCall)]
  160. private static extern void Internal_setMeshData(IntPtr thisPtr, MeshData value);
  161. }
  162. /** @} */
  163. }