QGearsCameraMatrixFile.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreMatrix3.h>
  17. #include "common/QGearsResource.h"
  18. namespace QGears{
  19. /**
  20. * Handles camera matrix files.
  21. */
  22. class CameraMatrixFile : public Resource{
  23. public:
  24. /**
  25. * Constructor.
  26. *
  27. * @param creator[in] Pointer to the ResourceManager that is
  28. * creating this resource.
  29. * @param name[in] The unique name of the resource.
  30. * @param handle[in] @todo Understand and document.
  31. * @param group[in] The name of the resource group to which this
  32. * resource belong.
  33. * @param is_manual[in] True if the resource is manually loaded,
  34. * false otherwise.
  35. * @param loader[in] Pointer to a ManualResourceLoader
  36. * implementation which will be called when the Resource wishes to
  37. * load (should be supplied if is_manual is set to true). It can be
  38. * null, but the Resource will never be able to reload if anything
  39. * ever causes it to unload. Therefore provision of a proper
  40. * ManualResourceLoader instance is strongly recommended.
  41. */
  42. CameraMatrixFile(
  43. Ogre::ResourceManager *creator, const String &name,
  44. Ogre::ResourceHandle handle, const String &group,
  45. bool is_manual = false, Ogre::ManualResourceLoader *loader = NULL
  46. );
  47. /**
  48. * Destructor.
  49. */
  50. virtual ~CameraMatrixFile();
  51. /**
  52. * The type of resource.
  53. */
  54. static const String RESOURCE_TYPE;
  55. /**
  56. * Retrieves the camera matrix in the file.
  57. *
  58. * @return The camera matrix.
  59. */
  60. const Ogre::Matrix3& GetMatrix() const;
  61. /**
  62. * Sets the camera matrix.
  63. *
  64. * @param matrix[in] The camera matrix.
  65. */
  66. void SetMatrix(const Ogre::Matrix3& matrix);
  67. /**
  68. * Retrieves the camera position.
  69. *
  70. * @return The camera position.
  71. */
  72. const Ogre::Vector3& GetPosition() const;
  73. /**
  74. * Sets the camera position.
  75. *
  76. * @param position[in] The camera position.
  77. */
  78. void SetPosition(const Ogre::Vector3& position);
  79. /**
  80. * Retrieves the camera offset.
  81. *
  82. * @return The camera offset, as a {@see Pixel}.
  83. */
  84. const Pixel& GetOffset() const;
  85. /**
  86. * Sets the camera offset.
  87. *
  88. * @param offset[in] The camera offset, as a {@see Pixel}.
  89. */
  90. void SetOffset(const Pixel& offset);
  91. /**
  92. * Counts the ???
  93. *
  94. * @return The number of ???
  95. * @todo What does this count?
  96. */
  97. const size_t& GetCount() const;
  98. /**
  99. * Sets the number of ???
  100. *
  101. * @param count[in] The number of ???
  102. * @todo What is this number?
  103. */
  104. void SetCount(const size_t count);
  105. /**
  106. * Retrieves the focal length.
  107. *
  108. * @return The focal length.
  109. */
  110. const Ogre::Real& GetFocalLength() const;
  111. /**
  112. * Sets the focal length.
  113. *
  114. * @param focal_length[in] The focal length.
  115. */
  116. void SetFocalLength(const Ogre::Real focal_length);
  117. /**
  118. * Retrieves the camera orientation.
  119. *
  120. * @return The camera orientation.
  121. */
  122. Ogre::Quaternion GetOrientation() const;
  123. /**
  124. * Retrieves the camera field of view.
  125. *
  126. * @return The field of view.
  127. */
  128. Ogre::Radian GetFov(Ogre::Real width) const;
  129. protected:
  130. /**
  131. * Loads the file.
  132. */
  133. virtual void loadImpl(void);
  134. /**
  135. * Unloads the file.
  136. */
  137. virtual void unloadImpl(void);
  138. /**
  139. * Calculates the file size
  140. *
  141. * @return Always 0.
  142. */
  143. virtual size_t CalculateSize(void) const;
  144. private:
  145. /**
  146. * The camera matrix.
  147. */
  148. Ogre::Matrix3 matrix_;
  149. /**
  150. * The position of the camera.
  151. */
  152. Ogre::Vector3 position_;
  153. /**
  154. * The camera offset.
  155. */
  156. Pixel offset_;
  157. /**
  158. * The focal length.
  159. */
  160. Ogre::Real focal_length_;
  161. /**
  162. * The number of @todo what?
  163. */
  164. size_t count_;
  165. };
  166. typedef Ogre::SharedPtr<CameraMatrixFile> CameraMatrixFilePtr;
  167. }