SmokeParticles.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __SMOKEPARTICLES_H__
  21. #define __SMOKEPARTICLES_H__
  22. /*
  23. ===============================================================================
  24. Smoke systems are for particles that are emitted off of things that are
  25. constantly changing position and orientation, like muzzle smoke coming
  26. from a bone on a weapon, blood spurting from a wound, or particles
  27. trailing from a monster limb.
  28. The smoke particles are always evaluated and rendered each tic, so there
  29. is a performance cost with using them for continuous effects. The general
  30. particle systems are completely parametric, and have no performance
  31. overhead when not in view.
  32. All smoke systems share the same shaderparms, so any coloration must be
  33. done in the particle definition.
  34. Each particle model has its own shaderparms, which can be used by the
  35. particle materials.
  36. ===============================================================================
  37. */
  38. typedef struct singleSmoke_s {
  39. struct singleSmoke_s * next;
  40. int privateStartTime; // start time for this particular particle
  41. int index; // particle index in system, 0 <= index < stage->totalParticles
  42. idRandom random;
  43. idVec3 origin;
  44. idMat3 axis;
  45. int timeGroup;
  46. } singleSmoke_t;
  47. typedef struct {
  48. const idParticleStage * stage;
  49. singleSmoke_t * smokes;
  50. } activeSmokeStage_t;
  51. class idSmokeParticles {
  52. public:
  53. idSmokeParticles();
  54. // creats an entity covering the entire world that will call back each rendering
  55. void Init();
  56. void Shutdown();
  57. // spits out a particle, returning false if the system will not emit any more particles in the future
  58. bool EmitSmoke( const idDeclParticle *smoke, const int startTime, const float diversity,
  59. const idVec3 &origin, const idMat3 &axis, int timeGroup /*_D3XP*/ );
  60. // free old smokes
  61. void FreeSmokes();
  62. private:
  63. bool initialized;
  64. renderEntity_t renderEntity; // used to present a model to the renderer
  65. int renderEntityHandle; // handle to static renderer model
  66. static const int MAX_SMOKE_PARTICLES = 10000;
  67. singleSmoke_t smokes[MAX_SMOKE_PARTICLES];
  68. idList<activeSmokeStage_t, TAG_PARTICLE> activeStages;
  69. singleSmoke_t * freeSmokes;
  70. int numActiveSmokes;
  71. int currentParticleTime; // don't need to recalculate if == view time
  72. bool UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView );
  73. static bool ModelCallback( renderEntity_s *renderEntity, const renderView_t *renderView );
  74. };
  75. #endif /* !__SMOKEPARTICLES_H__ */