ParticleTechnique.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 "ParticleEmitter.h"
  17. #include "ParticleRenderer.h"
  18. #include "ParticlePool.h"
  19. #include "ParticlePoolMap.h"
  20. class ParticleSystem;
  21. /**
  22. * A particle technique.
  23. */
  24. class ParticleTechnique{
  25. public:
  26. /**
  27. * Constructor.
  28. */
  29. ParticleTechnique();
  30. /**
  31. * Destructor.
  32. */
  33. virtual ~ParticleTechnique();
  34. /**
  35. * Copy the technique attributes to another technique.
  36. */
  37. void CopyAttributesTo(ParticleTechnique* technique);
  38. /**
  39. * Sets the parent system for the technique.
  40. *
  41. * @param
  42. */
  43. void SetParentSystem(ParticleSystem* parent_system){
  44. parent_system_ = parent_system;
  45. };
  46. /**
  47. * Retrieves the parent system.
  48. *
  49. * @return The parent system.
  50. */
  51. ParticleSystem* GetParentSystem() const {return parent_system_;};
  52. /**
  53. * Adds the technique to the scene render queue.
  54. *
  55. * @param queue[in|out] The queue to update.
  56. */
  57. void UpdateRenderQueue(Ogre::RenderQueue* queue);
  58. /**
  59. * Initializes the tehnique.
  60. */
  61. void Initialize();
  62. /**
  63. * Updates the technique.
  64. *
  65. * Updates the technique status based on the elapsed time.
  66. *
  67. * @param time_elapsed[in] The elapsed time.
  68. */
  69. void Update(Ogre::Real time_elapsed);
  70. /**
  71. * Creates a renderer.
  72. *
  73. * The renderer gets assigned to the technique.
  74. *
  75. * @param renderer_type[in] The type for the renderer.
  76. * @return The newly created renderer.
  77. */
  78. ParticleRenderer* CreateRenderer(const Ogre::String& renderer_type);
  79. /**
  80. * Sets the renderer for the technique.
  81. *
  82. * @paramater renderer[in] Renderer for the technique.
  83. */
  84. void SetRenderer(ParticleRenderer* renderer);
  85. /**
  86. * Destroys the technique renderer.
  87. */
  88. void DestroyRenderer();
  89. /**
  90. * Creates a particle emitter for the technique.
  91. *
  92. * The emitter gets added to the technique.
  93. *
  94. * @param emitter_type[in] The type for the emitter.
  95. * @return The newly created emitter.
  96. */
  97. ParticleEmitter* CreateEmitter(const Ogre::String& emitter_type);
  98. /**
  99. * Adds a particle emitter to the technique
  100. *
  101. * @param emitter[in] The emitter to add to the technique.
  102. */
  103. void AddEmitter(ParticleEmitter* emitter);
  104. /**
  105. * Destroys all the technique's emitters.
  106. */
  107. void DestroyAllEmitters();
  108. /**
  109. * Counts the number of emitters assigned to the techniques.
  110. *
  111. * @return The number of emitters assigned to the techniques.
  112. */
  113. int GetNumEmittableEmitters() const;
  114. /**
  115. * Marks all emitters as emittables.
  116. */
  117. void EmissionChange();
  118. /**
  119. * Retrieves the visual particles quota
  120. *
  121. * @return The visual particles quota
  122. * @todo What is the quta for? How is it set?
  123. */
  124. int GetVisualParticlesQuota() const {return visual_particle_quota_;};
  125. /**
  126. * Initializes the particles of an emitter for emission.
  127. *
  128. * @param eitter[in] The emited to mark.
  129. * @param requested[in] The number of particles to emit.
  130. * @param time_elapsed[in] Unused.
  131. * @todo Understand and document properly.
  132. */
  133. void ExecuteEmitParticles(
  134. ParticleEmitter* emitter, int requested, Ogre::Real time_elapsed
  135. );
  136. /**
  137. * Locks all particles and removes all their additional data.
  138. */
  139. void ResetVisualParticles();
  140. private:
  141. /**
  142. * The parent particle system.
  143. */
  144. ParticleSystem* parent_system_;
  145. /**
  146. * The technique renderer.
  147. */
  148. ParticleRenderer* renderer_;
  149. /**
  150. * The visual particle quota.
  151. */
  152. int visual_particle_quota_;
  153. /**
  154. * Indicates if the visual particle quota has been increased.
  155. */
  156. bool visual_particle_pool_increased_;
  157. /**
  158. * The visual particle pool.
  159. */
  160. ParticlePool<VisualParticle> visual_particles_pool_;
  161. /**
  162. * List of visual particles.
  163. */
  164. std::vector<VisualParticle*> visual_particles_;
  165. /**
  166. * The particle emitter quota.
  167. */
  168. int emitted_emitter_quota_;
  169. /**
  170. * Indicates if the particle emitte quota has been increased.
  171. */
  172. bool particle_emitter_pool_increased_;
  173. /**
  174. * Particle emitter pool.
  175. */
  176. ParticlePoolMap<ParticleEmitter> particle_emitter_pool_;
  177. /**
  178. * List of particle emitters.
  179. */
  180. std::vector<ParticleEmitter*> emitters_;
  181. };