2
0

Mesh.generated.cs 7.4 KB

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