CmMesh.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmGpuResource.h"
  4. #include "CmMeshData.h"
  5. #include "CmVertexData.h"
  6. #include "CmIndexData.h"
  7. #include "CmRenderOperation.h"
  8. namespace CamelotFramework
  9. {
  10. struct CM_EXPORT SubMesh
  11. {
  12. SubMesh():
  13. indexOffset(0), indexCount(0)
  14. { }
  15. SubMesh(UINT32 indexOffset, UINT32 indexCount):
  16. indexOffset(indexOffset), indexCount(indexCount)
  17. { }
  18. UINT32 indexOffset;
  19. UINT32 indexCount;
  20. };
  21. class CM_EXPORT Mesh : public GpuResource
  22. {
  23. public:
  24. virtual ~Mesh();
  25. /**
  26. * @copydoc GpuResource::writeSubresource
  27. */
  28. virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data);
  29. /**
  30. * @copydoc GpuResource::readSubresource
  31. */
  32. virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data);
  33. /**
  34. * @brief Allocates a buffer you may use for storage when reading a subresource. You
  35. * need to allocate such a buffer if you are calling "readSubresource".
  36. *
  37. * @note This method is thread safe.
  38. */
  39. MeshDataPtr allocateSubresourceBuffer(UINT32 subresourceIdx) const;
  40. /**
  41. * @brief TODO - Currently does nothing. But normally it should provide a way to map subresource index to
  42. * a specific submesh or buffer stream. Right now you can only work with entire mesh at once, not its subsets.
  43. */
  44. void mapFromSubresourceIdx(UINT32 subresourceIdx) const {}
  45. /**
  46. * @brief TODO - Currently does nothing. But normally it should provide a way to map submesh or stream index to
  47. * a specific subresource index. Right now you can only work with entire mesh at once, not its subsets.
  48. */
  49. UINT32 mapToSubresourceIdx() const { return 0; }
  50. RenderOperation getRenderOperation(UINT32 subMeshIdx = 0) const;
  51. /**
  52. * @brief Returns a dummy mesh, containing just one triangle. Don't modify the returned mesh.
  53. */
  54. static HMesh dummy();
  55. protected:
  56. friend class MeshManager;
  57. Mesh();
  58. VertexData* mVertexData;
  59. IndexData* mIndexData;
  60. Vector<SubMesh>::type mSubMeshes;
  61. /**
  62. * @copydoc Resource::initialize_internal()
  63. */
  64. virtual void initialize_internal();
  65. /**
  66. * @copydoc Resource::destroy_internal()
  67. */
  68. virtual void destroy_internal();
  69. /************************************************************************/
  70. /* SERIALIZATION */
  71. /************************************************************************/
  72. public:
  73. friend class MeshRTTI;
  74. static RTTITypeBase* getRTTIStatic();
  75. virtual RTTITypeBase* getRTTI() const;
  76. /************************************************************************/
  77. /* STATICS */
  78. /************************************************************************/
  79. public:
  80. static HMesh create();
  81. };
  82. }