Model.h 844 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "Header.h"
  3. #include "ModelLoader.h"
  4. #include "Vector.h"
  5. class Model
  6. {
  7. private:
  8. class Vertex
  9. {
  10. public:
  11. int position;
  12. int normal;
  13. int texcoord;
  14. };
  15. class Face
  16. {
  17. public:
  18. list<Vertex> vertices;
  19. };
  20. class Texture
  21. {
  22. GLuint index;
  23. public:
  24. Texture(const std::string &fileName);
  25. void bind();
  26. };
  27. class MaterialInfo
  28. {
  29. public:
  30. MaterialInfo();
  31. std::string name;
  32. Texture* texture;
  33. bool hasTexture;
  34. };
  35. class ObjGroup
  36. {
  37. public:
  38. std::string name;
  39. int materialIndex;
  40. list<Face> faces;
  41. };
  42. std::vector<Vec3f> vertices;
  43. std::vector<Vec3f> normals;
  44. std::vector<Vec2f> texcoords;
  45. std::vector<ObjGroup*> groups;
  46. std::vector<MaterialInfo*> materials;
  47. void loadMaterialFile(std::string fileName, std::string dirName);
  48. public:
  49. Model(std::string filename);
  50. ~Model(void);
  51. void draw();
  52. };