Masterchoc

Untitled

Dec 26th, 2017
147
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2.  
  3. #include <glm/glm.hpp>
  4. #include <glm/gtx/transform.hpp>
  5. #include <SDL2/SDL.h>
  6. #include <map>
  7.  
  8. class Camera {
  9. public:
  10.     Camera() {};
  11.     Camera(const glm::vec3& position, float fov, float aspect, float near, float far);
  12.  
  13.     inline glm::mat4 getViewProjection() const {
  14.         return m_projMatrix * glm::lookAt(m_position, m_position + m_direction, m_up);
  15.     }
  16.  
  17.     void onMouseMove(const glm::vec2& mouse);
  18.     void onKeyboard(const SDL_KeyboardEvent& event);
  19.     void update(float delta);
  20.  
  21.     virtual ~Camera();
  22.  
  23. private:
  24.     glm::vec3 m_up;
  25.     glm::vec3 m_position;
  26.     glm::vec3 m_direction;
  27.     glm::vec3 m_rotation;
  28.  
  29.     glm::vec3 m_velocity;
  30.     glm::vec3 m_friction;
  31.  
  32.     glm::mat4 m_projMatrix;
  33.     glm::mat4 m_viewMatrix;
  34.  
  35.     glm::vec2 m_mouse;
  36.     glm::vec2 m_oldMouse;
  37.  
  38.     float m_sensitivity;
  39.     float m_moveSpeed;
  40.     float m_delta;
  41.  
  42.     std::map<std::string, int> m_keys;
  43.     std::map<std::string, bool> m_keys_states;
  44. };
RAW Paste Data