CmMesh.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. protected:
  52. friend class MeshManager;
  53. Mesh();
  54. VertexData* mVertexData;
  55. IndexData* mIndexData;
  56. vector<SubMesh>::type mSubMeshes;
  57. void throwIfNotRenderThread() const;
  58. /**
  59. * @copydoc Resource::initialize_internal()
  60. */
  61. virtual void initialize_internal();
  62. /**
  63. * @copydoc Resource::destroy_internal()
  64. */
  65. virtual void destroy_internal();
  66. /************************************************************************/
  67. /* SERIALIZATION */
  68. /************************************************************************/
  69. public:
  70. friend class MeshRTTI;
  71. static RTTITypeBase* getRTTIStatic();
  72. virtual RTTITypeBase* getRTTI() const;
  73. /************************************************************************/
  74. /* STATICS */
  75. /************************************************************************/
  76. public:
  77. static HMesh create();
  78. };
  79. }