Added support for seperate traversal masks for standard, left and right
cull traversals. This allows one to create seperate rendering for left and right eyes when doing stereo.
This commit is contained in:
@@ -140,6 +140,17 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
void setLODBias(float bias) { _lodBias = bias; }
|
||||
float getLODBias() const { return _lodBias; }
|
||||
|
||||
|
||||
void setCullMask(const osg::Node::NodeMask nm) { _cullMask = nm; }
|
||||
const osg::Node::NodeMask getCullMask() const { return _cullMask; }
|
||||
|
||||
void setCullMaskLeft(const osg::Node::NodeMask nm) { _cullMaskLeft = nm; }
|
||||
const osg::Node::NodeMask getCullMaskLeft() const { return _cullMaskLeft; }
|
||||
|
||||
void setCullMaskRight(const osg::Node::NodeMask nm) { _cullMaskRight = nm; }
|
||||
const osg::Node::NodeMask getCullMaskRight() const { return _cullMaskRight; }
|
||||
|
||||
|
||||
/** Set to true if you want SceneView to automatically calculate values
|
||||
for the near/far clipping planes, each frame, set false to use camera's
|
||||
internal near and far planes. Default value is true.
|
||||
@@ -228,15 +239,18 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
|
||||
bool _initCalled;
|
||||
osg::ref_ptr<osg::NodeVisitor> _initVisitor;
|
||||
osg::ref_ptr<osg::NodeVisitor> _appVisitor;
|
||||
osg::Node::NodeMask _cullMask;
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;
|
||||
osg::ref_ptr<osgUtil::RenderStage> _renderStage;
|
||||
|
||||
osg::Node::NodeMask _cullMaskLeft;
|
||||
osg::ref_ptr<osg::Camera> _cameraLeft;
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorLeft;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphLeft;
|
||||
osg::ref_ptr<osgUtil::RenderStage> _renderStageLeft;
|
||||
|
||||
osg::Node::NodeMask _cullMaskRight;
|
||||
osg::ref_ptr<osg::Camera> _cameraRight;
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorRight;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphRight;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/ColorMatrix>
|
||||
#include <osg/LightModel>
|
||||
|
||||
#include <osg/GLU>
|
||||
|
||||
@@ -34,6 +35,10 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
|
||||
_initCalled = false;
|
||||
|
||||
_cullMask = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +102,15 @@ void SceneView::setDefaults()
|
||||
texenv->setMode(osg::TexEnv::MODULATE);
|
||||
_globalState->setAttributeAndModes(texenv, osg::StateAttribute::ON);
|
||||
|
||||
osg::LightModel* lightmodel = new osg::LightModel;
|
||||
lightmodel->setAmbientIntensity(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
|
||||
_globalState->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
|
||||
|
||||
_backgroundColor.set(0.2f, 0.2f, 0.4f, 1.0f);
|
||||
|
||||
_cullMask = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
}
|
||||
|
||||
void SceneView::init()
|
||||
@@ -166,13 +178,16 @@ void SceneView::cull()
|
||||
if (!_rendergraphRight.valid()) _rendergraphRight = dynamic_cast<RenderGraph*>(_rendergraph->cloneType());
|
||||
if (!_renderStageRight.valid()) _renderStageRight = dynamic_cast<RenderStage*>(_renderStage->cloneType());
|
||||
|
||||
_cullVisitorLeft->setTraversalMask(_cullMaskLeft);
|
||||
cullStage(_cameraLeft.get(),_cullVisitorLeft.get(),_rendergraphLeft.get(),_renderStageLeft.get());
|
||||
|
||||
_cullVisitorRight->setTraversalMask(_cullMaskRight);
|
||||
cullStage(_cameraRight.get(),_cullVisitorRight.get(),_rendergraphRight.get(),_renderStageRight.get());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_cullVisitor->setTraversalMask(_cullMask);
|
||||
cullStage(_camera.get(),_cullVisitor.get(),_rendergraph.get(),_renderStage.get());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user