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