Added getCameraByName method to viewer and home(double currentTime) to
MatrixManipulator, UFO, Trackball and ANimation manipulator.
This commit is contained in:
parent
c579ab511e
commit
5d10547ac5
@ -23,8 +23,6 @@ namespace osg {
|
||||
class SG_EXPORT Viewport : public StateAttribute
|
||||
{
|
||||
public :
|
||||
|
||||
|
||||
Viewport();
|
||||
|
||||
Viewport(int x,int y,int width,int height):
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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!"<<std::endl;
|
||||
osg::notify(osg::WARN)<<"UFOManipulator : I can't find the ground!"<<std::endl;
|
||||
ground = 0.0;
|
||||
}
|
||||
|
||||
@ -144,12 +143,17 @@ void UFOManipulator::computeHomePosition()
|
||||
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())
|
||||
computeHomePosition();
|
||||
@ -376,7 +380,7 @@ void UFOManipulator::_keyDown( const osgGA::GUIEventAdapter &ea, osgGA::GUIActio
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
home();
|
||||
home(ea.time());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user