BsMeshEx.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "Wrappers/BsScriptResource.h"
  6. #include "Mesh/BsMesh.h"
  7. #include "Renderer/BsRendererMeshData.h"
  8. namespace bs
  9. {
  10. /** @addtogroup ScriptInteropEngine
  11. * @{
  12. */
  13. /** @cond SCRIPT_EXTENSIONS */
  14. /** Extension class for Mesh, for adding additional functionality for the script version of the class. */
  15. class BS_SCRIPT_EXPORT(e:Mesh) MeshEx
  16. {
  17. public:
  18. /**
  19. * Creates a new mesh with enough space to hold the a number of primitives using the specified layout. All indices
  20. * will be part of a single sub-mesh.
  21. *
  22. * @param[in] numVertices Number of vertices in the mesh.
  23. * @param[in] numIndices Number of indices in the mesh. Must be a multiple of primitive size as specified
  24. * by provided topology.
  25. * @param[in] topology Determines how should the provided indices be interpreted by the pipeline. Default
  26. * option is a triangle list, where three indices represent a single triangle.
  27. * @param[in] usage Optimizes performance depending on planned usage of the mesh.
  28. * @param[in] vertex Controls how are vertices organized in the vertex buffer and what data they contain.
  29. * @param[in] index Size of indices, use smaller size for better performance, however be careful not to
  30. * go over the number of vertices limited by the data type size.
  31. */
  32. BS_SCRIPT_EXPORT(ec:Mesh)
  33. static HMesh create(int numVertices, int numIndices, DrawOperationType topology = DOT_TRIANGLE_LIST,
  34. MeshUsage usage = MU_STATIC, VertexLayout vertex = VertexLayout::Position, IndexType index = IT_32BIT);
  35. /**
  36. * Creates a new mesh with enough space to hold the a number of primitives using the specified layout. Indices can
  37. * be referenced by multiple sub-meshes.
  38. *
  39. * @param[in] numVertices Number of vertices in the mesh.
  40. * @param[in] numIndices Number of indices in the mesh. Must be a multiple of primitive size as specified
  41. * by provided topology.
  42. * @param[in] subMeshes Defines how are indices separated into sub-meshes, and how are those sub-meshes
  43. * rendered. Sub-meshes may be rendered independently, each with a different material.
  44. * @param[in] usage Optimizes performance depending on planned usage of the mesh.
  45. * @param[in] vertex Controls how are vertices organized in the vertex buffer and what data they contain.
  46. * @param[in] index Size of indices, use smaller size for better performance, however be careful not to
  47. * go over the number of vertices limited by the data type size.
  48. */
  49. BS_SCRIPT_EXPORT(ec:Mesh)
  50. static HMesh create(int numVertices, int numIndices, const Vector<SubMesh>& subMeshes,
  51. MeshUsage usage = MU_STATIC, VertexLayout vertex = VertexLayout::Position, IndexType index = IT_32BIT);
  52. /**
  53. * Creates a new mesh from an existing mesh data. Created mesh will match the vertex and index buffers described
  54. * by the mesh data exactly. Mesh will have no sub-meshes.
  55. *
  56. * @param[in] data Vertex and index data to initialize the mesh with.
  57. * @param[in] topology Determines how should the provided indices be interpreted by the pipeline. Default
  58. * option is a triangle list, where three indices represent a single triangle.
  59. * @param[in] usage Optimizes performance depending on planned usage of the mesh.
  60. */
  61. BS_SCRIPT_EXPORT(ec:Mesh)
  62. static HMesh create(const SPtr<RendererMeshData>& data, DrawOperationType topology = DOT_TRIANGLE_LIST,
  63. MeshUsage usage = MU_STATIC);
  64. /**
  65. * Creates a new mesh with enough space to hold the a number of primitives using the specified layout. Indices can
  66. * be referenced by multiple sub-meshes.
  67. *
  68. * @param[in] data Vertex and index data to initialize the mesh with.
  69. * @param[in] subMeshes Defines how are indices separated into sub-meshes, and how are those sub-meshes
  70. * rendered. Sub-meshes may be rendered independently, each with a different material.
  71. * @param[in] usage Optimizes performance depending on planned usage of the mesh.
  72. */
  73. BS_SCRIPT_EXPORT(ec:Mesh)
  74. static HMesh create(const SPtr<RendererMeshData>& data, const Vector<SubMesh>& subMeshes,
  75. MeshUsage usage = MU_STATIC);
  76. /** Returns all sub-meshes contained in the mesh. */
  77. BS_SCRIPT_EXPORT(e:Mesh,pr:getter,n:SubMeshes)
  78. static Vector<SubMesh> getSubMeshes(const HMesh& thisPtr);
  79. /** Returns the number of sub-meshes contained in this mesh. */
  80. BS_SCRIPT_EXPORT(e:Mesh,pr:getter,n:SubMeshCount)
  81. static UINT32 getSubMeshCount(const HMesh& thisPtr);
  82. BS_SCRIPT_EXPORT(e:Mesh,in:true)
  83. static void getBounds(const HMesh& thisPtr, AABox* box, Sphere* sphere);
  84. /**
  85. * Accesses the vertex and index data of the mesh. If reading, mesh must have been created with the
  86. * MeshUsage::CPUCached flag. If writing the caller must ensure the data matches mesh's vertex/index counts, vertex
  87. * layout and index format.
  88. */
  89. BS_SCRIPT_EXPORT(e:Mesh,pr:getter,n:MeshData)
  90. static SPtr<RendererMeshData> getMeshData(const HMesh& thisPtr);
  91. BS_SCRIPT_EXPORT(e:Mesh,pr:setter,n:MeshData)
  92. static void setMeshData(const HMesh& thisPtr, const SPtr<RendererMeshData>& value);
  93. };
  94. /** @endcond */
  95. /** @} */
  96. }