CameraViewSwitchManipulator 2.7 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 OSGGA_VIEWLISTMANIPULATOR
  14. #define OSGGA_VIEWLISTMANIPULATOR 1
  15. #include <osgGA/CameraManipulator>
  16. #include <osg/Quat>
  17. #include <osg/CameraView>
  18. namespace osgGA{
  19. class OSGGA_EXPORT CameraViewSwitchManipulator : public CameraManipulator
  20. {
  21. public:
  22. CameraViewSwitchManipulator() {}
  23. virtual const char* className() const { return "CameraViewSwitcher"; }
  24. /** set the position of the matrix manipulator using a 4x4 Matrix.*/
  25. virtual void setByMatrix(const osg::Matrixd& /*matrix*/) {}
  26. /** set the position of the matrix manipulator using a 4x4 Matrix.*/
  27. virtual void setByInverseMatrix(const osg::Matrixd& /*matrix*/) {}
  28. /** get the position of the manipulator as 4x4 Matrix.*/
  29. virtual osg::Matrixd getMatrix() const;
  30. /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
  31. virtual osg::Matrixd getInverseMatrix() const;
  32. /** Attach a node to the manipulator.
  33. Automatically detaches previously attached node.
  34. setNode(NULL) detaches previously nodes.
  35. Is ignored by manipulators which do not require a reference model.*/
  36. virtual void setNode(osg::Node*);
  37. /** Return node if attached.*/
  38. virtual const osg::Node* getNode() const { return _node.get();}
  39. /** Return node if attached.*/
  40. virtual osg::Node* getNode() { return _node.get();}
  41. /** Start/restart the manipulator.*/
  42. virtual void init(const GUIEventAdapter& /*ea*/,GUIActionAdapter& /*aa*/) { _currentView = 0; }
  43. /** handle events, return true if handled, false otherwise.*/
  44. virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
  45. /** Get the keyboard and mouse usage of this manipulator.*/
  46. virtual void getUsage(osg::ApplicationUsage& usage) const;
  47. typedef std::vector< osg::ref_ptr<osg::CameraView> > CameraViewList;
  48. protected:
  49. virtual ~CameraViewSwitchManipulator() {}
  50. osg::ref_ptr<osg::Node> _node;
  51. CameraViewList _cameraViews;
  52. unsigned int _currentView;
  53. };
  54. }
  55. #endif