Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Camera.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. static void handleControllerButton(KeyboardButton button, bool released);
  20. //! \fixme The Y axis seems to be the source of all evil?
  21. static void setPosition(glm::vec3 p) { pos = glm::vec3(p.x, -p.y, p.z); }
  22. static glm::vec3 getPosition() { return glm::vec3(pos.x, -pos.y, pos.z); }
  23. static glm::vec2 getRotation() { return rot; }
  24. static glm::mat4 getProjectionMatrix() { return projection; }
  25. static glm::mat4 getViewMatrix() { return view; }
  26. static void setSensitivityX(float sens) { rotationDeltaX = sens; }
  27. static float getSensitivityX() { return rotationDeltaX; }
  28. static void setSensitivityY(float sens) { rotationDeltaY = sens; }
  29. static float getSensitivityY() { return rotationDeltaY; }
  30. static void setUpdateViewFrustum(bool u) { updateViewFrustum = u; }
  31. static bool getUpdateViewFrustum() { return updateViewFrustum; }
  32. static bool boxInFrustum(BoundingBox b);
  33. static void displayFrustum(glm::mat4 MVP);
  34. private:
  35. static void calculateFrustumPlanes();
  36. static glm::vec3 pos;
  37. static glm::vec2 rot;
  38. static glm::vec3 posSpeed;
  39. static glm::vec2 rotSpeed;
  40. static glm::mat4 projection;
  41. static glm::mat4 view;
  42. static float rotationDeltaX, rotationDeltaY;
  43. static bool updateViewFrustum, dirty;
  44. };
  45. #endif