Added UFO manipulator
This commit is contained in:
165
include/osgGA/UFOManipulator
Normal file
165
include/osgGA/UFOManipulator
Normal file
@@ -0,0 +1,165 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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_UFO_MANIPULATOR_DEF
|
||||
#define OSGGA_UFO_MANIPULATOR_DEF 1
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <Producer/Keyboard>
|
||||
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osg/Node>
|
||||
#include <osg/Matrix>
|
||||
|
||||
/**
|
||||
\class UFOManipulator
|
||||
\brief A UFO manipulator driven with keybindings.
|
||||
|
||||
The UFOManipulator is better suited for applications that employ
|
||||
architectural walk-throughs, or situations where the eyepoint motion
|
||||
model must move slowly, deliberately and well controlled.
|
||||
|
||||
The UFO Manipulator allows the following movements with the listed
|
||||
Key combinations:
|
||||
\param UpArrow Acceleration forward.
|
||||
\param DownArrow Acceleration backward (or deceleration forward).
|
||||
\param LeftArrow Rotate view and direction of travel to the left.
|
||||
\param RightArrow Rotate view and direction of travel to the right.
|
||||
\param SpaceBar Brake. Gradually decelerates linear and rotational movement.
|
||||
\param Shift/UpArrow Accelerate up.
|
||||
\param Shift/DownArrow Accelerate down.
|
||||
\param Shift/LeftArrow Accelerate (linearly) left.
|
||||
\param Shift/RightArrow Accelerate (linearly) right.
|
||||
\param Shift/SpaceBar Instant brake. Immediately stop all linear and rotational movement.
|
||||
|
||||
When the Shift key is released, up, down, linear left and/or linear right movement is decelerated.
|
||||
|
||||
\param Ctrl/UpArrow Rotate view (but not direction of travel) up.
|
||||
\param Ctrl/DownArrow Rotate view (but not direction of travel) down.
|
||||
\param Ctrl/LeftArrow Rotate view (but not direction of travel) left.
|
||||
\param Ctrl/RightArrow Rotate view (but not direction of travel) right.
|
||||
\param Ctrl/Return Straightens out the view offset.
|
||||
|
||||
*/
|
||||
|
||||
namespace osgGA {
|
||||
|
||||
class OSGGA_EXPORT UFOManipulator : public osgGA::MatrixManipulator
|
||||
{
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
UFOManipulator();
|
||||
|
||||
/** return className
|
||||
\return returns constant "UFOManipulator"
|
||||
*/
|
||||
virtual const char* className() const;
|
||||
|
||||
/** Set the current position with a matrix
|
||||
\param matrix A viewpoint matrix.
|
||||
*/
|
||||
virtual void setByMatrix( const osg::Matrix &matrix ) ;
|
||||
|
||||
/** Set the current position with the invers matrix
|
||||
\param invmatrix The inverse of a viewpoint matrix
|
||||
*/
|
||||
virtual void setByInverseMatrix( const osg::Matrix &invmat);
|
||||
|
||||
/** Get the current viewmatrix */
|
||||
virtual osg::Matrix getMatrix() const;
|
||||
|
||||
/** Get the current inverse view matrix */
|
||||
virtual osg::Matrix getInverseMatrix() const ;
|
||||
|
||||
/** Set the subgraph this manipulator is driving the eye through.
|
||||
\param node root of subgraph
|
||||
*/
|
||||
virtual void setNode(osg::Node*);
|
||||
|
||||
/** Get the root node of the subgraph this manipulator is driving the eye through (const)*/
|
||||
virtual const osg::Node* getNode() const;
|
||||
|
||||
/** Get the root node of the subgraph this manipulator is driving the eye through */
|
||||
virtual osg::Node* getNode();
|
||||
|
||||
/** Computes the home position based on the extents and scale of the
|
||||
scene graph rooted at node */
|
||||
virtual void computeHomePosition();
|
||||
|
||||
/** Sets the viewpoint matrix to the home position */
|
||||
virtual void home(const osgGA::GUIEventAdapter&, osgGA::GUIActionAdapter&) ;
|
||||
|
||||
/** Handles incoming osgGA events */
|
||||
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter &aa);
|
||||
|
||||
/** Reports Usage parameters to the application */
|
||||
void getUsage(osg::ApplicationUsage& usage) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::Node> _node;
|
||||
float _viewAngle;
|
||||
osg::Matrix _matrix;
|
||||
osg::Matrix _inverseMatrix;
|
||||
osg::Matrix _offset;
|
||||
|
||||
double _minHeightAboveGround;
|
||||
double _minDistanceInFront;
|
||||
|
||||
double _speedEpsilon;
|
||||
double _forwardSpeed;
|
||||
double _sideSpeed;
|
||||
double _upSpeed;
|
||||
double _speedAccelerationFactor;
|
||||
double _speedDecelerationFactor;
|
||||
|
||||
bool _decelerateUpSideRate;
|
||||
|
||||
double _directionRotationEpsilon;
|
||||
double _directionRotationRate;
|
||||
double _directionRotationAcceleration;
|
||||
double _directionRotationDeceleration;
|
||||
|
||||
double _viewOffsetDelta;
|
||||
double _pitchOffsetRate;
|
||||
double _pitchOffset;
|
||||
double _yawOffsetRate;
|
||||
double _yawOffset;
|
||||
|
||||
double _t0;
|
||||
double _dt;
|
||||
osg::Vec3 _direction;
|
||||
osg::Vec3 _position;
|
||||
|
||||
|
||||
bool _shift;
|
||||
bool _ctrl;
|
||||
bool _decelerateOffsetRate;
|
||||
|
||||
bool _straightenOffset;
|
||||
|
||||
void _home();
|
||||
void _stop();
|
||||
void _keyDown( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &);
|
||||
void _keyUp( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter &);
|
||||
void _frame(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter &);
|
||||
|
||||
void _adjustPosition();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user