diff --git a/src/osgGA/TerrainManipulator.cpp b/src/osgGA/TerrainManipulator.cpp index 585f8659c..3b2cd8db4 100644 --- a/src/osgGA/TerrainManipulator.cpp +++ b/src/osgGA/TerrainManipulator.cpp @@ -1,13 +1,13 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ @@ -22,7 +22,7 @@ using namespace osgGA; TerrainManipulator::TerrainManipulator() { - _rotationMode =ELEVATION_AZIM; + _rotationMode =ELEVATION_AZIM; _distance = 1.0; _thrown = false; @@ -45,7 +45,7 @@ void TerrainManipulator::setRotationMode(RotationMode mode) void TerrainManipulator::setNode(osg::Node* node) { _node = node; - + if (_node.get()) { const osg::BoundingSphere& boundingSphere=_node->getBound(); @@ -53,10 +53,10 @@ void TerrainManipulator::setNode(osg::Node* node) _minimumDistance = osg::clampBetween( boundingSphere._radius * minimumDistanceScale, 0.00001f,1.0f); - + osg::notify(osg::INFO)<<"Setting terrain manipulator _minimumDistance to "<<_minimumDistance< segDowVector = new osg::LineSegment; segLookVector->set(eye+getUpVector(eyePointCoordFrame)*distance, eye-getUpVector(eyePointCoordFrame)*distance); iv.addLineSegment(segLookVector.get()); _node->accept(iv); - + hitFound = false; if (iv.hits()) { @@ -299,7 +310,7 @@ void TerrainManipulator::setByMatrix(const osg::Matrixd& matrix) hitFound = true; } } - } + } CoordinateFrame coordinateFrame = getCoordinateFrame(_center); _previousUp = getUpVector(coordinateFrame); @@ -325,7 +336,7 @@ void TerrainManipulator::computePosition(const osg::Vec3d& eye,const osg::Vec3d& osg::Vec3 lv(center-eye); _distance = lv.length(); _center = center; - + osg::notify(osg::INFO) << "In compute"<< std::endl; if (_node.valid()) @@ -425,28 +436,28 @@ bool TerrainManipulator::calcMovement() osg::Vec3d lookVector = -getUpVector(rotation_matrix); osg::Vec3d sideVector = getSideVector(rotation_matrix); osg::Vec3d upVector = getFrontVector(rotation_matrix); - + CoordinateFrame coordinateFrame = getCoordinateFrame(_center); osg::Vec3d localUp = getUpVector(coordinateFrame); //osg::Vec3d localUp = _previousUp; - + osg::Vec3d forwardVector = localUp^sideVector; sideVector = forwardVector^localUp; forwardVector.normalize(); sideVector.normalize(); - + osg::Quat rotate_elevation; rotate_elevation.makeRotate(dy,sideVector); osg::Quat rotate_azim; rotate_azim.makeRotate(-dx,localUp); - + _rotation = _rotation * rotate_elevation * rotate_azim; - + } - + return true; } @@ -481,7 +492,7 @@ bool TerrainManipulator::calcMovement() _center += dv; // need to recompute the intersection point along the look vector. - + if (_node.valid()) { @@ -543,7 +554,7 @@ bool TerrainManipulator::calcMovement() { osg::notify(osg::INFO)<<"New up orientation nearly inline - no need to rotate"<