Mesh.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <vector>
  10. #include <string>
  11. #include "Collision.h"
  12. class Mesh
  13. {
  14. public:
  15. Mesh();
  16. ~Mesh();
  17. // Load/unload mesh
  18. bool Load(const std::string& fileName, class Renderer* renderer);
  19. void Unload();
  20. // Get the vertex array associated with this mesh
  21. class VertexArray* GetVertexArray() { return mVertexArray; }
  22. // Get a texture from specified index
  23. class Texture* GetTexture(size_t index);
  24. // Get name of shader
  25. const std::string& GetShaderName() const { return mShaderName; }
  26. // Get object space bounding sphere radius
  27. float GetRadius() const { return mRadius; }
  28. // Get object space bounding box
  29. const AABB& GetBox() const { return mBox; }
  30. // Get specular power of mesh
  31. float GetSpecPower() const { return mSpecPower; }
  32. private:
  33. // AABB collision
  34. AABB mBox;
  35. // Textures associated with this mesh
  36. std::vector<class Texture*> mTextures;
  37. // Vertex array associated with this mesh
  38. class VertexArray* mVertexArray;
  39. // Name of shader specified by mesh
  40. std::string mShaderName;
  41. // Stores object space bounding sphere radius
  42. float mRadius;
  43. // Specular power of surface
  44. float mSpecPower;
  45. };