CmMesh.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmResource.h"
  4. #include "CmMeshData.h"
  5. #include "CmVertexIndexData.h"
  6. #include "CmRenderOperation.h"
  7. namespace CamelotEngine
  8. {
  9. struct CM_EXPORT SubMesh
  10. {
  11. SubMesh():
  12. indexOffset(0), indexCount(0)
  13. { }
  14. SubMesh(UINT32 indexOffset, UINT32 indexCount):
  15. indexOffset(indexOffset), indexCount(indexCount)
  16. { }
  17. UINT32 indexOffset;
  18. UINT32 indexCount;
  19. };
  20. class CM_EXPORT Mesh : public Resource
  21. {
  22. public:
  23. Mesh();
  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. /**
  30. * @brief Gets the mesh data from the GPU. This method is slow so be careful when you call it.
  31. */
  32. MeshDataPtr getMeshData();
  33. RenderOperation getRenderOperation(UINT32 subMeshIdx = 0) const;
  34. virtual void initImpl();
  35. private:
  36. MeshDataPtr mMeshData;
  37. VertexData* mVertexData;
  38. IndexData* mIndexData;
  39. vector<SubMesh>::type mSubMeshes;
  40. /************************************************************************/
  41. /* SERIALIZATION */
  42. /************************************************************************/
  43. public:
  44. friend class MeshRTTI;
  45. static RTTITypeBase* getRTTIStatic();
  46. virtual RTTITypeBase* getRTTI() const;
  47. };
  48. }