diff --git a/src/osgGA/TerrainManipulator.cpp b/src/osgGA/TerrainManipulator.cpp index afe246feb..18b33b02d 100644 --- a/src/osgGA/TerrainManipulator.cpp +++ b/src/osgGA/TerrainManipulator.cpp @@ -372,27 +372,31 @@ bool TerrainManipulator::calcMovement() { // pan model. - float scale = -0.5f*_distance; osg::Matrix rotation_matrix; rotation_matrix.set(_rotation); - osg::Vec3 dv(dx*scale,dy*scale,0.0f); - // _center += dv*rotation_matrix; + // compute look vector. + osg::Vec3 lookVector = -getUpVector(rotation_matrix); + osg::Vec3 sideVector = getSideVector(rotation_matrix); + osg::Vec3 upVector = getFrontVector(rotation_matrix); + + osg::Vec3 forwardVector =osg::Vec3(0.0f,0.0f,1.0f)^sideVector; + sideVector = forwardVector^osg::Vec3(0.0f,0.0f,1.0f); + + forwardVector.normalize(); + sideVector.normalize(); + + osg::Vec3 dv = forwardVector * (dy*scale) + sideVector * (dx*scale); + + _coordinateFrame = osg::Matrixd::translate(dv)*_coordinateFrame; // need to recompute the itersection point along the look vector. - _coordinateFrame = osg::Matrixd::rotate(_rotation.inverse())* - osg::Matrixd::translate(dx*scale,dy*scale,0.0f)* - osg::Matrixd::rotate(_rotation)* - _coordinateFrame; - - // osg::notify(osg::INDFO)<<"\tafter "<<_coordinateFrame.getTrans()<