ConnectedParticleSystem 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGPARTICLE_CONNECTEDPARTICLESYSTEM
  14. #define OSGPARTICLE_CONNECTEDPARTICLESYSTEM 1
  15. #include <osgParticle/ParticleSystem>
  16. namespace osgParticle
  17. {
  18. /** ConnectConnectedParticleSystem is a specialise ConnectedParticleSystem for effects
  19. * like missile trails, where the individual particles are rendered as
  20. * single ribbon.
  21. */
  22. class OSGPARTICLE_EXPORT ConnectedParticleSystem: public osgParticle::ParticleSystem
  23. {
  24. public:
  25. ConnectedParticleSystem();
  26. ConnectedParticleSystem(const ConnectedParticleSystem& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
  27. META_Object(osgParticle, ConnectedParticleSystem);
  28. /// Create a new particle from the specified template (or the default one if <CODE>ptemplate</CODE> is null).
  29. virtual Particle* createParticle(const Particle* ptemplate);
  30. /// Reuse the i-th particle.
  31. virtual void reuseParticle(int i);
  32. /// Draw the connected particles as either a line or a quad strip, depending upon viewing distance. .
  33. virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
  34. ///Get the (const) particle from where the line or quadstrip starts to be drawn
  35. const osgParticle::Particle* getStartParticle() const
  36. {
  37. return (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0;
  38. }
  39. ///Get the particle from where the line or quadstrip starts to be drawn
  40. osgParticle::Particle* getStartParticle()
  41. {
  42. return (_startParticle != Particle::INVALID_INDEX) ? &_particles[_startParticle] : 0;
  43. }
  44. ///Set the maximum numbers of particles to be skipped during the predraw filtering
  45. void setMaxNumberOfParticlesToSkip(unsigned int maxNumberofParticlesToSkip){_maxNumberOfParticlesToSkip = maxNumberofParticlesToSkip;}
  46. ///Get the maximum numbers of particles to be skipped during the predraw filtering
  47. unsigned int getMaxNumberOfParticlesToSkip(){ return _maxNumberOfParticlesToSkip;}
  48. protected:
  49. virtual ~ConnectedParticleSystem();
  50. ConnectedParticleSystem& operator=(const ConnectedParticleSystem&) { return *this; }
  51. int _lastParticleCreated;
  52. unsigned int _maxNumberOfParticlesToSkip;
  53. int _startParticle;
  54. };
  55. }
  56. #endif