You can use osgFX node kit framework to implement described capping tehnique. You do that by inheriting osgFX::Effect class. In your derived class you have to override/implement virtual bool define_techniques() member of the osgFX::Effect class like this:
bool CappingEffect::define_techniques()
{
CappingTechnique* technique = new CappingTechnique(this);
addTechnique(technique);
return true;
}
CappingTechnique must inherit from osgFX::Technique. In the derived class you
will have to implement virtual bool validate(osg::State&) const, virtual void
define_passes() and optionally virtual osg::Node* getOverrideChild(int pass)
like this:
bool CappingTechnique::validate(osg::State&) const
{
return true;
}
bool CappingTechnique:: define_passes()
{
// pass #1
{
osg::ref_ptr<osg::StateSet> ss = new osg::StateSet;
... setup states for stencil operation
addPass(ss.get());
}
// implement pass #2
{
osg::ref_ptr<osg::StateSet> ss = new osg::StateSet;
... setup states for solid color draw
addPass(ss.get());
}
}
You can optionally implement getOverrideChild (int pass) to supply some other
graph for a particlular pass. You then add your group to the CappingEffect (the
osgFX::Effect inherits from osg::Group node) and CappingEffect to the camera.
Robert Milharcic
From: [email protected]
[mailto:[email protected]] On Behalf Of Javier Taibo
Sent: Thursday, September 02, 2010 1:09 PM
To: [email protected]
Subject: [osg-users] draw callbacks
Hi,
I have some solid geometry clipped by some clipping planes in an OSG
application. I am trying to use the capping technique described in chapter 10
of the Red Book using the stencil buffer. I have successfully implemented this
technique in raw OpenGL, but I would like to use it whithin the OSG
application. The technique is based on storing on the stencil buffer the
regions that are "open" and then in a later pass draw a solid color in these
regions.
I have put the clipped geometry under an osg::Camera node with the stencil
function configured. To do the second pass (the one that draws the caps in the
regions marked in the stencil), I am trying to use a post-draw callback with
the OpenGL calls (saving and restoring the states to avoid breaking things).
The problem is that I need to set the NESTED rendering order to see all the
scene graph, and when I do it, the post-draw callback is not called anymore.
I do not have full control over the application, so the solution I am looking
for has to be "transparent" to the rest of the scene graph. I must activate
this behaviour to a group in the scene graph without breaking anything outside
this branch. What is the best way to do it? camera post-draw callbacks?
rendering bins? any other?
I am not very familiar with render passes in OSG, so the way I am trying is
probably not the best way. I would appreciate any suggestion, advice or pointer
to any related documentation or source code.
Thanks in advance.
Javier Taibo.
<<attachment: Robert Milharcic.vcf>>
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

