QGearsBackground2DFile.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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 <OgreQuaternion.h>
  17. #include <Ogre.h>
  18. #include "common/QGearsResource.h"
  19. #include "QGearsTile.h"
  20. namespace QGears{
  21. /**
  22. * Handles 2D background files
  23. *
  24. * @todo Whats the difference with QGearsBackgroundFile.h?
  25. */
  26. class Background2DFile : public Resource{
  27. public:
  28. /**
  29. * Constructor.
  30. *
  31. * @param creator[in] Pointer to the ResourceManager that is
  32. * creating this resource.
  33. * @param name[in] The unique name of the resource.
  34. * @param handle[in] @todo Understand and document.
  35. * @param group[in] The name of the resource group to which this
  36. * resource belong.
  37. * @param is_manual[in] True if the resource is manually loaded,
  38. * false otherwise.
  39. * @param loader[in] Pointer to a ManualResourceLoader
  40. * implementation which will be called when the Resource wishes to
  41. * load (should be supplied if is_manual is set to true). It can be
  42. * null, but the Resource will never be able to reload if anything
  43. * ever causes it to unload. Therefore provision of a proper
  44. * ManualResourceLoader instance is strongly recommended.
  45. */
  46. Background2DFile(
  47. Ogre::ResourceManager* creator, const String &name,
  48. Ogre::ResourceHandle handle, const String& group,
  49. bool is_manual = false,
  50. Ogre::ManualResourceLoader* loader = nullptr
  51. );
  52. /**
  53. * Destructor.
  54. */
  55. virtual ~Background2DFile();
  56. /**
  57. * The type of resource.
  58. */
  59. static const String RESOURCE_TYPE;
  60. typedef std::vector<Tile> TileList;
  61. /**
  62. * Sets the texture name.
  63. *
  64. * @param[in] The name of the texture.
  65. */
  66. virtual void SetTextureName(const String &texture_name);
  67. /**
  68. * Retrieves the texture name.
  69. *
  70. * @return The texture name.
  71. */
  72. virtual String GetTextureName() const;
  73. /**
  74. * Sets the background range.
  75. *
  76. * @param[in] Range vector.
  77. * @todo What is this range?
  78. */
  79. virtual void SetRange(const Ogre::Vector4& range);
  80. /**
  81. * Retrieves the background range.
  82. *
  83. * @return 4-dimensional vector with the background range.
  84. * @todo What is this range?
  85. */
  86. virtual Ogre::Vector4 GetRange() const;
  87. /**
  88. * Sets the background clip.
  89. *
  90. * @param[in] Clip vector.
  91. * @todo What is this clip?
  92. */
  93. virtual void SetClip(const Ogre::Vector2& clip);
  94. /**
  95. * Retrieves the background clip.
  96. *
  97. * @return 4-dimensional vector with the background clip.
  98. * @todo What is this clip?
  99. */
  100. virtual Ogre::Vector2 GetClip() const;
  101. /**
  102. * Sets the background position.
  103. *
  104. * @param[in] Position vector.
  105. */
  106. virtual void SetPosition(const Ogre::Vector3 &position);
  107. /**
  108. * Retrieves the background clip.
  109. *
  110. * @return 4-dimensional vector with the background clip.
  111. * @todo What is this clip?
  112. */
  113. virtual Ogre::Vector3 GetPosition() const;
  114. /**
  115. * Sets the background orientation.
  116. *
  117. * @param orientation[in] The new orientation.
  118. */
  119. virtual void SetOrientation(const Ogre::Quaternion &orientation);
  120. /**
  121. * Retrieves the background orientation.
  122. *
  123. * @return The background orientation quaternion.
  124. */
  125. virtual Ogre::Quaternion GetOrientation() const;
  126. /**
  127. * Sets the background field of view.
  128. *
  129. * @param fow[in] Field of view angle.
  130. */
  131. virtual void SetFov(const Ogre::Radian &fov);
  132. /**
  133. * Retrieves the background field of view.
  134. *
  135. * @return The field of view angle.
  136. */
  137. virtual Ogre::Radian GetFov() const;
  138. /**
  139. * Retrieves the list of tiles.
  140. */
  141. virtual TileList& GetTiles();
  142. protected:
  143. /**
  144. * Loads the file.
  145. */
  146. virtual void loadImpl() override;
  147. /**
  148. * Unloads the file.
  149. */
  150. virtual void unloadImpl() override;
  151. /**
  152. * Calculates the size of the background.
  153. *
  154. * @return The size of the background.
  155. * @todo Units?
  156. */
  157. virtual size_t calculateSize() const override;
  158. private:
  159. /**
  160. * The texture name.
  161. */
  162. String texture_name_;
  163. /**
  164. * The background clip.
  165. */
  166. Ogre::Vector2 clip_;
  167. /**
  168. * The background range.
  169. */
  170. Ogre::Vector4 range_;
  171. /**
  172. * The background position.
  173. */
  174. Ogre::Vector3 position_;
  175. /**
  176. * The background orientation.
  177. */
  178. Ogre::Quaternion orientation_;
  179. /**
  180. * The background field of view.
  181. */
  182. Ogre::Radian fov_;
  183. /**
  184. * The list of tiles.
  185. */
  186. TileList tiles_;
  187. };
  188. typedef Ogre::SharedPtr<Background2DFile> Background2DFilePtr;
  189. }