[C++] The IN55 project
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.

63 lines
1.2KB

  1. /*
  2. * Skia < lordbanana25 AT mailoo DOT org >
  3. *
  4. * Beerware licensed software - 2016
  5. */
  6. #ifndef __MODEL_H__
  7. #define __MODEL_H__
  8. #include <vector>
  9. #include <vectors.h>
  10. class FaceVertex
  11. {
  12. private:
  13. int v[3];
  14. public:
  15. FaceVertex() { v[0] = 0; v[1] = 0; v[2] = 0; }
  16. friend std::ostream& operator<<(std::ostream& os, const FaceVertex& v) {
  17. return os << "(" << v.v[0] << ", " << v.v[1] << ", " << v.v[2] << ")";
  18. }
  19. friend std::istream& operator>>(std::istream& is, FaceVertex& obj);
  20. };
  21. class Face
  22. {
  23. private:
  24. FaceVertex v1, v2, v3;
  25. public:
  26. Face(FaceVertex V1, FaceVertex V2, FaceVertex V3) : v1(V1), v2(V2), v3(V3) {}
  27. friend std::ostream& operator<<(std::ostream& os, const Face& f) {
  28. return os << f.v1 << f.v2 << f.v3;
  29. }
  30. };
  31. class Model
  32. {
  33. public:
  34. void loadFile(const char *filename);
  35. void saveModel();
  36. void printVertex();
  37. private:
  38. std::vector<Vec3> vertex_list;
  39. std::vector<Vec2> texture_list;
  40. std::vector<Face> face_list;
  41. float max_x;
  42. float min_x;
  43. float max_y;
  44. float min_y;
  45. float max_z;
  46. float min_z;
  47. };
  48. #endif