Simple game engine with complete export to scripting language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MeshManager.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef BLUECORE_MESH_MANAGER_H
  2. #define BLUECORE_MESH_MANAGER_H
  3. #include <map>
  4. #include <string>
  5. #include "RenderDevice.h"
  6. #include "Math/Vector.h"
  7. #include "Math/Plane.h"
  8. #include "Utilities/Buffer.h"
  9. #include "Utilities/Referenced.h"
  10. namespace BlueCore {
  11. typedef struct
  12. {
  13. Vector3Float point;
  14. float u, v;
  15. Vector3Float normal;
  16. } Vertex;
  17. typedef struct
  18. {
  19. unsigned short a, b, c;
  20. } TriangleIndices;
  21. typedef struct
  22. {
  23. public:
  24. unsigned int first;
  25. unsigned int count;
  26. } Subset;
  27. typedef struct
  28. {
  29. unsigned short neighbours[3];
  30. PlaneFloat plane;
  31. bool backFace;
  32. } ShadowFace;
  33. class Mesh : public Referenced
  34. {
  35. ref_ptr<RenderDevice> _Device;
  36. public:
  37. Buffer<Vertex> VertexBuffer;
  38. Buffer<TriangleIndices> IndexBuffer;
  39. Buffer<Subset> SubsetBuffer;
  40. Buffer<Vector3Float> TangentBuffer;
  41. Buffer<Vector3Float> BitangentBuffer;
  42. Buffer<ShadowFace> shadowfaces;
  43. public:
  44. Mesh (RenderDevice* device);
  45. void render ();
  46. void upload ();
  47. protected:
  48. ~Mesh();
  49. };
  50. class MeshManager : public Referenced
  51. {
  52. private:
  53. std::map<std::string, weak_ptr<Mesh> > _Meshes;
  54. bool saveToCache ( Mesh *mesh, const std::string &name );
  55. bool loadFromCache ( Mesh *mesh, const std::string &name );
  56. ref_ptr<RenderDevice> _Device;
  57. public:
  58. MeshManager (RenderDevice *device);
  59. ~MeshManager();
  60. Mesh *loadMesh (const std::string &name);
  61. };
  62. } // namespace BlueCore
  63. #endif