Mesh.generated.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. public Skeleton Skeleton
  98. {
  99. get { return Internal_getSkeleton(mCachedPtr); }
  100. }
  101. /// <summary>Returns an object containing all shapes used for morph animation, if any are available.</summary>
  102. [ShowInInspector]
  103. public MorphShapes MorphShapes
  104. {
  105. get { return Internal_getMorphShapes(mCachedPtr); }
  106. }
  107. /// <summary>Returns all sub-meshes contained in the mesh.</summary>
  108. [ShowInInspector]
  109. public SubMesh[] SubMeshes
  110. {
  111. get { return Internal_getSubMeshes(mCachedPtr); }
  112. }
  113. /// <summary>Returns the number of sub-meshes contained in this mesh.</summary>
  114. [ShowInInspector]
  115. public uint SubMeshCount
  116. {
  117. get { return Internal_getSubMeshCount(mCachedPtr); }
  118. }
  119. /// <summary>
  120. /// Accesses the vertex and index data of the mesh. If reading, mesh must have been created with the MeshUsage::CPUCached
  121. /// flag. If writing the caller must ensure the data matches mesh's vertex/index counts, vertex layout and index format.
  122. /// </summary>
  123. [ShowInInspector]
  124. public MeshData MeshData
  125. {
  126. get { return Internal_getMeshData(mCachedPtr); }
  127. set { Internal_setMeshData(mCachedPtr, value); }
  128. }
  129. /// <summary>Returns a reference wrapper for this resource.</summary>
  130. public static implicit operator RRef<Mesh>(Mesh x)
  131. { return Internal_GetRef(x.mCachedPtr); }
  132. [MethodImpl(MethodImplOptions.InternalCall)]
  133. private static extern RRef<Mesh> Internal_GetRef(IntPtr thisPtr);
  134. [MethodImpl(MethodImplOptions.InternalCall)]
  135. private static extern Skeleton Internal_getSkeleton(IntPtr thisPtr);
  136. [MethodImpl(MethodImplOptions.InternalCall)]
  137. private static extern MorphShapes Internal_getMorphShapes(IntPtr thisPtr);
  138. [MethodImpl(MethodImplOptions.InternalCall)]
  139. private static extern void Internal_create(Mesh managedInstance, int numVertices, int numIndices, MeshTopology topology, MeshUsage usage, VertexLayout vertex, IndexType index);
  140. [MethodImpl(MethodImplOptions.InternalCall)]
  141. private static extern void Internal_create0(Mesh managedInstance, int numVertices, int numIndices, SubMesh[] subMeshes, MeshUsage usage, VertexLayout vertex, IndexType index);
  142. [MethodImpl(MethodImplOptions.InternalCall)]
  143. private static extern void Internal_create1(Mesh managedInstance, MeshData data, MeshTopology topology, MeshUsage usage);
  144. [MethodImpl(MethodImplOptions.InternalCall)]
  145. private static extern void Internal_create2(Mesh managedInstance, MeshData data, SubMesh[] subMeshes, MeshUsage usage);
  146. [MethodImpl(MethodImplOptions.InternalCall)]
  147. private static extern SubMesh[] Internal_getSubMeshes(IntPtr thisPtr);
  148. [MethodImpl(MethodImplOptions.InternalCall)]
  149. private static extern uint Internal_getSubMeshCount(IntPtr thisPtr);
  150. [MethodImpl(MethodImplOptions.InternalCall)]
  151. private static extern void Internal_getBounds(IntPtr thisPtr, out AABox box, out Sphere sphere);
  152. [MethodImpl(MethodImplOptions.InternalCall)]
  153. private static extern MeshData Internal_getMeshData(IntPtr thisPtr);
  154. [MethodImpl(MethodImplOptions.InternalCall)]
  155. private static extern void Internal_setMeshData(IntPtr thisPtr, MeshData value);
  156. }
  157. /** @} */
  158. }