diff options
author | Sebastian Park <SebPark03@gmail.com> | 2024-04-10 02:51:43 -0400 |
---|---|---|
committer | Sebastian Park <SebPark03@gmail.com> | 2024-04-10 02:51:43 -0400 |
commit | 0b0629450e2553b2f890094290528b565d607e38 (patch) | |
tree | 16d34a6123f3e50153b5fcd6466de5057cc960a0 /wave-sim/src/graphics/camera.h | |
parent | ad313dcf57437ec0d40dddbce622a11c2bc2bc23 (diff) | |
parent | 47cd8a592ecad52c1b01f27d23476c0a5afeb7f1 (diff) |
Merge branch 'shaders'
Diffstat (limited to 'wave-sim/src/graphics/camera.h')
-rw-r--r-- | wave-sim/src/graphics/camera.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/wave-sim/src/graphics/camera.h b/wave-sim/src/graphics/camera.h new file mode 100644 index 0000000..04586af --- /dev/null +++ b/wave-sim/src/graphics/camera.h @@ -0,0 +1,51 @@ +#pragma once + +#include "Eigen/Dense" + +class Camera +{ +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + Camera(); + + void setPosition(const Eigen::Vector3f &position); + void move (const Eigen::Vector3f &deltaPosition); + + void setRotation(float pitch, float yaw); + void rotate (float deltaPitch, float deltaYaw); + + void lookAt(const Eigen::Vector3f &eye, const Eigen::Vector3f &target); + + void setOrbitPoint(const Eigen::Vector3f &target); + bool getIsOrbiting(); + void setIsOrbiting(bool orbit); + void toggleIsOrbiting(); + void zoom(float zoomMultiplier); + + const Eigen::Matrix4f &getView(); + const Eigen::Matrix4f &getProjection(); + const Eigen::Vector3f &getLook(); + + void setPerspective(float fovY, float aspect, float near, float far); + void setAspect(float aspect); + +private: + void updateLook(); + void updatePitchAndYaw(); + + // Do not mess with the order of these variables. Some Eigen voodoo will cause an inexplicable crash. + + Eigen::Vector3f m_position; + + float m_pitch, m_yaw; + Eigen::Vector3f m_look; + + Eigen::Vector3f m_orbitPoint; + bool m_isOrbiting; + + Eigen::Matrix4f m_view, m_proj; + bool m_viewDirty, m_projDirty; + + float m_fovY, m_aspect, m_near, m_far; + float m_zoom; +}; |