Model.h 971 B

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