model.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef MODEL_H
  2. #define MODEL_H
  3. #include <string>
  4. #include "mesh.h"
  5. #include "geometry.h"
  6. #include "matrix.h"
  7. #include "texture.h"
  8. #include "objParser.h"
  9. class Model{
  10. public:
  11. Model(std::string basePath, TransformParameters &initParameters) :
  12. mAlbedo(basePath + "_albedo.png", "RGB"),
  13. mNormal(basePath + "_normal.png", "XYZ"),
  14. mAmbient(basePath + "_ao.png", "BW"),
  15. mRoughness(basePath + "_rough.png", "BW"),
  16. mMetallic(basePath + "_metal.png", "BW"),
  17. mModelMatrix(Matrix4::transformMatrix(initParameters))
  18. {
  19. OBJ::buildMeshFromFile(mMesh, basePath + "_mesh.obj");
  20. mBounds.buildAABB(mMesh);
  21. mMesh.buildFacetNormals();
  22. mMesh.buildTangentSpace();
  23. };
  24. //TODO: too many getters, unify into one method?
  25. Mesh *getMesh();
  26. Matrix4 *getModelMatrix();
  27. AABox *getBounds();
  28. Texture *getAlbedo();
  29. Texture *getNormal();
  30. Texture *getAO();
  31. Texture *getRoughness();
  32. Texture *getMetallic();
  33. void update();
  34. //Prints the mesh vertices for debugging
  35. void describeMesh();
  36. private:
  37. Texture mAlbedo;
  38. Texture mNormal;
  39. Texture mAmbient;
  40. Texture mRoughness;
  41. Texture mMetallic;
  42. Mesh mMesh;
  43. AABox mBounds;
  44. Matrix4 mModelMatrix;
  45. };
  46. #endif