Improvements to the handling of coordinate system nodes
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user