openscenegraph
FlightManipulator
Go to the documentation of this file.
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_FLIGHT_MANIPULATOR
15#define OSGGA_FLIGHT_MANIPULATOR 1
16
17#include <osgGA/FirstPersonManipulator>
18
19
20namespace osgGA {
21
22
23/** FlightManipulator is a CameraManipulator which provides flight simulator-like
24 * updating of the camera position & orientation. By default, the left mouse
25 * button accelerates, the right mouse button decelerates, and the middle mouse
26 * button (or left and right simultaneously) stops dead.
27 */
28class OSGGA_EXPORT FlightManipulator : public FirstPersonManipulator
29{
30 typedef FirstPersonManipulator inherited;
31
32 public:
33
34 enum YawControlMode
35 {
36 YAW_AUTOMATICALLY_WHEN_BANKED,
37 NO_AUTOMATIC_YAW
38 };
39
40 FlightManipulator( int flags = UPDATE_MODEL_SIZE | COMPUTE_HOME_USING_BBOX );
41 FlightManipulator( const FlightManipulator& fpm,
42 const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
43
44 META_Object( osgGA, FlightManipulator );
45
46 virtual void setYawControlMode( YawControlMode ycm );
47 inline YawControlMode getYawControlMode() const;
48
49 virtual void home( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
50 virtual void init( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
51 virtual void getUsage( osg::ApplicationUsage& usage ) const;
52
53 protected:
54
55 virtual bool handleFrame( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
56 virtual bool handleMouseMove( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
57 virtual bool handleMouseDrag( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
58 virtual bool handleMousePush( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
59 virtual bool handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
60 virtual bool handleKeyDown( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
61 virtual bool flightHandleEvent( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
62
63 virtual bool performMovement();
64 virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
65 virtual bool performMovementMiddleMouseButton( const double eventTimeDelta, const double dx, const double dy );
66 virtual bool performMovementRightMouseButton( const double eventTimeDelta, const double dx, const double dy );
67
68 YawControlMode _yawMode;
69
70};
71
72
73//
74// inline methods
75//
76
77/// Returns the Yaw control for the flight model.
78inline FlightManipulator::YawControlMode FlightManipulator::getYawControlMode() const { return _yawMode; }
79
80
81}
82
83#endif /* OSGGA_FLIGHT_MANIPULATOR */