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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/gtc/quaternion.hpp>
  10. #include <glm/gtc/type_precision.hpp>
  11. #include "RoomData.h"
  12. class Camera {
  13. public:
  14. static void reset();
  15. static bool update();
  16. static void setSize(glm::i32vec2 s);
  17. static void handleAction(ActionEvents action, bool isFinished);
  18. static void handleMouseMotion(int x, int y);
  19. static void handleControllerAxis(float value, KeyboardButton axis);
  20. static void handleControllerButton(KeyboardButton button, bool released);
  21. //! \fixme The Y axis seems to be the source of all evil?
  22. static void setPosition(glm::vec3 p) { pos = glm::vec3(p.x, -p.y, p.z); }
  23. static glm::vec3 getPosition() { return glm::vec3(pos.x, -pos.y, pos.z); }
  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::mat4 projection;
  42. static glm::mat4 view;
  43. static float rotationDeltaX, rotationDeltaY;
  44. static bool updateViewFrustum, dirty;
  45. };
  46. #endif