RotateSphereDragger 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. //osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
  14. #ifndef OSGMANIPULATOR_ROTATESPHEREDRAGGER
  15. #define OSGMANIPULATOR_ROTATESPHEREDRAGGER 1
  16. #include <osgManipulator/Dragger>
  17. #include <osgManipulator/Projector>
  18. namespace osgManipulator {
  19. /**
  20. * Dragger for performing 3D rotation on a sphere.
  21. */
  22. class OSGMANIPULATOR_EXPORT RotateSphereDragger : public Dragger
  23. {
  24. public:
  25. RotateSphereDragger();
  26. META_OSGMANIPULATOR_Object(osgManipulator,RotateSphereDragger)
  27. /**
  28. * Handle pick events on dragger and generate TranslateInLine commands.
  29. */
  30. virtual bool handle(const PointerInfo&, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
  31. /** Setup default geometry for dragger. */
  32. void setupDefaultGeometry();
  33. /** Set/Get color for dragger. */
  34. inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
  35. inline const osg::Vec4& getColor() const { return _color; }
  36. /**
  37. * Set/Get pick color for dragger. Pick color is color of the dragger
  38. * when picked. It gives a visual feedback to show that the dragger has
  39. * been picked.
  40. */
  41. inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
  42. inline const osg::Vec4& getPickColor() const { return _pickColor; }
  43. protected:
  44. virtual ~RotateSphereDragger();
  45. osg::ref_ptr<SpherePlaneProjector> _projector;
  46. osg::Vec3d _prevWorldProjPt;
  47. bool _prevPtOnSphere;
  48. osg::Matrix _startLocalToWorld, _startWorldToLocal;
  49. osg::Quat _prevRotation;
  50. osg::Vec4 _color;
  51. osg::Vec4 _pickColor;
  52. };
  53. }
  54. #endif