Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

Camera.h 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef BZR_CAMERA_H
  19. #define BZR_CAMERA_H
  20. class Camera
  21. {
  22. public:
  23. Camera();
  24. // -dx strafe left
  25. // +dx strafe right
  26. // -dy move back
  27. // +dy move forward
  28. void move(fp_t dx, fp_t dy);
  29. // -dx look left
  30. // +dx look right
  31. // -dy look down
  32. // +dy look up
  33. void look(fp_t dx, fp_t dy);
  34. void step(fp_t dt);
  35. void setSpeed(fp_t newSpeed);
  36. void setPosition(const glm::vec3& newPosition);
  37. void setHeadPosition(const glm::vec3& newHeadPosition);
  38. void setHeadRotation(const glm::quat& newHeadRotation);
  39. const glm::vec3& position() const;
  40. const glm::quat& rotationQuat() const;
  41. const glm::mat4& viewMatrix() const;
  42. private:
  43. void updateRotationQuat();
  44. void updateViewMatrix();
  45. fp_t speed_;
  46. glm::vec3 position_;
  47. fp_t yaw_;
  48. fp_t pitch_;
  49. fp_t roll_;
  50. glm::vec3 headPosition_;
  51. glm::quat headRotation_;
  52. glm::quat rotationQuat_;
  53. glm::mat4 viewMatrix_;
  54. };
  55. #endif