FirstPersonManipulator
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* FirstPersonManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
* while some pieces of code were taken from OSG.
* Thanks to company Cadwork (www.cadwork.ch) and
* Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
*/
#ifndef OSGGA_FIRST_PERSON_MANIPULATOR
#define OSGGA_FIRST_PERSON_MANIPULATOR 1
#include <osgGA/StandardManipulator>
namespace osgGA {
class OSGGA_EXPORT FirstPersonManipulator : public StandardManipulator
{
typedef StandardManipulator inherited;
public:
FirstPersonManipulator( int flags = DEFAULT_SETTINGS );
FirstPersonManipulator( const FirstPersonManipulator& fpm,
const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
META_Object( osgGA, FirstPersonManipulator );
virtual void setByMatrix( const osg::Matrixd& matrix );
virtual void setByInverseMatrix( const osg::Matrixd& matrix );
virtual osg::Matrixd getMatrix() const;
virtual osg::Matrixd getInverseMatrix() const;
virtual void setTransformation( const osg::Vec3d& eye, const osg::Quat& rotation );
virtual void setTransformation( const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up );
virtual void getTransformation( osg::Vec3d& eye, osg::Quat& rotation ) const;
virtual void getTransformation( osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up ) const;
virtual void setVelocity( const double& velocity );
inline double getVelocity() const;
virtual void setAcceleration( const double& acceleration, bool relativeToModelSize = false );
double getAcceleration( bool *relativeToModelSize = NULL ) const;
virtual void setMaxVelocity( const double& maxVelocity, bool relativeToModelSize = false );
double getMaxVelocity( bool *relativeToModelSize = NULL ) const;
virtual void setWheelMovement( const double& wheelMovement, bool relativeToModelSize = false );
double getWheelMovement( bool *relativeToModelSize = NULL ) const;
virtual void home( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
virtual void home( double );
virtual void init( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
protected:
virtual bool handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
virtual bool performMouseDeltaMovement( const float dx, const float dy );
virtual void applyAnimationStep( const double currentProgress, const double prevProgress );
virtual bool startAnimationByMousePointerIntersection( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
void moveForward( const double distance );
void moveForward( const osg::Quat& rotation, const double distance );
void moveRight( const double distance );
void moveUp( const double distance );
osg::Vec3d _eye;
osg::Quat _rotation;
double _velocity;
double _acceleration;
static int _accelerationFlagIndex;
double _maxVelocity;
static int _maxVelocityFlagIndex;
double _wheelMovement;
static int _wheelMovementFlagIndex;
class FirstPersonAnimationData : public AnimationData {
public:
osg::Quat _startRot;
osg::Quat _targetRot;
void start( const osg::Quat& startRotation, const osg::Quat& targetRotation, const double startTime );
};
virtual void allocAnimationData() { _animationData = new FirstPersonAnimationData(); }
};
//
// inline methods
//
double FirstPersonManipulator::getVelocity() const { return _velocity; }
}
#endif /* OSGGA_FIRST_PERSON_MANIPULATOR */
StandardManipulator
osgGA::FirstPersonManipulator::FirstPersonAnimationData
Definition FirstPersonManipulator:92
osgGA::FirstPersonManipulator::FirstPersonAnimationData::start
void start(const osg::Quat &startRotation, const osg::Quat &targetRotation, const double startTime)
osgGA::FirstPersonManipulator::FirstPersonAnimationData::_startRot
osg::Quat _startRot
Definition FirstPersonManipulator:94
osgGA::FirstPersonManipulator::FirstPersonAnimationData::_targetRot
osg::Quat _targetRot
Definition FirstPersonManipulator:95
osgGA::FirstPersonManipulator::allocAnimationData
virtual void allocAnimationData()
Definition FirstPersonManipulator:98
osgGA::FirstPersonManipulator::getAcceleration
double getAcceleration(bool *relativeToModelSize=NULL) const
osgGA::FirstPersonManipulator::init
virtual void init(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::FirstPersonManipulator::moveUp
void moveUp(const double distance)
osgGA::FirstPersonManipulator::getInverseMatrix
virtual osg::Matrixd getInverseMatrix() const
osgGA::FirstPersonManipulator::_wheelMovementFlagIndex
static int _wheelMovementFlagIndex
Definition FirstPersonManipulator:90
osgGA::FirstPersonManipulator::_maxVelocity
double _maxVelocity
Definition FirstPersonManipulator:87
osgGA::FirstPersonManipulator::home
virtual void home(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::FirstPersonManipulator::_maxVelocityFlagIndex
static int _maxVelocityFlagIndex
Definition FirstPersonManipulator:88
osgGA::FirstPersonManipulator::_velocity
double _velocity
Definition FirstPersonManipulator:83
osgGA::FirstPersonManipulator::_eye
osg::Vec3d _eye
Definition FirstPersonManipulator:81
osgGA::FirstPersonManipulator::setTransformation
virtual void setTransformation(const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up)
osgGA::FirstPersonManipulator::setAcceleration
virtual void setAcceleration(const double &acceleration, bool relativeToModelSize=false)
osgGA::FirstPersonManipulator::getTransformation
virtual void getTransformation(osg::Vec3d &eye, osg::Quat &rotation) const
osgGA::FirstPersonManipulator::setWheelMovement
virtual void setWheelMovement(const double &wheelMovement, bool relativeToModelSize=false)
osgGA::FirstPersonManipulator::_rotation
osg::Quat _rotation
Definition FirstPersonManipulator:82
osgGA::FirstPersonManipulator::_accelerationFlagIndex
static int _accelerationFlagIndex
Definition FirstPersonManipulator:86
osgGA::FirstPersonManipulator::moveForward
void moveForward(const osg::Quat &rotation, const double distance)
osgGA::FirstPersonManipulator::getVelocity
double getVelocity() const
Returns velocity.
Definition FirstPersonManipulator:107
osgGA::FirstPersonManipulator::META_Object
META_Object(osgGA, FirstPersonManipulator)
osgGA::FirstPersonManipulator::getMatrix
virtual osg::Matrixd getMatrix() const
osgGA::FirstPersonManipulator::setTransformation
virtual void setTransformation(const osg::Vec3d &eye, const osg::Quat &rotation)
osgGA::FirstPersonManipulator::setByInverseMatrix
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
osgGA::FirstPersonManipulator::moveForward
void moveForward(const double distance)
osgGA::FirstPersonManipulator::getMaxVelocity
double getMaxVelocity(bool *relativeToModelSize=NULL) const
osgGA::FirstPersonManipulator::_acceleration
double _acceleration
Definition FirstPersonManipulator:85
osgGA::FirstPersonManipulator::startAnimationByMousePointerIntersection
virtual bool startAnimationByMousePointerIntersection(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::FirstPersonManipulator::getTransformation
virtual void getTransformation(osg::Vec3d &eye, osg::Vec3d &center, osg::Vec3d &up) const
osgGA::FirstPersonManipulator::home
virtual void home(double)
osgGA::FirstPersonManipulator::performMovementLeftMouseButton
virtual bool performMovementLeftMouseButton(const double eventTimeDelta, const double dx, const double dy)
osgGA::FirstPersonManipulator::setMaxVelocity
virtual void setMaxVelocity(const double &maxVelocity, bool relativeToModelSize=false)
osgGA::FirstPersonManipulator::FirstPersonManipulator
FirstPersonManipulator(int flags=DEFAULT_SETTINGS)
osgGA::FirstPersonManipulator::handleMouseWheel
virtual bool handleMouseWheel(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &us)
osgGA::FirstPersonManipulator::setVelocity
virtual void setVelocity(const double &velocity)
osgGA::FirstPersonManipulator::moveRight
void moveRight(const double distance)
osgGA::FirstPersonManipulator::setByMatrix
virtual void setByMatrix(const osg::Matrixd &matrix)
osgGA::FirstPersonManipulator::performMouseDeltaMovement
virtual bool performMouseDeltaMovement(const float dx, const float dy)
osgGA::FirstPersonManipulator::applyAnimationStep
virtual void applyAnimationStep(const double currentProgress, const double prevProgress)
osgGA::FirstPersonManipulator::_wheelMovement
double _wheelMovement
Definition FirstPersonManipulator:89
osgGA::FirstPersonManipulator::FirstPersonManipulator
FirstPersonManipulator(const FirstPersonManipulator &fpm, const osg::CopyOp &copyOp=osg::CopyOp::SHALLOW_COPY)
osgGA::FirstPersonManipulator::getWheelMovement
double getWheelMovement(bool *relativeToModelSize=NULL) const
osgGA::GUIActionAdapter
Definition GUIActionAdapter:62
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osgGA::StandardManipulator::AnimationData::AnimationData
AnimationData()
osgGA::StandardManipulator::StandardManipulator
StandardManipulator(int flags=DEFAULT_SETTINGS)
osgGA::StandardManipulator::DEFAULT_SETTINGS
@ DEFAULT_SETTINGS
Definition StandardManipulator:43
osgGA::StandardManipulator::_animationData
osg::ref_ptr< AnimationData > _animationData
Definition StandardManipulator:159
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Matrixd
Definition Matrixd:27
osg::Quat
Definition Quat:30
osg::Vec3d
Definition Vec3d:30
osgGA
Definition Callback:21
OSGGA_EXPORT
#define OSGGA_EXPORT
Definition osgGA/Export:40
NULL
#define NULL
Definition osg/Export:55