Model.h 868 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. Vec3f diffuseColor;
  35. };
  36. class ObjGroup
  37. {
  38. public:
  39. std::string name;
  40. int materialIndex;
  41. list<Face> faces;
  42. };
  43. std::vector<Vec3f> vertices;
  44. std::vector<Vec3f> normals;
  45. std::vector<Vec2f> texcoords;
  46. std::vector<ObjGroup*> groups;
  47. std::vector<MaterialInfo*> materials;
  48. void loadMaterialFile(std::string fileName, std::string dirName);
  49. public:
  50. Model(std::string filename);
  51. ~Model(void);
  52. void draw();
  53. };