DriveManipulator
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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.
*/
#ifndef OSGGA_DRIVEMANIPULATOR
#define OSGGA_DRIVEMANIPULATOR 1
#include <osgGA/CameraManipulator>
#include <osg/Quat>
namespace osgGA{
class OSGGA_EXPORT DriveManipulator : public CameraManipulator
{
public:
DriveManipulator();
virtual const char* className() const { return "Drive"; }
virtual void setByMatrix(const osg::Matrixd& matrix);
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
virtual osg::Matrixd getMatrix() const;
virtual osg::Matrixd getInverseMatrix() const;
virtual void setNode(osg::Node*);
virtual const osg::Node* getNode() const;
virtual osg::Node* getNode();
virtual void computeHomePosition();
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
virtual void getUsage(osg::ApplicationUsage& usage) const;
void setModelScale( double in_ms ) { _modelScale = in_ms; }
double getModelScale() const { return _modelScale; }
void setVelocity( double in_vel ) { _velocity = in_vel; }
double getVelocity() const { return _velocity; }
void setHeight( double in_h ) { _height = in_h; }
double getHeight() const { return _height; }
protected:
virtual ~DriveManipulator();
bool intersect(const osg::Vec3d& start, const osg::Vec3d& end, osg::Vec3d& intersection, osg::Vec3d& normal) const;
void flushMouseEventStack();
void addMouseEvent(const GUIEventAdapter& ea);
void computePosition(const osg::Vec3d& eye,const osg::Vec3d& lv,const osg::Vec3d& up);
bool calcMovement();
// Internal event stack comprising last two mouse events.
osg::ref_ptr<const GUIEventAdapter> _ga_t1;
osg::ref_ptr<const GUIEventAdapter> _ga_t0;
osg::observer_ptr<osg::Node> _node;
double _modelScale;
double _velocity;
double _height;
double _buffer;
enum SpeedControlMode {
USE_MOUSE_Y_FOR_SPEED,
USE_MOUSE_BUTTONS_FOR_SPEED
};
SpeedControlMode _speedMode;
osg::Vec3d _eye;
osg::Quat _rotation;
double _pitch;
double _distance;
bool _pitchUpKeyPressed;
bool _pitchDownKeyPressed;
};
}
#endif
CameraManipulator
Quat
osgGA::CameraManipulator::CameraManipulator
CameraManipulator()
osgGA::DriveManipulator::setNode
virtual void setNode(osg::Node *)
osgGA::DriveManipulator::home
virtual void home(const GUIEventAdapter &ea, GUIActionAdapter &us)
osgGA::DriveManipulator::SpeedControlMode
SpeedControlMode
Definition DriveManipulator:105
osgGA::DriveManipulator::USE_MOUSE_Y_FOR_SPEED
@ USE_MOUSE_Y_FOR_SPEED
Definition DriveManipulator:106
osgGA::DriveManipulator::USE_MOUSE_BUTTONS_FOR_SPEED
@ USE_MOUSE_BUTTONS_FOR_SPEED
Definition DriveManipulator:107
osgGA::DriveManipulator::_pitch
double _pitch
Definition DriveManipulator:114
osgGA::DriveManipulator::_node
osg::observer_ptr< osg::Node > _node
Definition DriveManipulator:98
osgGA::DriveManipulator::flushMouseEventStack
void flushMouseEventStack()
osgGA::DriveManipulator::_speedMode
SpeedControlMode _speedMode
Definition DriveManipulator:110
osgGA::DriveManipulator::setByMatrix
virtual void setByMatrix(const osg::Matrixd &matrix)
osgGA::DriveManipulator::setModelScale
void setModelScale(double in_ms)
Definition DriveManipulator:66
osgGA::DriveManipulator::_pitchUpKeyPressed
bool _pitchUpKeyPressed
Definition DriveManipulator:117
osgGA::DriveManipulator::_eye
osg::Vec3d _eye
Definition DriveManipulator:112
osgGA::DriveManipulator::getVelocity
double getVelocity() const
Definition DriveManipulator:70
osgGA::DriveManipulator::_rotation
osg::Quat _rotation
Definition DriveManipulator:113
osgGA::DriveManipulator::computeHomePosition
virtual void computeHomePosition()
osgGA::DriveManipulator::_buffer
double _buffer
Definition DriveManipulator:103
osgGA::DriveManipulator::getModelScale
double getModelScale() const
Definition DriveManipulator:67
osgGA::DriveManipulator::_velocity
double _velocity
Definition DriveManipulator:101
osgGA::DriveManipulator::getNode
virtual osg::Node * getNode()
osgGA::DriveManipulator::getUsage
virtual void getUsage(osg::ApplicationUsage &usage) const
osgGA::DriveManipulator::~DriveManipulator
virtual ~DriveManipulator()
osgGA::DriveManipulator::computePosition
void computePosition(const osg::Vec3d &eye, const osg::Vec3d &lv, const osg::Vec3d &up)
osgGA::DriveManipulator::addMouseEvent
void addMouseEvent(const GUIEventAdapter &ea)
osgGA::DriveManipulator::setHeight
void setHeight(double in_h)
Definition DriveManipulator:72
osgGA::DriveManipulator::calcMovement
bool calcMovement()
osgGA::DriveManipulator::className
virtual const char * className() const
Definition DriveManipulator:35
osgGA::DriveManipulator::_distance
double _distance
Definition DriveManipulator:115
osgGA::DriveManipulator::_height
double _height
Definition DriveManipulator:102
osgGA::DriveManipulator::getHeight
double getHeight() const
Definition DriveManipulator:73
osgGA::DriveManipulator::setByInverseMatrix
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
Definition DriveManipulator:41
osgGA::DriveManipulator::intersect
bool intersect(const osg::Vec3d &start, const osg::Vec3d &end, osg::Vec3d &intersection, osg::Vec3d &normal) const
osgGA::DriveManipulator::getMatrix
virtual osg::Matrixd getMatrix() const
osgGA::DriveManipulator::_modelScale
double _modelScale
Definition DriveManipulator:100
osgGA::DriveManipulator::_pitchDownKeyPressed
bool _pitchDownKeyPressed
Definition DriveManipulator:118
osgGA::DriveManipulator::setVelocity
void setVelocity(double in_vel)
Definition DriveManipulator:69
osgGA::DriveManipulator::init
virtual void init(const GUIEventAdapter &ea, GUIActionAdapter &us)
osgGA::DriveManipulator::getNode
virtual const osg::Node * getNode() const
osgGA::DriveManipulator::_ga_t1
osg::ref_ptr< const GUIEventAdapter > _ga_t1
Definition DriveManipulator:95
osgGA::DriveManipulator::_ga_t0
osg::ref_ptr< const GUIEventAdapter > _ga_t0
Definition DriveManipulator:96
osgGA::DriveManipulator::handle
virtual bool handle(const GUIEventAdapter &ea, GUIActionAdapter &us)
osgGA::DriveManipulator::DriveManipulator
DriveManipulator()
osgGA::DriveManipulator::getInverseMatrix
virtual osg::Matrixd getInverseMatrix() const
osgGA::GUIActionAdapter
Definition GUIActionAdapter:62
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osg::ApplicationUsage
Definition ApplicationUsage:26
osg::Matrixd
Definition Matrixd:27
osg::Matrixd::inverse
static Matrixd inverse(const Matrixd &matrix)
Definition Matrixd:536
osg::Node
Definition Node:72
osg::Quat
Definition Quat:30
osg::Vec3d
Definition Vec3d:30
osg::observer_ptr
Definition observer_ptr:39
osg::ref_ptr
Definition ref_ptr:32
osgGA
Definition Callback:21
OSGGA_EXPORT
#define OSGGA_EXPORT
Definition osgGA/Export:40