model.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef MODEL_H
  2. #define MODEL_H
  3. // ===============================
  4. // AUTHOR : Angel Ortiz (angelo12 AT vt DOT edu)
  5. // CREATE DATE : 2018-07-03
  6. // PURPOSE : Container for all of the data realted to a model such as texture data,
  7. // mesh data and even a model matrix for transformations.
  8. // It has an update method that could be called based on physics updates
  9. // but is not much more than a stub.
  10. // ===============================
  11. // SPECIAL NOTES: Should probably be rewritten to be a struct instead of having to use
  12. // all of these useless getters. This class is little more than a glorified container.
  13. // ===============================
  14. //Headers
  15. #include <string>
  16. #include "mesh.h"
  17. #include "geometry.h"
  18. #include "matrix.h"
  19. #include "texture.h"
  20. #include "objParser.h"
  21. class Model{
  22. public:
  23. //On model creation all textures are loaded, the mesh is built and even an
  24. //AABB is built.
  25. Model( const TransformParameters &initParameters, const std::string meshPath, const std::string materialPath) :
  26. mAlbedo(materialPath + "_albedo.png", "RGB"),
  27. mNormal(materialPath + "_normal.png", "XYZ"),
  28. mAmbient(materialPath + "_ao.png", "BW"),
  29. mRoughness(materialPath + "_rough.png", "BW"),
  30. mMetallic(materialPath + "_metal.png", "BW"),
  31. mModelMatrix(Matrix4::transformMatrix(initParameters))
  32. {
  33. OBJ::buildMeshFromFile(mMesh, meshPath);
  34. mBounds.buildAABB(mMesh);
  35. mMesh.buildFacetNormals();
  36. mMesh.buildTangentSpace();
  37. };
  38. //TODO: too many getters, unify into one method?
  39. Mesh *getMesh();
  40. Matrix4 *getModelMatrix();
  41. AABox *getBounds();
  42. Texture *getAlbedo();
  43. Texture *getNormal();
  44. Texture *getAO();
  45. Texture *getRoughness();
  46. Texture *getMetallic();
  47. void update();
  48. //Prints the mesh vertices for debugging
  49. void describeMesh();
  50. private:
  51. Texture mAlbedo;
  52. Texture mNormal;
  53. Texture mAmbient;
  54. Texture mRoughness;
  55. Texture mMetallic;
  56. Mesh mMesh;
  57. AABox mBounds;
  58. Matrix4 mModelMatrix;
  59. };
  60. #endif