Pteros  2.0
Molecular modeling library for human beings!
GliderManipulator.h
1 /* -*-c++-*-
2 *
3 * OpenSceneGraph example, osghangglide.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18 * THE SOFTWARE.
19 */
20 
21 #ifndef OSGGA_GliderMANIPULATOR
22 #define OSGGA_GliderMANIPULATOR 1
23 
24 #include <osgGA/CameraManipulator>
25 #include <osg/Quat>
26 
34 class GliderManipulator : public osgGA::CameraManipulator
35 {
36  public:
37 
39 
40  virtual const char* className() const { return "Glider"; }
41 
43  virtual void setByMatrix(const osg::Matrixd& matrix);
44 
46  virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
47 
49  virtual osg::Matrixd getMatrix() const;
50 
52  virtual osg::Matrixd getInverseMatrix() const;
53 
54 
55  virtual void setNode(osg::Node*);
56 
57  virtual const osg::Node* getNode() const;
58 
59  virtual osg::Node* getNode();
60 
61  virtual void home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
62 
63  virtual void init(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
64 
65  virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
66 
68  virtual void getUsage(osg::ApplicationUsage& usage) const;
69 
70  enum YawControlMode {
71  YAW_AUTOMATICALLY_WHEN_BANKED,
72  NO_AUTOMATIC_YAW
73  };
74 
76  void setYawControlMode(YawControlMode ycm) { _yawMode = ycm; }
77 
78  protected:
79 
80  virtual ~GliderManipulator();
81 
83  void flushMouseEventStack();
85  void addMouseEvent(const osgGA::GUIEventAdapter& ea);
86 
87  void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
88 
91  bool calcMovement();
92 
93 
94  // Internal event stack comprising last three mouse events.
95  osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t1;
96  osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t0;
97 
98  osg::ref_ptr<osg::Node> _node;
99 
100  float _modelScale;
101  float _velocity;
102 
103  YawControlMode _yawMode;
104 
105  osg::Vec3 _eye;
106  osg::Quat _rotation;
107  float _distance;
108 
109 };
110 
111 #endif
112 
void setYawControlMode(YawControlMode ycm)
Configure the Yaw control for the Glider model.
Definition: GliderManipulator.h:76
virtual void getUsage(osg::ApplicationUsage &usage) const
Get the keyboard and mouse usage of this manipulator.
Definition: GliderManipulator.cpp:184
virtual osg::Matrixd getMatrix() const
get the position of the manipulator as 4x4 Matrix.
Definition: GliderManipulator.cpp:212
virtual osg::Matrixd getInverseMatrix() const
get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...
Definition: GliderManipulator.cpp:217
GliderManipulator is a CameraManipulator which provides Glider simulator-like updating of the camera ...
Definition: GliderManipulator.h:34
virtual void setByMatrix(const osg::Matrixd &matrix)
set the position of the matrix manipulator using a 4x4 Matrix.
Definition: GliderManipulator.cpp:205
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
set the position of the matrix manipulator using a 4x4 Matrix.
Definition: GliderManipulator.h:46