diff --git a/src/osgGA/UFOManipulator.cpp b/src/osgGA/UFOManipulator.cpp index 5ff9bb94f..0d4dda70c 100644 --- a/src/osgGA/UFOManipulator.cpp +++ b/src/osgGA/UFOManipulator.cpp @@ -70,17 +70,31 @@ void UFOManipulator::setByMatrix( const osg::Matrixd &mat ) { _inverseMatrix = mat; _matrix.invert( _inverseMatrix ); + + _position.set( _inverseMatrix(3,0), _inverseMatrix(3,1), _inverseMatrix(3,2 )); + osg::Matrix R(_inverseMatrix); + R(3,0) = R(3,1) = R(3,2) = 0.0; + _direction = osg::Vec3(0,0,-1) * R; // yep. + + _stop(); } void UFOManipulator::setByInverseMatrix( const osg::Matrixd &invmat) { _matrix = invmat; _inverseMatrix.invert( _matrix ); + + _position.set( _inverseMatrix(3,0), _inverseMatrix(3,1), _inverseMatrix(3,2 )); + osg::Matrix R(_inverseMatrix); + R(3,0) = R(3,1) = R(3,2) = 0.0; + _direction = osg::Vec3(0,0,-1) * R; // yep. + + _stop(); } osg::Matrixd UFOManipulator::getMatrix() const { - return (_offset * _matrix); + return (_offset * _matrix); } osg::Matrixd UFOManipulator::getInverseMatrix() const @@ -136,7 +150,7 @@ void UFOManipulator::computeHomePosition() } else { - osg::notify(osg::INFO)<<"UFOManipulator : I can't find the ground!"<