CmMesh.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmResource.h"
  4. #include "CmMeshData.h"
  5. #include "CmVertexData.h"
  6. #include "CmIndexData.h"
  7. #include "CmRenderOperation.h"
  8. namespace CamelotEngine
  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 Resource
  22. {
  23. public:
  24. virtual ~Mesh();
  25. /**
  26. * @brief Mesh data that is used for initializing the mesh. Needs to be set before calling load.
  27. */
  28. void setMeshData(MeshDataPtr meshData);
  29. void setMeshData_internal(MeshDataPtr meshData);
  30. /**
  31. * @brief Gets the mesh data from the GPU. This method is slow so be careful when you call it.
  32. */
  33. MeshDataPtr getMeshData();
  34. void getMeshData_internal(AsyncOp& asyncOp);
  35. RenderOperation getRenderOperation(UINT32 subMeshIdx = 0) const;
  36. protected:
  37. friend class MeshManager;
  38. Mesh();
  39. VertexData* mVertexData;
  40. IndexData* mIndexData;
  41. vector<SubMesh>::type mSubMeshes;
  42. void throwIfNotRenderThread() const;
  43. /**
  44. * @copydoc Resource::initialize_internal()
  45. */
  46. virtual void initialize_internal();
  47. /**
  48. * @copydoc Resource::destroy_internal()
  49. */
  50. virtual void destroy_internal();
  51. /************************************************************************/
  52. /* SERIALIZATION */
  53. /************************************************************************/
  54. public:
  55. friend class MeshRTTI;
  56. static RTTITypeBase* getRTTIStatic();
  57. virtual RTTITypeBase* getRTTI() const;
  58. /************************************************************************/
  59. /* STATICS */
  60. /************************************************************************/
  61. public:
  62. static MeshHandle create();
  63. };
  64. }