Added getCameraByName method to viewer and home(double currentTime) to

MatrixManipulator, UFO, Trackball and ANimation manipulator.
This commit is contained in:
Don BURNS 2005-03-20 23:57:17 +00:00
parent c579ab511e
commit 5d10547ac5
8 changed files with 37 additions and 16 deletions

View File

@ -23,8 +23,6 @@ namespace osg {
class SG_EXPORT Viewport : public StateAttribute class SG_EXPORT Viewport : public StateAttribute
{ {
public : public :
Viewport(); Viewport();
Viewport(int x,int y,int width,int height): Viewport(int x,int y,int width,int height):

View File

@ -68,6 +68,7 @@ class OSGGA_EXPORT AnimationPathManipulator : public MatrixManipulator
void init(const GUIEventAdapter& ea,GUIActionAdapter& us); void init(const GUIEventAdapter& ea,GUIActionAdapter& us);
void home(const GUIEventAdapter& ea,GUIActionAdapter& us); void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
void home(double currentTime);
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us); virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);

View File

@ -158,6 +158,14 @@ public:
*/ */
virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {} 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. Start/restart the manipulator.
FIXME: what does this actually mean? Provide examples. FIXME: what does this actually mean? Provide examples.

View File

@ -67,6 +67,7 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator
/** Move the camera to the default position. /** Move the camera to the default position.
May be ignored by manipulators if home functionality is not appropriate.*/ May be ignored by manipulators if home functionality is not appropriate.*/
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us); virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
virtual void home(double);
/** Start/restart the manipulator.*/ /** Start/restart the manipulator.*/
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us); virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);

View File

@ -100,7 +100,9 @@ class OSGGA_EXPORT UFOManipulator : public osgGA::MatrixManipulator
/** Sets the viewpoint matrix to the home position */ /** Sets the viewpoint matrix to the home position */
virtual void home(const osgGA::GUIEventAdapter&, osgGA::GUIActionAdapter&) ; virtual void home(const osgGA::GUIEventAdapter&, osgGA::GUIActionAdapter&) ;
void home(void); void home(double);
virtual void init(const GUIEventAdapter& ,GUIActionAdapter&);
/** Handles incoming osgGA events */ /** Handles incoming osgGA events */
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter &aa); bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter &aa);

View File

@ -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()) if (_animationPath.valid())
{ {
_timeOffset = _animationPath->getFirstTime()-ea.time(); _timeOffset = _animationPath->getFirstTime()-currentTime;
} }
// reset the timing of the animation. // reset the timing of the animation.
_numOfFramesSinceStartOfTimedPeriod=-1; _numOfFramesSinceStartOfTimedPeriod=-1;
}
void AnimationPathManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter&)
{
home(ea.time());
} }
void AnimationPathManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& aa) void AnimationPathManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& aa)

View File

@ -46,11 +46,15 @@ osg::Node* TrackballManipulator::getNode()
} }
void TrackballManipulator::home(const GUIEventAdapter& ,GUIActionAdapter& us) void TrackballManipulator::home(double currentTime)
{ {
if (getAutoComputeHomePosition()) computeHomePosition(); if (getAutoComputeHomePosition()) computeHomePosition();
computePosition(_homeEye, _homeCenter, _homeUp); computePosition(_homeEye, _homeCenter, _homeUp);
}
void TrackballManipulator::home(const GUIEventAdapter& ea ,GUIActionAdapter& us)
{
home(ea.time());
us.requestRedraw(); us.requestRedraw();
} }

View File

@ -47,7 +47,7 @@ void UFOManipulator::setNode( osg::Node *node )
if (getAutoComputeHomePosition()) if (getAutoComputeHomePosition())
computeHomePosition(); computeHomePosition();
home(); home(0.0);
} }
const osg::Node* UFOManipulator::getNode() const const osg::Node* UFOManipulator::getNode() const
@ -106,7 +106,6 @@ void UFOManipulator::computeHomePosition()
if( (B-A).length() == 0.0) if( (B-A).length() == 0.0)
{ {
puts( "DOH" ); fflush(stdout);
return; return;
} }
@ -135,7 +134,7 @@ void UFOManipulator::computeHomePosition()
} }
else else
{ {
osg::notify(osg::INFO)<<"UFOManipulator : I can't find the ground!"<<std::endl; osg::notify(osg::WARN)<<"UFOManipulator : I can't find the ground!"<<std::endl;
ground = 0.0; ground = 0.0;
} }
@ -144,12 +143,17 @@ void UFOManipulator::computeHomePosition()
setHomePosition( p, p + osg::Vec3(0,1,0), osg::Vec3(0,0,1) ); setHomePosition( p, p + osg::Vec3(0,1,0), osg::Vec3(0,0,1) );
} }
void UFOManipulator::home(const osgGA::GUIEventAdapter&, osgGA::GUIActionAdapter&) void UFOManipulator::init(const GUIEventAdapter& ea, GUIActionAdapter&)
{ {
home(); home(ea.time());
} }
void UFOManipulator::home() void UFOManipulator::home(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
home(ea.time());
}
void UFOManipulator::home(double)
{ {
if (getAutoComputeHomePosition()) if (getAutoComputeHomePosition())
computeHomePosition(); computeHomePosition();
@ -376,7 +380,7 @@ void UFOManipulator::_keyDown( const osgGA::GUIEventAdapter &ea, osgGA::GUIActio
break; break;
case 'H': case 'H':
home(); home(ea.time());
break; break;
} }
} }