💿🐜 Antkeeper source code https://antkeeper.com
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.

125 lines
2.5 KiB

  1. /*
  2. * Copyright (C) 2020 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_CAMERA_RIG_HPP
  20. #define ANTKEEPER_CAMERA_RIG_HPP
  21. #include <vmq/vmq.hpp>
  22. using namespace vmq::types;
  23. class camera;
  24. /**
  25. * Abstract base class for camera rigs which control the movement of cameras.
  26. */
  27. class camera_rig
  28. {
  29. public:
  30. camera_rig();
  31. /**
  32. * Updates the rig.
  33. *
  34. * @param dt Delta time.
  35. */
  36. virtual void update(float dt) = 0;
  37. /**
  38. * Attaches a camera to the rig.
  39. *
  40. * @param camera Camera to attach.
  41. */
  42. void attach(::camera* camera);
  43. /**
  44. * Detaches a camera from the rig.
  45. */
  46. void detach();
  47. /**
  48. * Sets the translation of the camera rig.
  49. */
  50. void set_translation(const float3& translation);
  51. /**
  52. * Sets the rotation of the camera rig.
  53. */
  54. void set_rotation(const vmq::quaternion<float>& rotation);
  55. /**
  56. * Returns the attached camera.
  57. */
  58. const ::camera* get_camera() const;
  59. /// @copydoc camera_rig::get_camera() const
  60. ::camera* get_camera();
  61. const float3& get_translation() const;
  62. const vmq::quaternion<float>& get_rotation() const;
  63. const float3& get_forward() const;
  64. const float3& get_right() const;
  65. const float3& get_up() const;
  66. private:
  67. camera* camera;
  68. float3 translation;
  69. vmq::quaternion<float> rotation;
  70. float3 forward;
  71. float3 right;
  72. float3 up;
  73. };
  74. inline const camera* camera_rig::get_camera() const
  75. {
  76. return camera;
  77. }
  78. inline camera* camera_rig::get_camera()
  79. {
  80. return camera;
  81. }
  82. inline const float3& camera_rig::get_translation() const
  83. {
  84. return translation;
  85. }
  86. inline const vmq::quaternion<float>& camera_rig::get_rotation() const
  87. {
  88. return rotation;
  89. }
  90. inline const float3& camera_rig::get_forward() const
  91. {
  92. return forward;
  93. }
  94. inline const float3& camera_rig::get_right() const
  95. {
  96. return right;
  97. }
  98. inline const float3& camera_rig::get_up() const
  99. {
  100. return up;
  101. }
  102. #endif // ANTKEEPER_CAMERA_RIG_HPP