PointPlacer 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_POINT_PLACER
  15. #define OSGPARTICLE_POINT_PLACER 1
  16. #include <osgParticle/CenteredPlacer>
  17. #include <osgParticle/Particle>
  18. #include <osg/CopyOp>
  19. #include <osg/Object>
  20. namespace osgParticle
  21. {
  22. /** A point-shaped particle placer.
  23. This placer class uses the center point defined in its base class <CODE>CenteredPlacer</CODE>
  24. to place there all incoming particles.
  25. */
  26. class PointPlacer: public CenteredPlacer {
  27. public:
  28. inline PointPlacer();
  29. inline PointPlacer(const PointPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
  30. META_Object(osgParticle, PointPlacer);
  31. /** Place a particle.
  32. This method is called automatically by <CODE>ModularEmitter</CODE> and should not be called
  33. manually.
  34. */
  35. inline void place(Particle* P) const;
  36. /// return the control position
  37. inline osg::Vec3 getControlPosition() const;
  38. protected:
  39. virtual ~PointPlacer() {}
  40. PointPlacer& operator=(const PointPlacer&) { return *this; }
  41. };
  42. // INLINE FUNCTIONS
  43. inline PointPlacer::PointPlacer()
  44. : CenteredPlacer()
  45. {
  46. }
  47. inline PointPlacer::PointPlacer(const PointPlacer& copy, const osg::CopyOp& copyop)
  48. : CenteredPlacer(copy, copyop)
  49. {
  50. }
  51. inline void PointPlacer::place(Particle* P) const
  52. {
  53. P->setPosition(getCenter());
  54. }
  55. inline osg::Vec3 PointPlacer::getControlPosition() const
  56. {
  57. return getCenter();
  58. }
  59. }
  60. #endif