GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/gepetto/viewer/OSGManipulator/keyboard-manipulator.h Lines: 0 2 0.0 %
Date: 2020-05-14 11:23:33 Branches: 0 12 0.0 %

Line Branch Exec Source
1
#ifndef GEPETTO_VIEWER_FPSMANIPULATOR_H
2
#define GEPETTO_VIEWER_FPSMANIPULATOR_H
3
//
4
//  KeyboardManipulator
5
//  gepetto-viewer
6
//
7
//  Alternative CameraManipulator for OSG, use keyboard and mouse
8
//  KeyBinding are inspired by the classic system in games
9
//
10
//  Created by Pierre Fernbach in january 2016
11
//
12
13
14
#include <osgGA/FirstPersonManipulator>
15
#include <osgViewer/Viewer>
16
#include <osg/Camera>
17
#include <osgViewer/GraphicsWindow>
18
#include <X11/Xlib.h>
19
20
21
22
23
namespace osgGA {
24
25
  const double startSpeed_ = 2.;
26
  /** FirstPersonManipulator is base class for camera control based on position
27
      and orientation of camera, like walk, drive, and flight manipulators. */
28
  class OSGGA_EXPORT KeyboardManipulator : public FirstPersonManipulator
29
  {
30
          typedef FirstPersonManipulator inherited;
31
32
  public:
33
    KeyboardManipulator( int flags = DEFAULT_SETTINGS );
34
    KeyboardManipulator( const KeyboardManipulator& fpm, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
35
    /// Constructor with reference to the graphic window, needed for hidding mouse cursor
36
    KeyboardManipulator(osgViewer::GraphicsWindow* window, int flags = DEFAULT_SETTINGS );
37
38
    META_Object( osgGA, KeyboardManipulator );
39
40
  protected :
41
42
    virtual bool handleKeyDown( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
43
    virtual bool handleKeyUp( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
44
    virtual bool handleFrame( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
45
    virtual bool handleMousePush( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
46
    virtual bool handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
47
  //  virtual bool handleMouseWheel( const GUIEventAdapter& ea, GUIActionAdapter& us );
48
    virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
49
50
    virtual void rotateRoll( const double roll/*,const osg::Vec3d& localUp */);
51
    virtual void getUsage(osg::ApplicationUsage &usage) const;
52
    bool initKeyboard();
53
  private :
54
55
    double speed_;
56
    double speedX_;
57
    double speedY_;
58
    double speedZ_;
59
    double speedRoll_;
60
  /*  double zNear_;
61
    double zFar_;
62
    double fovy_;
63
    double ratio_;*/
64
    osg::Quat rotateRoll_;
65
   // osg::Quat rotatePitch_;
66
   // osg::Quat rotateYaw_;
67
    osg::Vec3d localUp_;
68
    int keyLayout_;
69
70
   //osg::Camera* camera_;
71
    osgViewer::GraphicsWindow* gWindow_;
72
   // Display *display_;
73
    int keycode_;
74
    bool rightClic_;
75
    bool ctrl_;
76
    bool shift_;
77
    bool noRoll_;
78
79
80
  };// end class
81
82
  /*
83
   * zqsd for azerty keyboard, if qwerty keyboard is detected, the keySym will be modified
84
   * */
85
  enum KeyBinding
86
  {
87
    key_forward = GUIEventAdapter::KEY_W, //depend on qwerty / azerty
88
    key_backward = GUIEventAdapter::KEY_S,
89
    key_right = GUIEventAdapter::KEY_D,
90
    key_left = GUIEventAdapter::KEY_A,
91
    key_roll_right = GUIEventAdapter::KEY_E,
92
    key_roll_left = GUIEventAdapter::KEY_Q,
93
    key_up = GUIEventAdapter::KEY_Space,
94
    key_down = GUIEventAdapter::KEY_V
95
  };
96
97
  enum keyLayout{
98
    LAYOUT_unknown,LAYOUT_azerty,LAYOUT_qwerty
99
  };
100
}//namespace osgGA
101
#endif // FPSMANIPULATOR_H