Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Camera.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*!
  2. * \file include/Camera.h
  3. * \brief Camera class
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _CAMERA_H_
  8. #define _CAMERA_H_
  9. #include <glm/vec2.hpp>
  10. #include <glm/vec3.hpp>
  11. #include <glm/mat4x4.hpp>
  12. #include <glm/gtc/quaternion.hpp>
  13. #include "RoomData.h"
  14. class Camera {
  15. public:
  16. static void reset();
  17. static bool update();
  18. static void handleAction(ActionEvents action, bool isFinished);
  19. static void handleMouseMotion(int x, int y);
  20. static void handleControllerAxis(float value, KeyboardButton axis);
  21. static void handleControllerButton(KeyboardButton button, bool released);
  22. static void setPosition(glm::vec3 p) { pos = p; }
  23. static glm::vec3 getPosition() { return pos; }
  24. static glm::vec2 getRotation();
  25. static glm::mat4 getProjectionMatrix() { return projection; }
  26. static glm::mat4 getViewMatrix() { return view; }
  27. static void setSensitivityX(float sens) { rotationDeltaX = sens; }
  28. static float getSensitivityX() { return rotationDeltaX; }
  29. static void setSensitivityY(float sens) { rotationDeltaY = sens; }
  30. static float getSensitivityY() { return rotationDeltaY; }
  31. static void setUpdateViewFrustum(bool u) { updateViewFrustum = u; }
  32. static bool getUpdateViewFrustum() { return updateViewFrustum; }
  33. static bool boxInFrustum(BoundingBox b);
  34. static void displayFrustum(glm::mat4 MVP);
  35. private:
  36. static void calculateFrustumPlanes();
  37. static glm::vec3 pos;
  38. static glm::quat quaternion;
  39. static glm::vec3 posSpeed;
  40. static glm::vec2 rotSpeed;
  41. static glm::vec2 lastSize;
  42. static glm::mat4 projection;
  43. static glm::mat4 view;
  44. static float rotationDeltaX, rotationDeltaY;
  45. static bool updateViewFrustum;
  46. };
  47. #endif