ParticleSystemManager.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 <OgreSingleton.h>
  17. #include "ParticleEmitter.h"
  18. #include "ParticleEmitterFactory.h"
  19. #include "ParticleRendererFactory.h"
  20. #include "ParticleSystem.h"
  21. #include "ParticleSystemFactory.h"
  22. #include "ParticleTechnique.h"
  23. #include "ParticleSystemTranslatorManager.h"
  24. /**
  25. * The particle system manager.
  26. */
  27. class ParticleSystemManager: public Ogre::Singleton<ParticleSystemManager>{
  28. public:
  29. /**
  30. * Constructor.
  31. */
  32. ParticleSystemManager();
  33. /**
  34. * Constructor.
  35. */
  36. ~ParticleSystemManager();
  37. /**
  38. * Creates a particle system template.
  39. *
  40. * @param name[in] Name for the template.
  41. * @return A new particle system template.
  42. */
  43. ParticleSystem* CreateParticleSystemTemplate(const Ogre::String& name);
  44. /**
  45. * Retrieves a particle system template.
  46. *
  47. * @param template_name[in] The name of the template to retrieve.
  48. * @return The template. 0 if no template with that name was found.
  49. */
  50. ParticleSystem* GetParticleSystemTemplate(
  51. const Ogre::String& template_name
  52. );
  53. /**
  54. * Gets all template names.
  55. *
  56. * @param v[out] List where the names will be loaded.
  57. */
  58. void ParticleSystemTemplateNames(std::vector<Ogre::String>& v);
  59. /**
  60. * Creates a particle system.
  61. *
  62. * @param name[in] Name for the template system.
  63. * @param template_name[in] Name for the system template.
  64. */
  65. ParticleSystem* CreateParticleSystem(
  66. const Ogre::String& name, const Ogre::String& template_name
  67. );
  68. /**
  69. * Destroys a particle system.
  70. *
  71. * @param particle_system[out] Particle system to destroy.
  72. */
  73. void DestroyParticleSystem(ParticleSystem* particle_system);
  74. /**
  75. * Creates a new technique.
  76. *
  77. * @return The new technique.
  78. */
  79. ParticleTechnique* CreateTechnique();
  80. /**
  81. * Duplicates a technique.
  82. *
  83. * @param technique[in] Technique to duplicate.
  84. * @return The new, duplicated technique.
  85. */
  86. ParticleTechnique* CloneTechnique(ParticleTechnique* technique);
  87. /**
  88. * Destroys a technique.
  89. *
  90. * @param technique[out] Technique to destroy.
  91. */
  92. void DestroyTechnique(ParticleTechnique* technique);
  93. /**
  94. * Creates a new particle emitter.
  95. *
  96. * @param emitter_type[in] Type for the emitter.
  97. */
  98. ParticleEmitter* CreateEmitter(const Ogre::String& emitter_type);
  99. /**
  100. * Duplicates a particle emitter.
  101. *
  102. * @param emitter[in] Emitter to duplicate.
  103. * @return The new, duplicated emitter.
  104. */
  105. ParticleEmitter* CloneEmitter(ParticleEmitter* emitter);
  106. /**
  107. * Destroys a particle emitter.
  108. *
  109. * @param emitter[out] Emitter to destroy.
  110. */
  111. void DestroyEmitter(ParticleEmitter* emitter);
  112. /**
  113. * Creates a new particle renderer.
  114. *
  115. * @param renderer_type[in] Type for the renderer.
  116. * @return The newly created renderer.
  117. */
  118. ParticleRenderer* CreateRenderer(const Ogre::String& renderer_type);
  119. /**
  120. * Duplicates a renderer.
  121. *
  122. * @param renderer[in] renderer to duplicate.
  123. * @return The new, duplicated renderer.
  124. */
  125. ParticleRenderer* CloneRenderer(ParticleRenderer* renderer);
  126. /**
  127. * Destroys a renderer.
  128. *
  129. * @param renderer[out] The renderer to destroy.
  130. */
  131. void DestroyRenderer(ParticleRenderer* renderer);
  132. private:
  133. /**
  134. * Adds a new {@see ParticleEmitterFactory} to the manager.
  135. *
  136. * @param factory[in] The factory to add to the manager.
  137. */
  138. void AddEmitterFactory(ParticleEmitterFactory* factory);
  139. /**
  140. * Adds a new {@see ParticleRendererFactory} to the manager.
  141. *
  142. * @param factory[in] The factory to add to the manager.
  143. */
  144. void AddRendererFactory(ParticleRendererFactory* factory);
  145. private:
  146. /**
  147. * The particle system factory.
  148. */
  149. ParticleSystemFactory* particle_system_factory_;
  150. /**
  151. * The translator manager.
  152. */
  153. ParticleSystemTranslatorManager* translator_manager_;
  154. typedef std::map<Ogre::String, ParticleSystem*>
  155. ParticleSystemTemplateMap;
  156. /**
  157. * The particle system template map.
  158. */
  159. ParticleSystemTemplateMap particle_system_templates_;
  160. typedef std::map<Ogre::String, ParticleEmitterFactory*>
  161. EmitterFactoryMap;
  162. /**
  163. * List of particle emitter factories.
  164. */
  165. EmitterFactoryMap emitter_factories_;
  166. typedef std::map<Ogre::String, ParticleRendererFactory*>
  167. RendererFactoryMap;
  168. /**
  169. * List of renderer factories.
  170. */
  171. RendererFactoryMap renderer_factories_;
  172. };