From Farshid Lashkari, "I noticed some problems when setting up CameraNodes that inherit

viewport settings in stereo mode. It seems that the SceneView::cull()
method will pass the full size viewport to the left/right
cullvisitors, instead of the modified stereo viewport. I made quite a
few changes to SceneView to fix the issue. The SceneView::cullStage()
method will now receive the viewport as an argument, instead of using
the global viewport. The SceneView::cull() method will pass the
modifed viewport to cullStage when rendering in stereo.

There are 2 new private methods computeLeftEyeViewport() and
computeRightEyeViewport() that will compute the stereo viewports. I
also modified the draw() function so it applies the correct viewport
to the prerender stages. These changes are only necessary for
horizontal/vertical split stereo."
This commit is contained in:
Robert Osfield
2008-06-19 14:29:38 +00:00
parent c3c727b822
commit dd13893861
2 changed files with 137 additions and 61 deletions

View File

@@ -475,7 +475,10 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
virtual ~SceneView();
/** Do cull traversal of attached scene graph using Cull NodeVisitor. Return true if computeNearFar has been done during the cull traversal.*/
virtual bool cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::StateGraph* rendergraph, osgUtil::RenderStage* renderStage);
virtual bool cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::StateGraph* rendergraph, osgUtil::RenderStage* renderStage, osg::Viewport *viewport);
void computeLeftEyeViewport(const osg::Viewport *viewport);
void computeRightEyeViewport(const osg::Viewport *viewport);
const osg::Matrix computeMVPW() const;
@@ -496,10 +499,12 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorLeft;
osg::ref_ptr<osgUtil::StateGraph> _stateGraphLeft;
osg::ref_ptr<osgUtil::RenderStage> _renderStageLeft;
osg::ref_ptr<osg::Viewport> _viewportLeft;
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorRight;
osg::ref_ptr<osgUtil::StateGraph> _stateGraphRight;
osg::ref_ptr<osgUtil::RenderStage> _renderStageRight;
osg::ref_ptr<osg::Viewport> _viewportRight;
osg::ref_ptr<osg::CollectOccludersVisitor> _collectOccludersVisitor;