Added s/getClearColor and deprecated s/getBackgroundColor(). Re-implemented
setClearColor so that it passes on its value to Camera::setClearColor(), and changed OsgSceneHandler to use the Camera::getClearColor() on each new frame to ensure that it reflects the settings of the camera correctly.
This commit is contained in:
@@ -105,11 +105,15 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
const osg::StateSet *getGlobalStateSet() const { return _global_stateset.get(); }
|
||||
|
||||
|
||||
void setBackgroundColor( const osg::Vec4& backgroundColor );
|
||||
#ifdef USE_DEPRECATED_API
|
||||
void setBackgroundColor( const osg::Vec4& backgroundColor) { setClearColor(backgroundColor); }
|
||||
|
||||
osg::Vec4& getBackgroundColor() { return _background_color; }
|
||||
const osg::Vec4& getBackgroundColor() const { return getClearColor(); }
|
||||
#endif
|
||||
|
||||
const osg::Vec4& getBackgroundColor() const { return _background_color; }
|
||||
void setClearColor( const osg::Vec4& clearColor );
|
||||
|
||||
const osg::Vec4& getClearColor() const;
|
||||
|
||||
|
||||
void setLODScale( float scale );
|
||||
@@ -184,7 +188,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
osg::ref_ptr<osg::Group> _scene_decorator;
|
||||
|
||||
osg::ref_ptr<osg::StateSet> _global_stateset;
|
||||
osg::Vec4 _background_color;
|
||||
osg::Vec4 _clear_color;
|
||||
float _LODScale;
|
||||
|
||||
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode;
|
||||
|
||||
@@ -212,7 +212,7 @@ void OsgCameraGroup::_init()
|
||||
|
||||
_scene_data = NULL;
|
||||
_global_stateset = NULL;
|
||||
_background_color.set( 0.2f, 0.2f, 0.4f, 1.0f );
|
||||
_clear_color.set( 0.2f, 0.2f, 0.4f, 1.0f );
|
||||
_LODScale = 1.0f;
|
||||
|
||||
_fusionDistanceMode = osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE;
|
||||
@@ -295,7 +295,6 @@ void OsgCameraGroup::setUpSceneViewsWithData()
|
||||
|
||||
sv->setFrameStamp( _frameStamp.get() );
|
||||
sv->setGlobalStateSet( _global_stateset.get() );
|
||||
sv->setClearColor( _background_color );
|
||||
sv->setLODScale( _LODScale );
|
||||
sv->setFusionDistance( _fusionDistanceMode, _fusionDistanceValue );
|
||||
}
|
||||
@@ -315,10 +314,19 @@ void OsgCameraGroup::setGlobalStateSet( osg::StateSet *sset )
|
||||
setUpSceneViewsWithData();
|
||||
}
|
||||
|
||||
void OsgCameraGroup::setBackgroundColor( const osg::Vec4& backgroundColor )
|
||||
void OsgCameraGroup::setClearColor( const osg::Vec4& clearColor )
|
||||
{
|
||||
_background_color = backgroundColor;
|
||||
setUpSceneViewsWithData();
|
||||
_clear_color = clearColor;
|
||||
for(unsigned int i=0;i<getNumberOfCameras();++i)
|
||||
{
|
||||
Producer::Camera *cam = _cfg->getCamera(i);
|
||||
cam->setClearColor(_clear_color[0],_clear_color[1],_clear_color[2],_clear_color[3]);
|
||||
}
|
||||
}
|
||||
|
||||
const osg::Vec4& OsgCameraGroup::getClearColor() const
|
||||
{
|
||||
return _clear_color;
|
||||
}
|
||||
|
||||
void OsgCameraGroup::setLODScale( float scale )
|
||||
@@ -424,6 +432,8 @@ bool OsgCameraGroup::realize()
|
||||
Producer::Camera *cam = _cfg->getCamera(i);
|
||||
Producer::RenderSurface* rs = cam->getRenderSurface();
|
||||
|
||||
cam->setClearColor(_clear_color[0],_clear_color[1],_clear_color[2],_clear_color[3]);
|
||||
|
||||
// create the scene handler.
|
||||
osgProducer::OsgSceneHandler *sh = new osgProducer::OsgSceneHandler(_ds.get());
|
||||
|
||||
|
||||
@@ -54,6 +54,10 @@ void OsgSceneHandler::cullImplementation(Producer::Camera &cam)
|
||||
|
||||
_sceneView->setViewport( x, y, w, h );
|
||||
|
||||
osg::Vec4 clear_color;
|
||||
cam.getClearColor(clear_color[0],clear_color[1],clear_color[2],clear_color[3]);
|
||||
_sceneView->setClearColor(clear_color);
|
||||
|
||||
_sceneView->cull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user