diff --git a/include/osg/DisplaySettings b/include/osg/DisplaySettings index 21af34511..dd595e871 100644 --- a/include/osg/DisplaySettings +++ b/include/osg/DisplaySettings @@ -127,8 +127,8 @@ class SG_EXPORT DisplaySettings : public osg::Referenced bool getStencilBuffer() const { return _minimumNumberStencilBits!=0; } - void setMaxNumberOfGraphicsContexts(int num) { _maxNumOfGraphicsContexts = num; } - int getMaxNumberOfGraphicsContexts() const { return _maxNumOfGraphicsContexts; } + void setMaxNumberOfGraphicsContexts(unsigned int num) { _maxNumOfGraphicsContexts = num; } + unsigned int getMaxNumberOfGraphicsContexts() const { return _maxNumOfGraphicsContexts; } protected: @@ -152,7 +152,7 @@ class SG_EXPORT DisplaySettings : public osg::Referenced unsigned int _minimumNumberAlphaBits; unsigned int _minimumNumberStencilBits; - int _maxNumOfGraphicsContexts; + unsigned int _maxNumOfGraphicsContexts; }; diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index 20cb18a57..a38ca3419 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -190,6 +190,25 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced /** Get the ComputeNearFarMode.*/ CullVisitor::ComputeNearFarMode getComputeNearFarMode() const { return _computeNearFar;} + /** FusionDistanceMode is used only when working in stereo.*/ + enum FusionDistanceMode + { + /** Use fusion distance from the attached camera if one exist.*/ + USE_CAMERA_FUSION_DISTANCE, + /** Use fusion distance from the value set on the SceneView.*/ + USE_FUSION_DISTANCE_VALUE, + /** Compute the fusion distance by multiplying the screen distance by the fusion distance value.*/ + PROPORTIONAL_TO_SCREEN_DISTANCE + }; + + /** Set the FusionDistanceMode and Value. Note, is used only when working in stereo.*/ + void setFusionDistance(FusionDistanceMode mode,float value=1.0f); + + /** Get the FusionDistanceMode.*/ + 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; } /** set whether the draw method should call renderer->prioritizeTexture.*/ @@ -291,20 +310,23 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced osg::ref_ptr _rendergraphRight; osg::ref_ptr _renderStageRight; - osg::ref_ptr _frameStamp; + osg::ref_ptr _frameStamp; - osg::Vec4 _backgroundColor; + osg::Vec4 _backgroundColor; - CullVisitor::ComputeNearFarMode _computeNearFar; - osg::CullStack::CullingMode _cullingMode; - float _LODBias; - float _smallFeatureCullingPixelSize; + CullVisitor::ComputeNearFarMode _computeNearFar; + osg::CullStack::CullingMode _cullingMode; + float _LODBias; + float _smallFeatureCullingPixelSize; - osg::ref_ptr _viewport; + FusionDistanceMode _fusionDistanceMode; + float _fusionDistanceValue; - LightingMode _lightingMode; + osg::ref_ptr _viewport; + + LightingMode _lightingMode; - bool _prioritizeTextures; + bool _prioritizeTextures; }; diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 93e3fc217..b8cd246f3 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -27,6 +27,9 @@ SceneView::SceneView(DisplaySettings* ds) _LODBias = 1.0f; _smallFeatureCullingPixelSize = 3.0f; + _fusionDistanceMode = USE_CAMERA_FUSION_DISTANCE; + _fusionDistanceValue = 1.0f; + _lightingMode=HEADLIGHT; _prioritizeTextures = false; @@ -217,12 +220,22 @@ void SceneView::cull() { float fusionDistance = _displaySettings->getScreenDistance(); - - if (_camera.valid()) + switch(_fusionDistanceMode) { - fusionDistance = _camera->getFusionDistance(); + case(USE_CAMERA_FUSION_DISTANCE): + if (_camera.valid()) + { + fusionDistance = _camera->getFusionDistance(); + } + break; + case(USE_FUSION_DISTANCE_VALUE): + fusionDistance = _fusionDistanceValue; + break; + case(PROPORTIONAL_TO_SCREEN_DISTANCE): + fusionDistance *= _fusionDistanceValue; + break; } - + float iod = _displaySettings->getEyeSeparation(); float sd = _displaySettings->getScreenDistance(); float es = 0.5f*iod*(fusionDistance/sd);