Added a few things to osgProducer::Viewer to support UFO manipulator and
cleaned up UFOManipulator.
This commit is contained in:
@@ -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 &);
|
||||
|
||||
@@ -276,6 +276,7 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
|
||||
void selectCameraManipulator(unsigned int no);
|
||||
void getCameraManipulatorNameList( std::list<std::string> &nameList );
|
||||
bool selectCameraManipulatorByName( const std::string &name );
|
||||
osgGA::MatrixManipulator *getCameraManipulatorByName( const std::string &name );
|
||||
|
||||
|
||||
void setRecordingAnimationPath(bool on) { _recordingAnimationPath = on; }
|
||||
|
||||
@@ -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: <SpaceBar>", "Reset the viewing angle to 0.0");
|
||||
usage.addKeyboardMouseBinding("UFO Manipulator: <UpArrow>", "Acceleration forward.");
|
||||
usage.addKeyboardMouseBinding("UFO Manipulator: <DownArrow>", "Acceleration backward (or deceleration forward");
|
||||
@@ -209,7 +210,10 @@ void UFOManipulator::getUsage(osg::ApplicationUsage& usage) const
|
||||
usage.addKeyboardMouseBinding("UFO Manipulator: <Ctrl/DownArrow>", "Rotate view (but not direction of travel) down.");
|
||||
usage.addKeyboardMouseBinding("UFO Manipulator: <Ctrl/LeftArrow>", "Rotate view (but not direction of travel) left.");
|
||||
usage.addKeyboardMouseBinding("UFO Manipulator: <Ctrl/RightArrow>", "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 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user