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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/type_precision.hpp>
  10. #include "RoomData.h"
  11. class Camera {
  12. public:
  13. static void reset();
  14. static bool update();
  15. static void setSize(glm::i32vec2 s);
  16. static void handleAction(ActionEvents action, bool isFinished);
  17. static void handleMouseMotion(int x, int y);
  18. static void handleControllerAxis(float value, KeyboardButton axis);
  19. //! \fixme The Y axis seems to be the source of all evil?
  20. static void setPosition(glm::vec3 p) { pos = glm::vec3(p.x, -p.y, p.z); }
  21. static glm::vec3 getPosition() { return glm::vec3(pos.x, -pos.y, pos.z); }
  22. static glm::vec2 getRotation() { return rot; }
  23. static glm::mat4 getProjectionMatrix() { return projection; }
  24. static glm::mat4 getViewMatrix() { return view; }
  25. static void setSensitivityX(float sens) { rotationDeltaX = sens; }
  26. static float getSensitivityX() { return rotationDeltaX; }
  27. static void setSensitivityY(float sens) { rotationDeltaY = sens; }
  28. static float getSensitivityY() { return rotationDeltaY; }
  29. static void setUpdateViewFrustum(bool u) { updateViewFrustum = u; }
  30. static bool getUpdateViewFrustum() { return updateViewFrustum; }
  31. static bool boxInFrustum(BoundingBox b);
  32. static void displayFrustum(glm::mat4 MVP);
  33. private:
  34. static void calculateFrustumPlanes();
  35. static glm::vec3 pos;
  36. static glm::vec2 rot;
  37. static glm::vec3 posSpeed;
  38. static glm::vec2 rotSpeed;
  39. static glm::mat4 projection;
  40. static glm::mat4 view;
  41. static float rotationDeltaX, rotationDeltaY;
  42. static bool updateViewFrustum, dirty;
  43. };
  44. #endif