CMesh.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "WallpaperEngine/Scripting/ScriptableObject.h"
  3. #include <glm/mat3x3.hpp>
  4. #include <glm/mat4x4.hpp>
  5. namespace WallpaperEngine::Render::Objects {
  6. using namespace WallpaperEngine::Data::Model;
  7. /**
  8. * A static 3D model ("model" objects), in 3D scenes or placed in a 2D one. Every mesh in the .mdl has its own material
  9. * and is drawn straight into the scene buffer with depth testing, the bind pose only (no skinning or animation yet)
  10. */
  11. class CMesh final : public Scripting::ScriptableObject {
  12. public:
  13. CMesh (Wallpapers::CScene& scene, const Mesh& mesh);
  14. ~CMesh () override;
  15. void setup () override;
  16. void render () override;
  17. [[nodiscard]] const Mesh& getMesh () const;
  18. [[nodiscard]] const glm::mat4& getModelMatrix () const;
  19. [[nodiscard]] const glm::mat3& getNormalMatrix () const;
  20. [[nodiscard]] const glm::mat4& getViewProjectionMatrix () const;
  21. [[nodiscard]] const glm::mat4& getModelViewProjectionMatrix () const;
  22. [[nodiscard]] const glm::mat4& getModelViewProjectionMatrixInverse () const;
  23. [[nodiscard]] const glm::vec3& getEyePosition () const;
  24. class Part;
  25. private:
  26. void updateMatrices ();
  27. const Mesh& m_mesh;
  28. std::vector<MaterialUniquePtr> m_materials;
  29. std::vector<std::unique_ptr<Part>> m_parts;
  30. glm::mat4 m_modelMatrix = glm::mat4 (1.0f);
  31. glm::mat3 m_normalMatrix = glm::mat3 (1.0f);
  32. glm::mat4 m_viewProjection = glm::mat4 (1.0f);
  33. glm::mat4 m_modelViewProjection = glm::mat4 (1.0f);
  34. glm::mat4 m_modelViewProjectionInverse = glm::mat4 (1.0f);
  35. glm::vec3 m_eyePosition = glm::vec3 (0.0f);
  36. };
  37. } // namespace WallpaperEngine::Render::Objects