Added support for View::setFustionDistance(..)
This commit is contained in:
@@ -500,16 +500,7 @@ int main( int argc, char **argv )
|
||||
(*itr)->useCursor(false);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// set all the sceneview's up so that their left and right add cull masks are set up.
|
||||
for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin();
|
||||
itr!=viewer.getSceneHandlerList().end();
|
||||
++itr)
|
||||
{
|
||||
osgUtil::SceneView* sceneview = (*itr)->getSceneView();
|
||||
sceneview->setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,radius);
|
||||
}
|
||||
#endif
|
||||
viewer.setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,radius);
|
||||
|
||||
// set up the SlideEventHandler.
|
||||
seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive);
|
||||
|
||||
@@ -94,6 +94,19 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
/** Set the DsplaySettings object associated with this view.*/
|
||||
const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
|
||||
|
||||
/** Set the FusionDistanceMode and Value. Note, is used only when working in stereo.*/
|
||||
void setFusionDistance(osgUtil::SceneView::FusionDistanceMode mode,float value=1.0f)
|
||||
{
|
||||
_fusionDistanceMode = mode;
|
||||
_fusionDistanceValue = value;
|
||||
}
|
||||
|
||||
/** Get the FusionDistanceMode.*/
|
||||
osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return _fusionDistanceMode; }
|
||||
|
||||
/** Get the FusionDistanceValue. Note, only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.*/
|
||||
float getFusionDistanceValue() const { return _fusionDistanceValue; }
|
||||
|
||||
|
||||
/** Convinience method for creating slave Cameras and associated GraphicsWindows across all screens.*/
|
||||
void setUpViewAcrossAllScreens();
|
||||
@@ -142,6 +155,8 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
EventHandlers _eventHandlers;
|
||||
|
||||
osg::ref_ptr<osg::DisplaySettings> _displaySettings;
|
||||
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode;
|
||||
float _fusionDistanceValue;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -553,6 +553,10 @@ struct CompositeViewerRenderingOperation : public osg::Operation
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"RenderingOperation"<<std::endl;
|
||||
|
||||
// pass on the fusion distance settings from the View to the SceneView
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(_sceneView->getCamera()->getView());
|
||||
if (view) _sceneView->setFusionDistance(view->getFusionDistanceMode(), view->getFusionDistanceValue());
|
||||
|
||||
_sceneView->inheritCullSettings(*(_sceneView->getCamera()));
|
||||
_sceneView->cull();
|
||||
_sceneView->draw();
|
||||
@@ -1148,7 +1152,13 @@ void CompositeViewer::updateTraversal()
|
||||
++vitr)
|
||||
{
|
||||
View* view = vitr->get();
|
||||
if (view->getCameraManipulator()) view->getCamera()->setViewMatrix( view->getCameraManipulator()->getInverseMatrix());
|
||||
if (view->getCameraManipulator())
|
||||
{
|
||||
view->setFusionDistance( view->getCameraManipulator()->getFusionDistanceMode(),
|
||||
view->getCameraManipulator()->getFusionDistanceValue() );
|
||||
|
||||
view->getCamera()->setViewMatrix( view->getCameraManipulator()->getInverseMatrix());
|
||||
}
|
||||
view->updateSlaves();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
using namespace osgViewer;
|
||||
|
||||
View::View()
|
||||
View::View():
|
||||
_fusionDistanceMode(osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE),
|
||||
_fusionDistanceValue(1.0f)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"Constructing osgViewer::View"<<std::endl;
|
||||
|
||||
@@ -33,7 +35,9 @@ View::View()
|
||||
|
||||
View::View(const osgViewer::View& view, const osg::CopyOp& copyop):
|
||||
osg::View(view,copyop),
|
||||
osgGA::GUIActionAdapter()
|
||||
osgGA::GUIActionAdapter(),
|
||||
_fusionDistanceMode(view._fusionDistanceMode),
|
||||
_fusionDistanceValue(view._fusionDistanceValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,10 @@ struct ViewerRenderingOperation : public osg::Operation, public ViewerQuerySuppo
|
||||
// do cull taversal
|
||||
osg::Timer_t beforeCullTick = osg::Timer::instance()->tick();
|
||||
|
||||
// pass on the fusion distance settings from the View to the SceneView
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(_sceneView->getCamera()->getView());
|
||||
if (view) _sceneView->setFusionDistance(view->getFusionDistanceMode(), view->getFusionDistanceValue());
|
||||
|
||||
_sceneView->inheritCullSettings(*(_sceneView->getCamera()));
|
||||
|
||||
_sceneView->cull();
|
||||
@@ -305,6 +309,10 @@ struct ViewerDoubleBufferedRenderingOperation : public osg::Operation, public Vi
|
||||
if (sceneView)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"Culling buffer "<<_currentCull<<std::endl;
|
||||
|
||||
// pass on the fusion distance settings from the View to the SceneView
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(sceneView->getCamera()->getView());
|
||||
if (view) sceneView->setFusionDistance(view->getFusionDistanceMode(), view->getFusionDistanceValue());
|
||||
|
||||
osg::Stats* stats = sceneView->getCamera()->getStats();
|
||||
osg::State* state = sceneView->getState();
|
||||
@@ -456,6 +464,10 @@ struct ViewerDoubleBufferedRenderingOperation : public osg::Operation, public Vi
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"RenderingOperation"<<std::endl;
|
||||
|
||||
// pass on the fusion distance settings from the View to the SceneView
|
||||
osgViewer::View* view = dynamic_cast<osgViewer::View*>(sceneView->getCamera()->getView());
|
||||
if (view) sceneView->setFusionDistance(view->getFusionDistanceMode(), view->getFusionDistanceValue());
|
||||
|
||||
osg::Stats* stats = sceneView->getCamera()->getStats();
|
||||
osg::State* state = sceneView->getState();
|
||||
const osg::FrameStamp* fs = state->getFrameStamp();
|
||||
@@ -2043,6 +2055,9 @@ void Viewer::updateTraversal()
|
||||
|
||||
if (_cameraManipulator.valid())
|
||||
{
|
||||
setFusionDistance( getCameraManipulator()->getFusionDistanceMode(),
|
||||
getCameraManipulator()->getFusionDistanceValue() );
|
||||
|
||||
_camera->setViewMatrix(_cameraManipulator->getInverseMatrix());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user