diff --git a/include/osgGA/UFOManipulator b/include/osgGA/UFOManipulator index c35395a75..6a86164d3 100644 --- a/include/osgGA/UFOManipulator +++ b/include/osgGA/UFOManipulator @@ -100,6 +100,7 @@ class OSGGA_EXPORT UFOManipulator : public osgGA::MatrixManipulator /** Sets the viewpoint matrix to the home position */ virtual void home(const osgGA::GUIEventAdapter&, osgGA::GUIActionAdapter&) ; + void home(void); /** Handles incoming osgGA events */ bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter &aa); @@ -107,6 +108,9 @@ class OSGGA_EXPORT UFOManipulator : public osgGA::MatrixManipulator /** Reports Usage parameters to the application */ void getUsage(osg::ApplicationUsage& usage) const; + /** Report the current position as LookAt vectors */ + void getCurrentPositionAsLookAt( osg::Vec3 &eye, osg::Vec3 ¢er, osg::Vec3 &up ); + protected: private: @@ -151,7 +155,6 @@ class OSGGA_EXPORT UFOManipulator : public osgGA::MatrixManipulator bool _straightenOffset; - void _home(); void _stop(); void _keyDown( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &); void _keyUp( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter &); diff --git a/include/osgProducer/Viewer b/include/osgProducer/Viewer index 0b06ca34b..3170dd25b 100644 --- a/include/osgProducer/Viewer +++ b/include/osgProducer/Viewer @@ -276,6 +276,7 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction void selectCameraManipulator(unsigned int no); void getCameraManipulatorNameList( std::list &nameList ); bool selectCameraManipulatorByName( const std::string &name ); + osgGA::MatrixManipulator *getCameraManipulatorByName( const std::string &name ); void setRecordingAnimationPath(bool on) { _recordingAnimationPath = on; } diff --git a/src/osgGA/UFOManipulator.cpp b/src/osgGA/UFOManipulator.cpp index 2ce2560bb..669981f5c 100644 --- a/src/osgGA/UFOManipulator.cpp +++ b/src/osgGA/UFOManipulator.cpp @@ -43,7 +43,7 @@ void UFOManipulator::setNode( osg::Node *node ) if (getAutoComputeHomePosition()) computeHomePosition(); - _home(); + home(); } const osg::Node* UFOManipulator::getNode() const @@ -142,10 +142,10 @@ void UFOManipulator::computeHomePosition() void UFOManipulator::home(const osgGA::GUIEventAdapter&, osgGA::GUIActionAdapter&) { - _home(); + home(); } -void UFOManipulator::_home() +void UFOManipulator::home() { if (getAutoComputeHomePosition()) computeHomePosition(); @@ -194,6 +194,7 @@ bool UFOManipulator::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAda void UFOManipulator::getUsage(osg::ApplicationUsage& usage) const { + /** Way too busy. This needs to wait until we have a scrollable window usage.addKeyboardMouseBinding("UFO Manipulator: ", "Reset the viewing angle to 0.0"); usage.addKeyboardMouseBinding("UFO Manipulator: ", "Acceleration forward."); usage.addKeyboardMouseBinding("UFO Manipulator: ", "Acceleration backward (or deceleration forward"); @@ -209,7 +210,10 @@ void UFOManipulator::getUsage(osg::ApplicationUsage& usage) const usage.addKeyboardMouseBinding("UFO Manipulator: ", "Rotate view (but not direction of travel) down."); usage.addKeyboardMouseBinding("UFO Manipulator: ", "Rotate view (but not direction of travel) left."); usage.addKeyboardMouseBinding("UFO Manipulator: ", "Rotate view (but not direction of travel) right."); - usage.addKeyboardMouseBinding("UFO Manipulator: 'H'", "go to Home position."); + */ + usage.addKeyboardMouseBinding("UFO: ", "Please see http://www.openscenegraph.org/html/UFOCameraManipulator.html"); + // Keep this one as it might be confusing + usage.addKeyboardMouseBinding("UFO: H", "Reset the viewing position to home"); } @@ -368,7 +372,7 @@ void UFOManipulator::_keyDown( const osgGA::GUIEventAdapter &ea, osgGA::GUIActio break; case 'H': - _home(); + home(); break; } } @@ -432,16 +436,26 @@ void UFOManipulator::_frame( const osgGA::GUIEventAdapter &ea, osgGA::GUIActionA if( _straightenOffset ) { - _pitchOffsetRate = 0.0; - _yawOffsetRate = 0.0; - _pitchOffset *= 0.99; - _yawOffset *= 0.99; - - if( fabs(_pitchOffset ) < 0.01 ) - _pitchOffset = 0.0; - if( fabs(_yawOffset ) < 0.01 ) + if( _shift ) + { _pitchOffset = 0.0; + _yawOffset = 0.0; + _pitchOffsetRate = 0.0; + _yawOffsetRate = 0.0; + } + else + { + _pitchOffsetRate = 0.0; + _yawOffsetRate = 0.0; + _pitchOffset *= 0.99; + _yawOffset *= 0.99; + if( fabs(_pitchOffset ) < 0.01 ) + _pitchOffset = 0.0; + if( fabs(_yawOffset ) < 0.01 ) + _pitchOffset = 0.0; + + } if( _pitchOffset == 0.0 && _yawOffset == 0.0 ) _straightenOffset = false; } @@ -510,3 +524,11 @@ void UFOManipulator::_stop() _upSpeed = 0.0; _directionRotationRate = 0.0; } + +void UFOManipulator::getCurrentPositionAsLookAt( osg::Vec3 &eye, osg::Vec3 ¢er, osg::Vec3 &up ) +{ + eye = _position; + center = _position + _direction; + up.set( 0, 0, 1 ); +} +