diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2019-04-01 11:00:10 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2019-04-01 11:00:10 +0300 |
commit | d87b478d6057de5085feaf0890a16fcc9b407438 (patch) | |
tree | 81b38f4a4bde2abe8265320ff3f14dcdadb533dc /src/slic3r/GUI/Camera.hpp | |
parent | 1ce3bb690c1378a5af71594876fde24b9e79739e (diff) | |
parent | ba89f04429cd89da25c97c9d474697ac4fe14700 (diff) |
Camera refactoring
1) All camera related OpenGL calls moved into class
2) The Camera class now stores the view matrix, the projection matrix and the viewport
3) The Camera class now exposes methods to get the camera orientation vectors, the camera position, the view matrix, the projection matrix and the viewport
4) All the code operating on the camera or requiring camera data has been modified to use the new methods
Diffstat (limited to 'src/slic3r/GUI/Camera.hpp')
-rw-r--r-- | src/slic3r/GUI/Camera.hpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp index d50dc6e4d..ff2d3aa31 100644 --- a/src/slic3r/GUI/Camera.hpp +++ b/src/slic3r/GUI/Camera.hpp @@ -26,6 +26,10 @@ private: Vec3d m_target; float m_theta; + mutable std::array<int, 4> m_viewport; + mutable Transform3d m_view_matrix; + mutable Transform3d m_projection_matrix; + BoundingBoxf3 m_scene_box; public: @@ -41,6 +45,22 @@ public: const BoundingBoxf3& get_scene_box() const { return m_scene_box; } void set_scene_box(const BoundingBoxf3& box); + + bool select_view(const std::string& direction); + + const std::array<int, 4>& get_viewport() const { return m_viewport; } + const Transform3d& get_view_matrix() const { return m_view_matrix; } + const Transform3d& get_projection_matrix() const { return m_projection_matrix; } + + Vec3d get_dir_right() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(0); } + Vec3d get_dir_up() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(1); } + Vec3d get_dir_forward() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(2); } + + Vec3d get_position() const { return m_view_matrix.matrix().block(0, 0, 3, 3).row(3); } + + void apply_viewport(int x, int y, unsigned int w, unsigned int h) const; + void apply_view_matrix() const; + void apply_ortho_projection(float x_min, float x_max, float y_min, float y_max, float z_min, float z_max) const; }; } // GUI |