CParticleBoxEmitter.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __C_PARTICLE_BOX_EMITTER_H_INCLUDED__
  5. #define __C_PARTICLE_BOX_EMITTER_H_INCLUDED__
  6. #include "IParticleBoxEmitter.h"
  7. #include "irrArray.h"
  8. #include "aabbox3d.h"
  9. namespace irr
  10. {
  11. namespace scene
  12. {
  13. //! A default box emitter
  14. class CParticleBoxEmitter : public IParticleBoxEmitter
  15. {
  16. public:
  17. //! constructor
  18. CParticleBoxEmitter(
  19. const core::aabbox3df& box,
  20. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  21. u32 minParticlesPerSecond = 20,
  22. u32 maxParticlesPerSecond = 40,
  23. video::SColor minStartColor = video::SColor(255,0,0,0),
  24. video::SColor maxStartColor = video::SColor(255,255,255,255),
  25. u32 lifeTimeMin=2000,
  26. u32 lifeTimeMax=4000,
  27. s32 maxAngleDegrees=0,
  28. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  29. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f)
  30. );
  31. //! Prepares an array with new particles to emitt into the system
  32. //! and returns how much new particles there are.
  33. virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
  34. //! Set direction the emitter emits particles.
  35. virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
  36. //! Set minimum number of particles emitted per second.
  37. virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
  38. //! Set maximum number of particles emitted per second.
  39. virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
  40. //! Set minimum start color.
  41. virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
  42. //! Set maximum start color.
  43. virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
  44. //! Set the maximum starting size for particles
  45. virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; };
  46. //! Set the minimum starting size for particles
  47. virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; };
  48. //! Set the minimum particle life-time in milliseconds
  49. virtual void setMinLifeTime( u32 lifeTimeMin ) { MinLifeTime = lifeTimeMin; }
  50. //! Set the maximum particle life-time in milliseconds
  51. virtual void setMaxLifeTime( u32 lifeTimeMax ) { MaxLifeTime = lifeTimeMax; }
  52. //! Maximal random derivation from the direction
  53. virtual void setMaxAngleDegrees( s32 maxAngleDegrees ) { MaxAngleDegrees = maxAngleDegrees; }
  54. //! Set box from which the particles are emitted.
  55. virtual void setBox( const core::aabbox3df& box ) { Box = box; }
  56. //! Gets direction the emitter emits particles.
  57. virtual const core::vector3df& getDirection() const { return Direction; }
  58. //! Gets minimum number of particles emitted per second.
  59. virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
  60. //! Gets maximum number of particles emitted per second.
  61. virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
  62. //! Gets minimum start color.
  63. virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
  64. //! Gets maximum start color.
  65. virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
  66. //! Gets the maximum starting size for particles
  67. virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }
  68. //! Gets the minimum starting size for particles
  69. virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }
  70. //! Get the minimum particle life-time in milliseconds
  71. virtual u32 getMinLifeTime() const { return MinLifeTime; }
  72. //! Get the maximum particle life-time in milliseconds
  73. virtual u32 getMaxLifeTime() const { return MaxLifeTime; }
  74. //! Maximal random derivation from the direction
  75. virtual s32 getMaxAngleDegrees() const { return MaxAngleDegrees; }
  76. //! Get box from which the particles are emitted.
  77. virtual const core::aabbox3df& getBox() const { return Box; }
  78. //! Writes attributes of the object.
  79. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
  80. //! Reads attributes of the object.
  81. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
  82. private:
  83. core::array<SParticle> Particles;
  84. core::aabbox3df Box;
  85. core::vector3df Direction;
  86. core::dimension2df MaxStartSize, MinStartSize;
  87. u32 MinParticlesPerSecond, MaxParticlesPerSecond;
  88. video::SColor MinStartColor, MaxStartColor;
  89. u32 MinLifeTime, MaxLifeTime;
  90. u32 Time;
  91. s32 MaxAngleDegrees;
  92. };
  93. } // end namespace scene
  94. } // end namespace irr
  95. #endif