2
0

CmMesh.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. void throwIfNotRenderThread() const;
  62. /**
  63. * @copydoc Resource::initialize_internal()
  64. */
  65. virtual void initialize_internal();
  66. /**
  67. * @copydoc Resource::destroy_internal()
  68. */
  69. virtual void destroy_internal();
  70. /************************************************************************/
  71. /* SERIALIZATION */
  72. /************************************************************************/
  73. public:
  74. friend class MeshRTTI;
  75. static RTTITypeBase* getRTTIStatic();
  76. virtual RTTITypeBase* getRTTI() const;
  77. /************************************************************************/
  78. /* STATICS */
  79. /************************************************************************/
  80. public:
  81. static HMesh create();
  82. };
  83. }