Improvements to the handling of coordinate system nodes
This commit is contained in:
parent
9cb7bb0f4a
commit
504dd515d3
@ -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);
|
||||
|
||||
|
@ -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> _coordinateFrameCallback;
|
||||
};
|
||||
|
||||
|
@ -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<osg::Node> _node;
|
||||
|
||||
RotationMode _rotationMode;
|
||||
double _minimumDistance;
|
||||
|
||||
bool _thrown;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -7,6 +7,7 @@ using namespace osgGA;
|
||||
|
||||
MatrixManipulator::MatrixManipulator()
|
||||
{
|
||||
_minimumDistance = 0.001;
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,7 +9,6 @@ using namespace osgGA;
|
||||
TerrainManipulator::TerrainManipulator()
|
||||
{
|
||||
_rotationMode =ELEVATION_AZIM;
|
||||
_minimumDistance = 1.0;
|
||||
_distance = 1.0;
|
||||
|
||||
_thrown = false;
|
||||
|
@ -343,6 +343,7 @@ bool OsgCameraGroup::realize()
|
||||
|
||||
osgUtil::SceneView* sv = sh->getSceneView();
|
||||
sv->setDefaults();
|
||||
//sv->setLight(0);
|
||||
|
||||
if (_renderSurfaceStateMap.count(rs)==0)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
|
||||
virtual osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const
|
||||
{
|
||||
osg::notify(osg::INFO)<<"getCoordinateFrame("<<position<<")"<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"getCoordinateFrame("<<position<<")"<<std::endl;
|
||||
|
||||
const Viewer::RefNodePath& refNodePath = _viewer->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<osg::CoordinateSystemNode*>(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 "<<local_position<<std::endl;
|
||||
|
||||
osg::notify(osg::NOTICE)<<"csn->computeLocalCoordinateFrame(position)* osg::computeLocalToWorld(tmpPath)"<<std::endl;
|
||||
|
||||
coordinateFrame = csn->computeLocalCoordinateFrame(local_position)* osg::computeLocalToWorld(tmpPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"osg::computeLocalToWorld(tmpPath)"<<std::endl;
|
||||
coordinateFrame = osg::computeLocalToWorld(tmpPath);
|
||||
}
|
||||
return coordinateFrame;
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::INFO)<<" no coordinate system found, using default orientation"<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" no coordinate system found, using default orientation"<<std::endl;
|
||||
return osg::Matrixd::translate(position);
|
||||
}
|
||||
}
|
||||
@ -332,8 +338,12 @@ void Viewer::computeActiveCoordindateSystemNodePath()
|
||||
void Viewer::updatedSceneData()
|
||||
{
|
||||
OsgCameraGroup::updatedSceneData();
|
||||
|
||||
|
||||
// refresh the coordinate system node path.
|
||||
computeActiveCoordindateSystemNodePath();
|
||||
|
||||
// refresh the camera manipulators
|
||||
if (_keyswitchManipulator.valid()) _keyswitchManipulator->setNode(getTopMostSceneData());
|
||||
}
|
||||
|
||||
void Viewer::setKeyboardMouse(Producer::KeyboardMouse* kbm)
|
||||
|
Loading…
Reference in New Issue
Block a user