Added bool paramter to MatrixManipulator::setHomePosition(,,,bool) to allow
the autocomputehomeposition to be controlled.
This commit is contained in:
parent
2003c27714
commit
da5fa4cbcd
@ -109,7 +109,7 @@ 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 setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition=false);
|
||||
|
||||
virtual void setAutoComputeHomePosition(bool flag);
|
||||
|
||||
|
@ -114,24 +114,30 @@ 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)
|
||||
/** Manually set the home position, and set the automatic compute of home position. */
|
||||
virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition=false)
|
||||
{
|
||||
setAutoComputeHomePosition(autoComputeHomePosition);
|
||||
_homeEye = eye;
|
||||
_homeCenter = center;
|
||||
_homeUp = up;
|
||||
}
|
||||
|
||||
/** Get the mnaully set home position. */
|
||||
virtual void getHomePosition(osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up)
|
||||
{
|
||||
eye = _homeEye;
|
||||
center = _homeCenter;
|
||||
up = _homeUp;
|
||||
}
|
||||
|
||||
|
||||
/** Set whether the automatic compute of the home position is enabled.*/
|
||||
virtual void setAutoComputeHomePosition(bool flag) { _autoComputeHomePosition = flag; }
|
||||
|
||||
/** Get whether the automatic compute of the home position is enabled.*/
|
||||
bool getAutoComputeHomePosition() const { return _autoComputeHomePosition; }
|
||||
|
||||
/** Compute the home position.*/
|
||||
virtual void computeHomePosition()
|
||||
{
|
||||
if(getNode())
|
||||
@ -140,7 +146,8 @@ public:
|
||||
|
||||
setHomePosition(boundingSphere._center+osg::Vec3( 0.0,-3.5f * boundingSphere._radius,0.0f),
|
||||
boundingSphere._center,
|
||||
osg::Vec3(0.0f,0.0f,1.0f));
|
||||
osg::Vec3(0.0f,0.0f,1.0f),
|
||||
_autoComputeHomePosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,7 @@ void KeySwitchMatrixManipulator::addMatrixManipulator(int key, std::string name,
|
||||
_manips[key]=std::make_pair(name,osg::ref_ptr<MatrixManipulator>(cm));
|
||||
if(!_current.valid()){
|
||||
_current=cm;
|
||||
_current->setAutoComputeHomePosition(_autoComputeHomePosition);
|
||||
_current->setHomePosition(_homeEye,_homeCenter,_homeUp);
|
||||
_current->setHomePosition(_homeEye,_homeCenter,_homeUp,_autoComputeHomePosition);
|
||||
_current->setNode(0);
|
||||
_current->setCoordinateFrameCallback(getCoordinateFrameCallback());
|
||||
_current->setByMatrix(getMatrix());
|
||||
@ -36,8 +35,7 @@ void KeySwitchMatrixManipulator::selectMatrixManipulator(unsigned int num)
|
||||
|
||||
if (itr!=_manips.end())
|
||||
{
|
||||
itr->second.second->setAutoComputeHomePosition(_autoComputeHomePosition);
|
||||
itr->second.second->setHomePosition(_homeEye,_homeCenter,_homeUp);
|
||||
itr->second.second->setHomePosition(_homeEye,_homeCenter,_homeUp,_autoComputeHomePosition);
|
||||
|
||||
if (_current.valid())
|
||||
{
|
||||
@ -66,14 +64,14 @@ void KeySwitchMatrixManipulator::setNode(osg::Node* node)
|
||||
}
|
||||
}
|
||||
|
||||
void KeySwitchMatrixManipulator::setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up)
|
||||
void KeySwitchMatrixManipulator::setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition)
|
||||
{
|
||||
MatrixManipulator::setHomePosition(eye, center, up);
|
||||
MatrixManipulator::setHomePosition(eye, center, up, autoComputeHomePosition);
|
||||
for(KeyManipMap::iterator itr=_manips.begin();
|
||||
itr!=_manips.end();
|
||||
++itr)
|
||||
{
|
||||
itr->second.second->setHomePosition(eye, center, up);
|
||||
itr->second.second->setHomePosition(eye, center, up, autoComputeHomePosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user