I'm kind of talking to myself here... and since 2010 there is no sign of Art
Tevs... anybody saw him lately?
Well, if anybody cares, I found out a solution to have multiple processors with
compositeviewer, each view can have its different osgPPU pipeline, etc.
1. All you need to add is a group node to your scene, that holds all the
processors.
2. then you need to add this little snippet of code to Processor.cpp in the
traverse method:
Code:
void Processor::traverse(osg::NodeVisitor& nv)
{
if (!mCamera)
return;
// if not initialized before, then do it
if (mbDirty) init();
// if subgraph is dirty, then we have to resetup it
// we do this on the first visitor which runs over the pipeline because
this also removes cycles
if (mbDirtyUnitGraph)
{
mbDirtyUnitGraph = false;
// first resolve all cycles in the set
ResolveUnitsCyclesVisitor rv;
rv.run(this);
// mark every unit as dirty, so that they get updated on the next call
MarkUnitsDirtyVisitor nv;
nv.run(this);
// debug information
osg::notify(osg::INFO) <<
"" <<
std::endl;
osg::notify(osg::INFO) << "BEGIN " << getName() << std::endl;
SetupUnitRenderingVisitor sv(this);
sv.run(this);
osg::notify(osg::INFO) << "END " << getName() << std::endl;
osg::notify(osg::INFO) <<
"" <<
std::endl;
// optimize subgraph
OptimizeUnitsVisitor ov;
ov.run(this);
}
[b]// make sure we render only our own camera
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
osgUtil::CullVisitor* cv = dynamic_cast(&nv);
if (cv)
{
if (cv->getCurrentCamera() != getCamera())
{
return;
}
}
}
[/b]
// first we need to clear traversion bit of every unit
if (nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
{
CleanUpdateTraversedVisitor::sVisitor->run(this);
}
// if processor is propagated by a cull visitor, hence first clean the
traverse bit
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
osg::notify(osg::DEBUG_INFO) <<
"" <<
std::endl;
osg::notify(osg::DEBUG_INFO) << "BEGIN FRAME " << getName() <<
std::endl;
CleanCullTraversedVisitor::sVisitor->run(this);
}
if (mbDirtyUnitGraph == false || nv.getVisitorType() ==
osg::NodeVisitor::NODE_VISITOR)
{
osg::Group::traverse(nv);
}
// check if we have units that want to be executed last, then do so
if (mbDirtyUnitGraph == false && nv.getVisitorType() ==
osg::NodeVisitor::CULL_VISITOR)
{
for (std::list::iterator it = mLastUnits.begin(); it !=
mLastUnits.end(); it++)
{
placeUnitAsLast(*it, false);
(*it)->accept(nv);
placeUnitAsLast(*it, true);
}
mLastUnits.clear();
}
}
3. You need to make sure your camera viewport of each view is set to an origin
of 0/0. Control the position of the rendering viewport by setting the UnitOut
viewport to the desired origin.
This is due to a limitation of osgPPU, which copies to and from the render
target always relative to a 0/0 origin.
Now Enjoy osgPPU and compositeViewer!
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=51363#51363
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org