CParticleRingEmitter.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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_RING_EMITTER_H_INCLUDED__
  5. #define __C_PARTICLE_RING_EMITTER_H_INCLUDED__
  6. #include "IParticleRingEmitter.h"
  7. #include "irrArray.h"
  8. namespace irr
  9. {
  10. namespace scene
  11. {
  12. //! A ring emitter
  13. class CParticleRingEmitter : public IParticleRingEmitter
  14. {
  15. public:
  16. //! constructor
  17. CParticleRingEmitter(
  18. const core::vector3df& center, f32 radius, f32 ringThickness,
  19. const core::vector3df& direction = core::vector3df(0.0f,0.03f,0.0f),
  20. u32 minParticlesPerSecond = 20,
  21. u32 maxParticlesPerSecond = 40,
  22. const video::SColor& minStartColor = video::SColor(255,0,0,0),
  23. const video::SColor& maxStartColor = video::SColor(255,255,255,255),
  24. u32 lifeTimeMin=2000,
  25. u32 lifeTimeMax=4000,
  26. s32 maxAngleDegrees=0,
  27. const core::dimension2df& minStartSize = core::dimension2df(5.0f,5.0f),
  28. const core::dimension2df& maxStartSize = core::dimension2df(5.0f,5.0f)
  29. );
  30. //! Prepares an array with new particles to emitt into the system
  31. //! and returns how much new particles there are.
  32. virtual s32 emitt(u32 now, u32 timeSinceLastCall, SParticle*& outArray);
  33. //! Set direction the emitter emits particles
  34. virtual void setDirection( const core::vector3df& newDirection ) { Direction = newDirection; }
  35. //! Set minimum number of particles the emitter emits per second
  36. virtual void setMinParticlesPerSecond( u32 minPPS ) { MinParticlesPerSecond = minPPS; }
  37. //! Set maximum number of particles the emitter emits per second
  38. virtual void setMaxParticlesPerSecond( u32 maxPPS ) { MaxParticlesPerSecond = maxPPS; }
  39. //! Set minimum starting color for particles
  40. virtual void setMinStartColor( const video::SColor& color ) { MinStartColor = color; }
  41. //! Set maximum starting color for particles
  42. virtual void setMaxStartColor( const video::SColor& color ) { MaxStartColor = color; }
  43. //! Set the maximum starting size for particles
  44. virtual void setMaxStartSize( const core::dimension2df& size ) { MaxStartSize = size; }
  45. //! Set the minimum starting size for particles
  46. virtual void setMinStartSize( const core::dimension2df& size ) { MinStartSize = size; }
  47. //! Set the minimum particle life-time in milliseconds
  48. virtual void setMinLifeTime( u32 lifeTimeMin ) { MinLifeTime = lifeTimeMin; }
  49. //! Set the maximum particle life-time in milliseconds
  50. virtual void setMaxLifeTime( u32 lifeTimeMax ) { MaxLifeTime = lifeTimeMax; }
  51. //! Set maximal random derivation from the direction
  52. virtual void setMaxAngleDegrees( s32 maxAngleDegrees ) { MaxAngleDegrees = maxAngleDegrees; }
  53. //! Set the center of the ring
  54. virtual void setCenter( const core::vector3df& center ) { Center = center; }
  55. //! Set the radius of the ring
  56. virtual void setRadius( f32 radius ) { Radius = radius; }
  57. //! Set the thickness of the ring
  58. virtual void setRingThickness( f32 ringThickness ) { RingThickness = ringThickness; }
  59. //! Gets direction the emitter emits particles
  60. virtual const core::vector3df& getDirection() const { return Direction; }
  61. //! Gets the minimum number of particles the emitter emits per second
  62. virtual u32 getMinParticlesPerSecond() const { return MinParticlesPerSecond; }
  63. //! Gets the maximum number of particles the emitter emits per second
  64. virtual u32 getMaxParticlesPerSecond() const { return MaxParticlesPerSecond; }
  65. //! Gets the minimum starting color for particles
  66. virtual const video::SColor& getMinStartColor() const { return MinStartColor; }
  67. //! Gets the maximum starting color for particles
  68. virtual const video::SColor& getMaxStartColor() const { return MaxStartColor; }
  69. //! Gets the maximum starting size for particles
  70. virtual const core::dimension2df& getMaxStartSize() const { return MaxStartSize; }
  71. //! Gets the minimum starting size for particles
  72. virtual const core::dimension2df& getMinStartSize() const { return MinStartSize; }
  73. //! Get the minimum particle life-time in milliseconds
  74. virtual u32 getMinLifeTime() const { return MinLifeTime; }
  75. //! Get the maximum particle life-time in milliseconds
  76. virtual u32 getMaxLifeTime() const { return MaxLifeTime; }
  77. //! Get maximal random derivation from the direction
  78. virtual s32 getMaxAngleDegrees() const { return MaxAngleDegrees; }
  79. //! Get the center of the ring
  80. virtual const core::vector3df& getCenter() const { return Center; }
  81. //! Get the radius of the ring
  82. virtual f32 getRadius() const { return Radius; }
  83. //! Get the thickness of the ring
  84. virtual f32 getRingThickness() const { return RingThickness; }
  85. //! Writes attributes of the object.
  86. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
  87. //! Reads attributes of the object.
  88. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
  89. private:
  90. core::array<SParticle> Particles;
  91. core::vector3df Center;
  92. f32 Radius;
  93. f32 RingThickness;
  94. core::vector3df Direction;
  95. core::dimension2df MaxStartSize, MinStartSize;
  96. u32 MinParticlesPerSecond, MaxParticlesPerSecond;
  97. video::SColor MinStartColor, MaxStartColor;
  98. u32 MinLifeTime, MaxLifeTime;
  99. u32 Time;
  100. s32 MaxAngleDegrees;
  101. };
  102. } // end namespace scene
  103. } // end namespace irr
  104. #endif