1 // Copyright (C) 2009 - 2012 Mathias Froehlich
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #ifndef _HLACameraManipulator_hxx
18 #define _HLACameraManipulator_hxx
20 #include <osgGA/CameraManipulator>
21 #include <simgear/scene/util/OsgMath.hxx>
22 #include "HLAPerspectiveViewer.hxx"
28 class HLACameraManipulator : public osgGA::CameraManipulator {
30 HLACameraManipulator(HLAPerspectiveViewer* perspectiveViewer = 0);
31 HLACameraManipulator(const HLACameraManipulator& cameraManipulator, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY);
32 virtual ~HLACameraManipulator();
34 META_Object(fgviewer, HLACameraManipulator);
36 virtual void setByMatrix(const osg::Matrixd& matrix);
37 virtual void setByInverseMatrix(const osg::Matrixd& matrix);
39 virtual osg::Matrixd getMatrix() const;
40 virtual osg::Matrixd getInverseMatrix() const;
42 /** Handle events, return true if handled, false otherwise. */
43 virtual bool handle(const osgGA::GUIEventAdapter& eventAdapter, osgGA::GUIActionAdapter& actionAdapter);
46 bool _handle(const osgGA::GUIEventAdapter& eventAdapter, Viewer& viewer);
47 void _handleFrameEvent(osgGA::GUIActionAdapter& actionAdapter);
48 bool _handleKeyDownEvent(const osgGA::GUIEventAdapter& eventAdapter, Viewer& viewer);
49 bool _handleKeyUpEvent(const osgGA::GUIEventAdapter& eventAdapter, Viewer& viewer);
50 void _incrementEyePosition(const SGVec3d& offset);
52 void _rotateView(const osg::Vec2& inc);
53 void _rotateSun(const osg::Vec2& inc, Viewer& viewer);
56 osg::Matrixd _viewMatrix;
57 osg::Matrixd _inverseViewMatrix;
58 osg::Vec2 _lastMousePos;
59 SGSharedPtr<HLAPerspectiveViewer> _perspectiveViewer;
62 } // namespace fgviewer