CenteredPlacer 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_CENTERED_PLACER
  15. #define OSGPARTICLE_CENTERED_PLACER 1
  16. #include <osgParticle/Placer>
  17. #include <osg/CopyOp>
  18. #include <osg/Object>
  19. #include <osg/Vec3>
  20. namespace osgParticle
  21. {
  22. /** An abstract placer base class for placers which need a <I>center point</I>.
  23. */
  24. class CenteredPlacer: public Placer {
  25. public:
  26. inline CenteredPlacer();
  27. inline CenteredPlacer(const CenteredPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
  28. virtual const char* libraryName() const { return "osgParticle"; }
  29. virtual const char* className() const { return "CenteredPlacer"; }
  30. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Placer* >(obj) != 0; }
  31. /// Get the center point.
  32. inline const osg::Vec3& getCenter() const;
  33. /// Set the center point.
  34. inline void setCenter(const osg::Vec3& v);
  35. /// Set the center point.
  36. inline void setCenter(float x, float y, float z);
  37. protected:
  38. virtual ~CenteredPlacer() {}
  39. private:
  40. osg::Vec3 center_;
  41. };
  42. // INLINE FUNCTIONS
  43. inline CenteredPlacer::CenteredPlacer()
  44. : Placer(), center_(0, 0, 0)
  45. {
  46. }
  47. inline CenteredPlacer::CenteredPlacer(const CenteredPlacer& copy, const osg::CopyOp& copyop)
  48. : Placer(copy, copyop), center_(copy.center_)
  49. {
  50. }
  51. inline const osg::Vec3& CenteredPlacer::getCenter() const
  52. {
  53. return center_;
  54. }
  55. inline void CenteredPlacer::setCenter(const osg::Vec3& v)
  56. {
  57. center_ = v;
  58. }
  59. inline void CenteredPlacer::setCenter(float x, float y, float z)
  60. {
  61. center_.set(x, y, z);
  62. }
  63. }
  64. #endif