Added support for matix manipulator setHomePosition(,,)

This commit is contained in:
Robert Osfield
2004-07-12 19:54:54 +00:00
parent 47910f2c2e
commit 0acbe077fa
9 changed files with 135 additions and 58 deletions

View File

@@ -52,6 +52,8 @@ class OSGGA_EXPORT DriveManipulator : public MatrixManipulator
virtual osg::Node* getNode();
virtual void computeHomePosition();
virtual void home(const GUIEventAdapter& ea,GUIActionAdapter& us);
virtual void init(const GUIEventAdapter& ea,GUIActionAdapter& us);

View File

@@ -109,6 +109,12 @@ public:
virtual osg::Node* getNode() { return _current->getNode(); }
virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up);
virtual void setAutoComputeHomePosition(bool flag);
virtual void computeHomePosition();
virtual void home(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->home(ee,aa); }
virtual void init(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->init(ee,aa); }

View File

@@ -27,6 +27,8 @@
namespace osgGA{
#define NEW_HOME_POSITION
/**
MatrixManipulator is an abstract base class defining the interface, and a certain
@@ -50,6 +52,7 @@ public:
virtual ~CoordinateFrameCallback() {}
};
/** set the minimum distance (as ratio) the eye point can be zoomed in towards the
center before the center is pushed forward.*/
@@ -111,6 +114,37 @@ public:
/** Return node if attached.*/
virtual osg::Node* getNode() { return NULL; }
virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up)
{
_homeEye = eye;
_homeCenter = center;
_homeUp = up;
}
virtual void getHomePosition(osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up)
{
_homeEye = eye;
_homeCenter = center;
_homeUp = up;
}
virtual void setAutoComputeHomePosition(bool flag) { _autoComputeHomePosition = flag; }
bool getAutoComputeHomePosition() const { return _autoComputeHomePosition; }
virtual void computeHomePosition()
{
if(getNode())
{
const osg::BoundingSphere& boundingSphere=getNode()->getBound();
setHomePosition(boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f),
boundingSphere._center,
osg::Vec3(0.0f,0.0f,1.0f));
}
}
/**
Move the camera to the default position.
May be ignored by manipulators if home functionality is not appropriate.
@@ -135,6 +169,12 @@ protected:
virtual ~MatrixManipulator();
double _minimumDistance;
bool _autoComputeHomePosition;
osg::Vec3d _homeEye;
osg::Vec3d _homeCenter;
osg::Vec3d _homeUp;
osg::ref_ptr<CoordinateFrameCallback> _coordinateFrameCallback;
};