OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FirstPersonManipulator.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 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  * FirstPersonManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
14  * while some pieces of code were taken from OSG.
15  * Thanks to company Cadwork (www.cadwork.ch) and
16  * Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
17 */
18 
19 #ifndef OSGGA_FIRST_PERSON_MANIPULATOR
20 #define OSGGA_FIRST_PERSON_MANIPULATOR 1
21 
22 #include <osgGA/StandardManipulator>
23 
24 
25 namespace osgGA {
26 
27 
31 {
33 
34  public:
35 
36  FirstPersonManipulator( int flags = DEFAULT_SETTINGS );
38  const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
39 
41 
42  virtual void setByMatrix( const osg::Matrixd& matrix );
43  virtual void setByInverseMatrix( const osg::Matrixd& matrix );
44  virtual osg::Matrixd getMatrix() const;
45  virtual osg::Matrixd getInverseMatrix() const;
46 
47  virtual void setTransformation( const osg::Vec3d& eye, const osg::Quat& rotation );
48  virtual void setTransformation( const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up );
49  virtual void getTransformation( osg::Vec3d& eye, osg::Quat& rotation ) const;
50  virtual void getTransformation( osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up ) const;
51 
52  virtual void setVelocity( const double& velocity );
53  inline double getVelocity() const;
54  virtual void setAcceleration( const double& acceleration, bool relativeToModelSize = false );
55  double getAcceleration( bool *relativeToModelSize = NULL ) const;
56  virtual void setMaxVelocity( const double& maxVelocity, bool relativeToModelSize = false );
57  double getMaxVelocity( bool *relativeToModelSize = NULL ) const;
58 
59  virtual void setWheelMovement( const double& wheelMovement, bool relativeToModelSize = false );
60  double getWheelMovement( bool *relativeToModelSize = NULL ) const;
61 
62  virtual void home( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
63  virtual void home( double );
64 
65  virtual void init( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
66 
67  protected:
68 
69  virtual bool handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
70 
71  virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
72  virtual bool performMouseDeltaMovement( const float dx, const float dy );
73  virtual void applyAnimationStep( const double currentProgress, const double prevProgress );
74  virtual bool startAnimationByMousePointerIntersection( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
75 
76  void moveForward( const double distance );
77  void moveForward( const osg::Quat& rotation, const double distance );
78  void moveRight( const double distance );
79  void moveUp( const double distance );
80 
83  double _velocity;
84 
85  double _acceleration;
87  double _maxVelocity;
91 
92  class FirstPersonAnimationData : public AnimationData {
93  public:
96  void start( const osg::Quat& startRotation, const osg::Quat& targetRotation, const double startTime );
97  };
98  virtual void allocAnimationData() { _animationData = new FirstPersonAnimationData(); }
99 };
100 
101 
102 //
103 // inline methods
104 //
105 
108 
109 
110 }
111 
112 #endif /* OSGGA_FIRST_PERSON_MANIPULATOR */
#define NULL
Definition: Export.h:59
#define OSGGA_EXPORT
Definition: Export.h:40
#define META_Object(library, name)
Definition: Object.h:42
double getVelocity() const
Returns velocity.
Definition: Quat.h:29