QGearsRSDFile.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 <OgreResource.h>
  17. #include <OgreMaterial.h>
  18. #include "common/TypeDefine.h"
  19. namespace QGears{
  20. /**
  21. * Handles RDS files.
  22. *
  23. * RSD files are product of the original PlayStation Psy-Q 3D development
  24. * libraries. They are often exported by 3D modelers when converting from
  25. * an LWO or DXF file to something more understandable by the PSX. They are
  26. * in ascii, making it easy to edit by hand. When a 3D editor does an
  27. * export, four text files are actually created, .rsd, .ply, .mat, and
  28. * .grp. These can then be "compiled" into a binary .rsd file for the PSX.
  29. * In the PC version of Final Fantasy 7, the text .rsd files are used while
  30. * the other files were "compiled" into Polygon(.p) format.
  31. */
  32. class RSDFile : public Ogre::Resource{
  33. public:
  34. /**
  35. * Constructor.
  36. *
  37. * @param creator[in] Pointer to the ResourceManager that is
  38. * creating this resource.
  39. * @param name[in] The unique name of the resource.
  40. * @param handle[in] @todo Understand and document.
  41. * @param group[in] The name of the resource group to which this
  42. * resource belong.
  43. * @param is_manual[in] True if the resource is manually loaded,
  44. * false otherwise.
  45. * @param loader[in] Pointer to a ManualResourceLoader
  46. * implementation which will be called when the Resource wishes to
  47. * load (should be supplied if is_manual is set to true). It can be
  48. * null, but the Resource will never be able to reload if anything
  49. * ever causes it to unload. Therefore provision of a proper
  50. * ManualResourceLoader instance is strongly recommended.
  51. */
  52. RSDFile(
  53. Ogre::ResourceManager* creator, const String &name,
  54. Ogre::ResourceHandle handle, const String& group,
  55. bool is_manual = false,
  56. Ogre::ManualResourceLoader* loader = nullptr
  57. );
  58. /**
  59. * Destructor.
  60. */
  61. virtual ~RSDFile();
  62. /**
  63. * The resource type.
  64. */
  65. static const String RESOURCE_TYPE;
  66. typedef std::vector<String> TextureNameList;
  67. typedef std::vector<Ogre::MaterialPtr> MaterialList;
  68. /**
  69. * Sets the name of the polygon.
  70. *
  71. * @param polygon_name[in] The name for the polygon.
  72. */
  73. virtual void SetPolygonName(const String &polygon_name);
  74. /**
  75. * Sets the material type.
  76. *
  77. * @param material_name[in] The material name.
  78. */
  79. virtual void SetMaterialName(const String &material_name);
  80. /**
  81. * Sets the group name.
  82. *
  83. * @param group_name[in] The name for the group.
  84. */
  85. virtual void SetGroupName(const String &group_name);
  86. /**
  87. * Retrieves the polygon name.
  88. *
  89. * @return The polygon name.
  90. */
  91. virtual const String& GetPolygonName() const;
  92. /**
  93. * Retrieves the material name.
  94. *
  95. * @return The matyerial name.
  96. */
  97. virtual const String& GetMaterialName() const;
  98. /**
  99. * Retrieves the group name.
  100. *
  101. * @return The group name.
  102. */
  103. virtual const String& GetGroupName() const;
  104. /**
  105. * Counts the texture names.
  106. *
  107. * @return The number of texture names.
  108. */
  109. virtual size_t GetTextureNameCount() const;
  110. /**
  111. * Retrieves the list of texture names.
  112. *
  113. * @return The list of texture names.
  114. */
  115. virtual TextureNameList& GetTextureNames();
  116. /**
  117. * Retrieves the material base.
  118. *
  119. * @return The material base name.
  120. */
  121. virtual String GetMaterialBaseName() const;
  122. protected:
  123. /**
  124. * Loads the file.
  125. */
  126. virtual void loadImpl() override;
  127. /**
  128. * Unloads the file.
  129. */
  130. virtual void unloadImpl() override;
  131. /**
  132. * Calculates the size of the palette.
  133. *
  134. * @return The size of the palette.
  135. * @todo Units?
  136. */
  137. virtual size_t calculateSize() const;
  138. /**
  139. * Adds a texture.
  140. *
  141. * @param pass[in|out] Render pas options.
  142. * @param index[in] Index of the texture to add
  143. */
  144. virtual void AddTexture(Ogre::Pass *pass, const size_t index) const;
  145. private:
  146. /**
  147. * The polygon names.
  148. */
  149. String polygon_name_;
  150. /**
  151. * The material type.
  152. */
  153. String material_name_;
  154. /**
  155. * The group name.
  156. */
  157. String group_name_;
  158. /**
  159. * The texture name.
  160. */
  161. TextureNameList texture_names_;
  162. /**
  163. * The lsit of materials
  164. */
  165. MaterialList materials_;
  166. };
  167. typedef Ogre::SharedPtr<RSDFile> RSDFilePtr;
  168. }