From 5d10547ac5c38a88d3f012a7e3cab13fb255adf5 Mon Sep 17 00:00:00 2001 From: Don BURNS Date: Sun, 20 Mar 2005 23:57:17 +0000 Subject: [PATCH] Added getCameraByName method to viewer and home(double currentTime) to MatrixManipulator, UFO, Trackball and ANimation manipulator. --- include/osg/Viewport | 2 -- include/osgGA/AnimationPathManipulator | 1 + include/osgGA/MatrixManipulator | 8 ++++++++ include/osgGA/TrackballManipulator | 1 + include/osgGA/UFOManipulator | 4 +++- src/osgGA/AnimationPathManipulator.cpp | 11 +++++++---- src/osgGA/TrackballManipulator.cpp | 8 ++++++-- src/osgGA/UFOManipulator.cpp | 18 +++++++++++------- 8 files changed, 37 insertions(+), 16 deletions(-) diff --git a/include/osg/Viewport b/include/osg/Viewport index c58f71dbc..184e40a18 100644 --- a/include/osg/Viewport +++ b/include/osg/Viewport @@ -23,8 +23,6 @@ namespace osg { class SG_EXPORT Viewport : public StateAttribute { public : - - Viewport(); Viewport(int x,int y,int width,int height): diff --git a/include/osgGA/AnimationPathManipulator b/include/osgGA/AnimationPathManipulator index 7e5ee724d..a2da03ae0 100644 --- a/include/osgGA/AnimationPathManipulator +++ b/include/osgGA/AnimationPathManipulator @@ -68,6 +68,7 @@ class OSGGA_EXPORT AnimationPathManipulator : public MatrixManipulator void init(const GUIEventAdapter& ea,GUIActionAdapter& us); void home(const GUIEventAdapter& ea,GUIActionAdapter& us); + void home(double currentTime); virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us); diff --git a/include/osgGA/MatrixManipulator b/include/osgGA/MatrixManipulator index b5c6ac0b7..81ff9ee51 100644 --- a/include/osgGA/MatrixManipulator +++ b/include/osgGA/MatrixManipulator @@ -158,6 +158,14 @@ public: */ virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {} + /** + Move the camera to the default position. + This version does not require GUIEventAdapter and GUIActionAdapter so may be + called from somewhere other than a handle() method in GUIEventHandler. Application + must be aware of implications. + */ + virtual void home(double /*currentTime*/) {} + /** Start/restart the manipulator. FIXME: what does this actually mean? Provide examples. diff --git a/include/osgGA/TrackballManipulator b/include/osgGA/TrackballManipulator index 845aa5f0a..d05e07cbf 100644 --- a/include/osgGA/TrackballManipulator +++ b/include/osgGA/TrackballManipulator @@ -67,6 +67,7 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator /** Move the camera to the default position. May be ignored by manipulators if home functionality is not appropriate.*/ virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us); + virtual void home(double); /** Start/restart the manipulator.*/ virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us); diff --git a/include/osgGA/UFOManipulator b/include/osgGA/UFOManipulator index 0d32120d5..faf343731 100644 --- a/include/osgGA/UFOManipulator +++ b/include/osgGA/UFOManipulator @@ -100,7 +100,9 @@ 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); + void home(double); + + virtual void init(const GUIEventAdapter& ,GUIActionAdapter&); /** Handles incoming osgGA events */ bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter &aa); diff --git a/src/osgGA/AnimationPathManipulator.cpp b/src/osgGA/AnimationPathManipulator.cpp index 754571001..be62fd5b3 100644 --- a/src/osgGA/AnimationPathManipulator.cpp +++ b/src/osgGA/AnimationPathManipulator.cpp @@ -44,17 +44,20 @@ AnimationPathManipulator::AnimationPathManipulator( const std::string& filename } -void AnimationPathManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter&) +void AnimationPathManipulator::home(double currentTime) { if (_animationPath.valid()) { - _timeOffset = _animationPath->getFirstTime()-ea.time(); + _timeOffset = _animationPath->getFirstTime()-currentTime; } - // reset the timing of the animation. _numOfFramesSinceStartOfTimedPeriod=-1; - +} + +void AnimationPathManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter&) +{ + home(ea.time()); } void AnimationPathManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& aa) diff --git a/src/osgGA/TrackballManipulator.cpp b/src/osgGA/TrackballManipulator.cpp index b33138a56..5c94ccf5c 100644 --- a/src/osgGA/TrackballManipulator.cpp +++ b/src/osgGA/TrackballManipulator.cpp @@ -46,11 +46,15 @@ osg::Node* TrackballManipulator::getNode() } -void TrackballManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us) +void TrackballManipulator::home(double currentTime) { if (getAutoComputeHomePosition()) computeHomePosition(); - computePosition(_homeEye, _homeCenter, _homeUp); +} + +void TrackballManipulator::home(const GUIEventAdapter& ea ,GUIActionAdapter& us) +{ + home(ea.time()); us.requestRedraw(); } diff --git a/src/osgGA/UFOManipulator.cpp b/src/osgGA/UFOManipulator.cpp index d93f9f34a..996ceb287 100644 --- a/src/osgGA/UFOManipulator.cpp +++ b/src/osgGA/UFOManipulator.cpp @@ -47,7 +47,7 @@ void UFOManipulator::setNode( osg::Node *node ) if (getAutoComputeHomePosition()) computeHomePosition(); - home(); + home(0.0); } const osg::Node* UFOManipulator::getNode() const @@ -106,7 +106,6 @@ void UFOManipulator::computeHomePosition() if( (B-A).length() == 0.0) { - puts( "DOH" ); fflush(stdout); return; } @@ -135,7 +134,7 @@ void UFOManipulator::computeHomePosition() } else { - osg::notify(osg::INFO)<<"UFOManipulator : I can't find the ground!"<