ParticleSystemManager.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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[in] name 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[in] template_name 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. * Creates a new technique.
  55. *
  56. * @return The new technique.
  57. */
  58. ParticleTechnique* CreateTechnique();
  59. /**
  60. * Duplicates a technique.
  61. *
  62. * @param[in] technique Technique to duplicate.
  63. * @return The new, duplicated technique.
  64. */
  65. ParticleTechnique* CloneTechnique(ParticleTechnique* technique);
  66. /**
  67. * Destroys a technique.
  68. *
  69. * @param[out] technique Technique to destroy.
  70. */
  71. void DestroyTechnique(ParticleTechnique* technique);
  72. /**
  73. * Creates a new particle emitter.
  74. *
  75. * @param[in] emitter_type Type for the emitter.
  76. */
  77. ParticleEmitter* CreateEmitter(const Ogre::String& emitter_type);
  78. /**
  79. * Duplicates a particle emitter.
  80. *
  81. * @param[in] emitter Emitter to duplicate.
  82. * @return The new, duplicated emitter.
  83. */
  84. ParticleEmitter* CloneEmitter(ParticleEmitter* emitter);
  85. /**
  86. * Destroys a particle emitter.
  87. *
  88. * @param[out] emitter Emitter to destroy.
  89. */
  90. void DestroyEmitter(ParticleEmitter* emitter);
  91. /**
  92. * Creates a new particle renderer.
  93. *
  94. * @param[in] renderer_type Type for the renderer.
  95. * @return The newly created renderer.
  96. */
  97. ParticleRenderer* CreateRenderer(const Ogre::String& renderer_type);
  98. /**
  99. * Duplicates a renderer.
  100. *
  101. * @param[in] renderer renderer to duplicate.
  102. * @return The new, duplicated renderer.
  103. */
  104. ParticleRenderer* CloneRenderer(ParticleRenderer* renderer);
  105. /**
  106. * Destroys a renderer.
  107. *
  108. * @param[out] renderer The renderer to destroy.
  109. */
  110. void DestroyRenderer(ParticleRenderer* renderer);
  111. private:
  112. /**
  113. * Adds a new {@see ParticleEmitterFactory} to the manager.
  114. *
  115. * @param[in] factory The factory to add to the manager.
  116. */
  117. void AddEmitterFactory(ParticleEmitterFactory* factory);
  118. /**
  119. * Adds a new {@see ParticleRendererFactory} to the manager.
  120. *
  121. * @param[in] factory The factory to add to the manager.
  122. */
  123. void AddRendererFactory(ParticleRendererFactory* factory);
  124. private:
  125. /**
  126. * The particle system factory.
  127. */
  128. ParticleSystemFactory* particle_system_factory_;
  129. /**
  130. * The translator manager.
  131. */
  132. ParticleSystemTranslatorManager* translator_manager_;
  133. typedef std::map<Ogre::String, ParticleSystem*>
  134. ParticleSystemTemplateMap;
  135. /**
  136. * The particle system template map.
  137. */
  138. ParticleSystemTemplateMap particle_system_templates_;
  139. typedef std::map<Ogre::String, ParticleEmitterFactory*>
  140. EmitterFactoryMap;
  141. /**
  142. * List of particle emitter factories.
  143. */
  144. EmitterFactoryMap emitter_factories_;
  145. typedef std::map<Ogre::String, ParticleRendererFactory*>
  146. RendererFactoryMap;
  147. /**
  148. * List of renderer factories.
  149. */
  150. RendererFactoryMap renderer_factories_;
  151. };