BsMeshManager.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. #include "BsMesh.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Manager that handles creation of Meshes.
  9. */
  10. class BS_CORE_EXPORT MeshManager : public Module<MeshManager>
  11. {
  12. public:
  13. MeshManager();
  14. ~MeshManager();
  15. /**
  16. * @brief Creates an empty mesh with enough space to store vertex and index data described by the parameters.
  17. *
  18. * @param numVertices Number of vertices in the mesh.
  19. * @param numIndices Number of indices in the mesh.
  20. * @param vertexDesc Vertex description that describes how are vertices organized within the vertex buffer(s).
  21. * @param bufferType Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
  22. * updating the mesh often, or static otherwise.
  23. * @param drawOp Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
  24. * @param indexType Type of indexes in the index buffer. Determines size of an index.
  25. */
  26. MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, MeshBufferType bufferType = MeshBufferType::Static,
  27. DrawOperationType drawOp = DOT_TRIANGLE_LIST, IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
  28. /**
  29. * @brief Creates an mesh with enough space to store vertex and index data described by the parameters, and initializes
  30. * a portion (or entire) mesh with some data.
  31. *
  32. * @param numVertices Number of vertices in the mesh.
  33. * @param numIndices Number of indices in the mesh.
  34. * @param vertexDesc Vertex description that describes how are vertices organized within the vertex buffer(s).
  35. * @param initialData Initial data to initialize the mesh with. Internal offsets in this object will be used to
  36. * determine where to write the data in the Mesh buffers.
  37. * @param bufferType Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
  38. * updating the mesh often, or static otherwise.
  39. * @param drawOp Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
  40. * @param indexType Type of indexes in the index buffer. Determines size of an index.
  41. */
  42. MeshPtr create(UINT32 numVertices, UINT32 numIndices, const VertexDataDescPtr& vertexDesc, const MeshDataPtr& initialData,
  43. MeshBufferType bufferType = MeshBufferType::Static, DrawOperationType drawOp = DOT_TRIANGLE_LIST,
  44. IndexBuffer::IndexType indexType = IndexBuffer::IT_32BIT);
  45. /**
  46. * @brief Creates a mesh and initializes it with the provided data. Mesh will be of exact size needed to hold the data.
  47. *
  48. * @param initialData Initial data to initialize the mesh with. Size of the buffers and vertex declaration will be taken
  49. * from this object.
  50. * @param bufferType Type of buffers to use to store mesh vertex and index data. Specify dynamic if you plan on
  51. * updating the mesh often, or static otherwise.
  52. * @param drawOp Informs the render system on how to draw the mesh. Determines how are indices and vertices interpreted.
  53. */
  54. MeshPtr create(const MeshDataPtr& initialData, MeshBufferType bufferType = MeshBufferType::Static,
  55. DrawOperationType drawOp = DOT_TRIANGLE_LIST);
  56. /**
  57. * @brief Creates a new empty and uninitialized mesh. You will need to manually initialize the mesh before using it.
  58. *
  59. * @note This should only be used for special cases and is not meant for normal use.
  60. */
  61. MeshPtr createEmpty();
  62. /**
  63. * @brief Returns some dummy mesh data with one triangle you may use for initializing a mesh.
  64. */
  65. MeshDataPtr getDummyMeshData() const { return mDummyMeshData; }
  66. /**
  67. * @brief Returns a dummy mesh containing one triangle.
  68. */
  69. HMesh getDummyMesh() const { return mDummyMesh; }
  70. protected:
  71. /**
  72. * @copydoc Module::onStartUp
  73. */
  74. virtual void onStartUp();
  75. private:
  76. MeshDataPtr mDummyMeshData;
  77. HMesh mDummyMesh;
  78. };
  79. }