#pragma once #include #include "../glIncludes.h" /** * @class Camera_ * @brief Struct that updates the model-view and projection matrix for openGL * using the glm library. Multiple cameras can be defined on a scene by scene * basis, although the projection matrix is a global attribute and needs to be * updated each time a camera is swapped. * * @author Chase Percy * */ class Camera_ { private: /** * @struct Movement * @brief Private movement struct to store movement flags. This allows the * camera to move in more than one direction at once, i.e. forward and left, * but increases speed, similar to quake style movement. * * @author Chase Percy */ struct Movement { bool forward{false}; /// True if forward movement has been set. bool backward{false}; /// True if backward movement has been set. bool left{false}; /// True if left movement has been set. bool right{false}; /// True if right movement has been set. bool freeCam{true}; /// Toggle between FPS or free cam }; bool m_lock{ true}; /// internal lock variable to track the cameras current state.s public: glm::vec3 position{0.f, 0.f, 0.f}; /// The current position of the camera glm::vec3 front{0.f, 0.f, -1.0f}; /// The facing direction of the camera glm::vec3 up{0.f, 1.0f, 0}; /// The up vector of the camera (roll) glm::vec3 direction{0.f, 0.f, 0.f}; /// The direction for mouse look float yaw{0.f}; /// The yaw angle for mouse look float pitch{0.f}; /// The pitch for mouse look Movement move; /// The movement struct for what directions to update float speed{1.f}; /// The movement speed of the camera float sensitivity{0.1f}; /// The sensitivity of the camera glm::mat4 perspectiveMatrix{0.f}; glm::mat4 viewMatrix{1.0f}; bool mouseLook{true}; /** * Sets the perspective of the camera. Must be called each time a state is * loaded or swapped. * @param fovY The fov in the y direction (45 is a good default) * @param aspect The aspect ratio for our camera (width/height) * @param zNear How close in front of the camera we want to render * @param zFar How far from the camera we want to render */ void setPerspective(float fovY, float aspect, float zNear, float zFar); /** * The update function for the camera. Updates the modelView matrix. * @param deltaTime The elapsed time between frames */ void update(float deltaTime); /** * Locks the mouse and makes it invisible or unlocks it to a normal state. * @param lock true for lock, false for unlock. */ void lockMouse(bool lock); /** * Returns the value of lock. * @return lock */ bool isLocked() const; };