Placer 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. //osgParticle - Copyright (C) 2002 Marco Jez
  14. #ifndef OSGPARTICLE_PLACER
  15. #define OSGPARTICLE_PLACER 1
  16. #include <osg/CopyOp>
  17. #include <osg/Object>
  18. #include <osg/Vec3>
  19. namespace osgParticle
  20. {
  21. class Particle;
  22. /** An abstract base class for implementing <I>particle placers</I>. A placer is an object which take
  23. a particle as input, and places it somewhere by setting its position vector. Placer objects are
  24. used by the <CODE>ModularEmitter</CODE> class as part of the particle emission process.
  25. */
  26. class Placer: public osg::Object {
  27. public:
  28. inline Placer();
  29. inline Placer(const Placer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
  30. virtual const char* libraryName() const { return "osgParticle"; }
  31. virtual const char* className() const { return "Placer"; }
  32. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Placer *>(obj) != 0; }
  33. /// Place a particle. Must be implemented in descendant classes.
  34. virtual void place(Particle* P) const = 0;
  35. /// Volume of the placer. Can be implemented in descendant classes.
  36. virtual float volume() const { return 1.0f; }
  37. /// Return the control position of particles that placer will generate. Must be implemented in descendant classes.
  38. virtual osg::Vec3 getControlPosition() const = 0;
  39. protected:
  40. ~Placer() {}
  41. Placer& operator=(const Placer& ) { return *this; }
  42. };
  43. // INLINE FUNCTIONS
  44. inline Placer::Placer()
  45. : osg::Object()
  46. {
  47. }
  48. inline Placer::Placer(const Placer& copy, const osg::CopyOp& copyop)
  49. : osg::Object(copy, copyop)
  50. {
  51. }
  52. }
  53. #endif