[32] | 1 | #pragma once |
---|
| 2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
| 3 | * |
---|
| 4 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
| 5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
| 6 | * (at your option) any later version. The full license is in LICENSE file |
---|
| 7 | * included with this distribution, and on the openscenegraph.org website. |
---|
| 8 | * |
---|
| 9 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
| 10 | * You have to aquire licenses for all used proprietary modules. |
---|
| 11 | * |
---|
| 12 | * This library is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * OpenSceneGraph Public License for more details. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #include <visual_object.h> |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | namespace osgVisual |
---|
| 23 | { |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * \brief This class is a free spacemouse manipulator. It uses the 3DConnexion SpaceNavigator, which interface is implemented in manip_spaceMouse.h |
---|
| 27 | * |
---|
| 28 | * @author Torben Dannhauer |
---|
| 29 | * @date Aug 2009 |
---|
| 30 | */ |
---|
| 31 | class extLinkManipulator : public osgGA::MatrixManipulator |
---|
| 32 | { |
---|
| 33 | public: |
---|
| 34 | /** |
---|
| 35 | * \brief Constructor |
---|
| 36 | * |
---|
| 37 | */ |
---|
| 38 | extLinkManipulator(); |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | * \brief This function returns the classname. |
---|
| 42 | * |
---|
| 43 | * @return Classname of this manipulator. |
---|
| 44 | */ |
---|
| 45 | virtual const char* className() const { return "extLinkManipulator"; } |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * \brief Set the position of the matrix manipulator using a 4x4 Matrix. |
---|
| 49 | * |
---|
| 50 | * @param matrix : Matrix to set. |
---|
| 51 | */ |
---|
| 52 | virtual void setByMatrix(const osg::Matrixd& matrix); |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | * \brief Set the position of the matrix manipulator using a 4x4 Matrix. |
---|
| 56 | * |
---|
| 57 | * @param matrix : Inverse Matrix to set. |
---|
| 58 | */ |
---|
| 59 | virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); } |
---|
| 60 | |
---|
| 61 | /** get the position of the manipulator as 4x4 Matrix.*/ |
---|
| 62 | virtual osg::Matrixd getMatrix() const; |
---|
| 63 | |
---|
| 64 | /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/ |
---|
| 65 | virtual osg::Matrixd getInverseMatrix() const; |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * \brief Start/restart the manipulator. |
---|
| 69 | * |
---|
| 70 | * No further implementation |
---|
| 71 | * |
---|
| 72 | * @param ea : GUI eventadapter to use for initialization. |
---|
| 73 | * @param us : GUI actionadapter to use for initialization. |
---|
| 74 | */ |
---|
| 75 | virtual void init(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us); |
---|
| 76 | |
---|
| 77 | /** handle events, return true if handled, false otherwise.*/ |
---|
| 78 | virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us); |
---|
| 79 | |
---|
| 80 | /** Get the keyboard and mouse usage of this manipulator.*/ |
---|
| 81 | virtual void getUsage(osg::ApplicationUsage& usage) const; |
---|
| 82 | |
---|
| 83 | virtual void setAttachedObject( |
---|
| 84 | visual_object* object_ ) {attachedObject = object_;}; |
---|
| 85 | |
---|
| 86 | virtual osgVisual::visual_object* getAttachedObject() {return attachedObject.get();}; |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | protected: |
---|
| 90 | /** |
---|
| 91 | * \brief Destructor. Because it is protected, no explicit delete myPointer by external caller is possible. |
---|
| 92 | * This forces the class to be used with osg::ref pointers. |
---|
| 93 | */ |
---|
| 94 | virtual ~extLinkManipulator(); |
---|
| 95 | |
---|
| 96 | osg::Matrixd manipMatrix; |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | osg::ref_ptr<osgVisual::visual_object> attachedObject; |
---|
| 100 | }; |
---|
| 101 | |
---|
| 102 | } // END NAMESPACE |
---|
| 103 | |
---|