CParticleAttractionAffector.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_ATTRACTION_AFFECTOR_H_INCLUDED__
  5. #define __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__
  6. #include "IParticleAttractionAffector.h"
  7. namespace irr
  8. {
  9. namespace scene
  10. {
  11. //! Particle Affector for attracting particles to a point
  12. class CParticleAttractionAffector : public IParticleAttractionAffector
  13. {
  14. public:
  15. CParticleAttractionAffector(
  16. const core::vector3df& point = core::vector3df(), f32 speed = 1.0f,
  17. bool attract = true, bool affectX = true,
  18. bool affectY = true, bool affectZ = true );
  19. //! Affects a particle.
  20. virtual void affect(u32 now, SParticle* particlearray, u32 count);
  21. //! Set the point that particles will attract to
  22. virtual void setPoint( const core::vector3df& point ) { Point = point; }
  23. //! Set the speed, in game units per second that the particles will attract to
  24. //! the specified point
  25. virtual void setSpeed( f32 speed ) { Speed = speed; }
  26. //! Set whether or not the particles are attracting or detracting
  27. virtual void setAttract( bool attract ) { Attract = attract; }
  28. //! Set whether or not this will affect particles in the X direction
  29. virtual void setAffectX( bool affect ) { AffectX = affect; }
  30. //! Set whether or not this will affect particles in the Y direction
  31. virtual void setAffectY( bool affect ) { AffectY = affect; }
  32. //! Set whether or not this will affect particles in the Z direction
  33. virtual void setAffectZ( bool affect ) { AffectZ = affect; }
  34. //! Get the point that particles are attracted to
  35. virtual const core::vector3df& getPoint() const { return Point; }
  36. //! Get the speed that points attract to the specified point
  37. virtual f32 getSpeed() const { return Speed; }
  38. //! Get whether or not the particles are attracting or detracting
  39. virtual bool getAttract() const { return Attract; }
  40. //! Get whether or not the particles X position are affected
  41. virtual bool getAffectX() const { return AffectX; }
  42. //! Get whether or not the particles Y position are affected
  43. virtual bool getAffectY() const { return AffectY; }
  44. //! Get whether or not the particles Z position are affected
  45. virtual bool getAffectZ() const { return AffectZ; }
  46. //! Writes attributes of the object.
  47. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
  48. //! Reads attributes of the object.
  49. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
  50. private:
  51. core::vector3df Point;
  52. f32 Speed;
  53. bool AffectX;
  54. bool AffectY;
  55. bool AffectZ;
  56. bool Attract;
  57. u32 LastTime;
  58. };
  59. } // end namespace scene
  60. } // end namespace irr
  61. #endif // __C_PARTICLE_ATTRACTION_AFFECTOR_H_INCLUDED__