Model.h 1.0 KB

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