From 504dd515d30d76fb82d985fc45431e75e49c82fa Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 9 Jul 2004 15:21:33 +0000 Subject: [PATCH] Improvements to the handling of coordinate system nodes --- include/osgGA/KeySwitchMatrixManipulator | 4 ++++ include/osgGA/MatrixManipulator | 11 +++++++++++ include/osgGA/TerrainManipulator | 9 --------- src/osgGA/KeySwitchMatrixManipulator.cpp | 11 +++++++++++ src/osgGA/MatrixManipulator.cpp | 1 + src/osgGA/TerrainManipulator.cpp | 1 - src/osgProducer/OsgCameraGroup.cpp | 1 + src/osgProducer/Viewer.cpp | 20 +++++++++++++++----- 8 files changed, 43 insertions(+), 15 deletions(-) diff --git a/include/osgGA/KeySwitchMatrixManipulator b/include/osgGA/KeySwitchMatrixManipulator index c32ec4a66..fca0b7ba7 100644 --- a/include/osgGA/KeySwitchMatrixManipulator +++ b/include/osgGA/KeySwitchMatrixManipulator @@ -77,6 +77,10 @@ public: // Overrides from MatrixManipulator... + /** set the minimum distance (as ratio) the eye point can be zoomed in towards the + center before the center is pushed forward.*/ + virtual void setMinimumDistance(float minimumDistance); + /** set the coordinate frame which callback tells the manipulator which way is up, east and north.*/ virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb); diff --git a/include/osgGA/MatrixManipulator b/include/osgGA/MatrixManipulator index 4164d262d..60bbd3797 100644 --- a/include/osgGA/MatrixManipulator +++ b/include/osgGA/MatrixManipulator @@ -50,6 +50,15 @@ 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.*/ + virtual void setMinimumDistance(float minimumDistance) { _minimumDistance=minimumDistance; } + + /** get the minimum distance (as ratio) the eye point can be zoomed in */ + float getMinimumDistance() const { return _minimumDistance; } + + /** set the coordinate frame which callback tells the manipulator which way is up, east and north.*/ virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb) { _coordinateFrameCallback = cb; } @@ -125,6 +134,8 @@ protected: MatrixManipulator(); virtual ~MatrixManipulator(); + double _minimumDistance; + osg::ref_ptr _coordinateFrameCallback; }; diff --git a/include/osgGA/TerrainManipulator b/include/osgGA/TerrainManipulator index efed6baf9..226615b6d 100644 --- a/include/osgGA/TerrainManipulator +++ b/include/osgGA/TerrainManipulator @@ -38,14 +38,6 @@ class OSGGA_EXPORT TerrainManipulator : public MatrixManipulator RotationMode getRotationMode() const { return _rotationMode; } - /** set the minimum distance (as ratio) the eye point can be zoomed in towards the - center before the center is pushed forward.*/ - void setMinimumDistance(float minimumDistance) { _minimumDistance=minimumDistance; } - - /** get the minimum distance (as ratio) the eye point can be zoomed in */ - float getMinimumDistance() const { return _minimumDistance; } - - /** set the position of the matrix manipulator using a 4x4 Matrix.*/ virtual void setByMatrix(const osg::Matrixd& matrix); @@ -123,7 +115,6 @@ class OSGGA_EXPORT TerrainManipulator : public MatrixManipulator osg::ref_ptr _node; RotationMode _rotationMode; - double _minimumDistance; bool _thrown; diff --git a/src/osgGA/KeySwitchMatrixManipulator.cpp b/src/osgGA/KeySwitchMatrixManipulator.cpp index 694bb2c02..3e16627e0 100644 --- a/src/osgGA/KeySwitchMatrixManipulator.cpp +++ b/src/osgGA/KeySwitchMatrixManipulator.cpp @@ -61,6 +61,17 @@ void KeySwitchMatrixManipulator::setNode(osg::Node* node) } } +void KeySwitchMatrixManipulator::setMinimumDistance(float minimumDistance) +{ + _minimumDistance = minimumDistance; + for(KeyManipMap::iterator itr=_manips.begin(); + itr!=_manips.end(); + ++itr) + { + itr->second.second->setMinimumDistance(minimumDistance); + } +} + void KeySwitchMatrixManipulator::setCoordinateFrameCallback(CoordinateFrameCallback* cb) { _coordinateFrameCallback = cb; diff --git a/src/osgGA/MatrixManipulator.cpp b/src/osgGA/MatrixManipulator.cpp index aa7d88c39..f6134fd0f 100644 --- a/src/osgGA/MatrixManipulator.cpp +++ b/src/osgGA/MatrixManipulator.cpp @@ -7,6 +7,7 @@ using namespace osgGA; MatrixManipulator::MatrixManipulator() { + _minimumDistance = 0.001; } diff --git a/src/osgGA/TerrainManipulator.cpp b/src/osgGA/TerrainManipulator.cpp index 61c9dd829..e772ddefa 100644 --- a/src/osgGA/TerrainManipulator.cpp +++ b/src/osgGA/TerrainManipulator.cpp @@ -9,7 +9,6 @@ using namespace osgGA; TerrainManipulator::TerrainManipulator() { _rotationMode =ELEVATION_AZIM; - _minimumDistance = 1.0; _distance = 1.0; _thrown = false; diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index 03a7f4dc6..9bf443628 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -343,6 +343,7 @@ bool OsgCameraGroup::realize() osgUtil::SceneView* sv = sh->getSceneView(); sv->setDefaults(); + //sv->setLight(0); if (_renderSurfaceStateMap.count(rs)==0) { diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 5d4d679cb..40e49ee5e 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -181,7 +181,7 @@ public: virtual osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const { - osg::notify(osg::INFO)<<"getCoordinateFrame("<getCoordindateSystemNodePath(); @@ -189,7 +189,7 @@ public: { osg::Matrixd coordinateFrame; - // have to crete a copy of the RefNodePath to create an osg::NodePath + // have to create a copy of the RefNodePath to create an osg::NodePath // to allow it to be used along with the computeLocalToWorld call. osg::NodePath tmpPath; for(Viewer::RefNodePath::const_iterator itr=refNodePath.begin(); @@ -202,17 +202,23 @@ public: osg::CoordinateSystemNode* csn = dynamic_cast(tmpPath.back()); if (csn) { - coordinateFrame = csn->computeLocalCoordinateFrame(position)* osg::computeLocalToWorld(tmpPath); + osg::Vec3 local_position = position*osg::computeWorldToLocal(tmpPath); + osg::notify(osg::NOTICE)<<"local postion "<computeLocalCoordinateFrame(position)* osg::computeLocalToWorld(tmpPath)"<computeLocalCoordinateFrame(local_position)* osg::computeLocalToWorld(tmpPath); } else { + osg::notify(osg::NOTICE)<<"osg::computeLocalToWorld(tmpPath)"<setNode(getTopMostSceneData()); } void Viewer::setKeyboardMouse(Producer::KeyboardMouse* kbm)