Hi Fred and Jefferson,

On Thu, Dec 18, 2008 at 8:39 AM,  <fredlis...@free.fr> wrote:
> Unfortunately, it doesn't seem to work ( at least for me ). I modified the 
> osgprecipitation example to add a simple clip plane, and although the model 
> is clipped, the rain continues to appear in the half space clipped.
>
> Attached the modified example.

I tested the modified example and it didn't function for a number of reasons..

First up the clipping plane has to be placed in eye coordinates and
osg::ClipNode didn't provide an option for placing it in an absolute
reference frame (an absolute/identity view matrix puts you in eye
coords) so I went ahead an added this to osg::ClipNode, so there now
is a ClipNode::setReferenceFrame(RefernceFrame) method along the same
lines as the same method in osg::LightSource, osg::TexGenNode and
osg::Camera (all instance have the same menaning.)

The next problem was that ClipNode was decorating the whole scene, not
just the precipitation effect so I restructed the example.  So it now
looks like (note the setReferenceFrame and CliPlane in eye coords) :

    osg::ref_ptr<osg::Group> group = new osg::Group;

    if (clipDistance!=0.0)
    {
        osg::ref_ptr<osg::ClipNode> clipNode = new osg::ClipNode;
        clipNode->addClipPlane( new osg::ClipPlane( 0 ) );
        clipNode->getClipPlane(0)->setClipPlane( 0.0, 0.0, -1.0,
-clipDistance );
        clipNode->setReferenceFrame(osg::ClipNode::ABSOLUTE_RF);
        clipNode->addChild(precipitationEffect.get());

        group->addChild(clipNode.get());
    }
    else
    {
        group->addChild(precipitationEffect.get());
    }

    group->addChild(loadedModel.get());

The osgprecitpitation example also now has a --clip distance command
line option to allow us to enable the above optional code path.  Try
values like 10 or 20 when loading the standard test example lz.osg.

Once this was all in place the precipitation effect still wasn't being
clipped, so I investigated user defined clipping plane and GLSL and
found that we need to explicitly set the gl_ClipVertex variable the
vertex shader.  Adding this fixed the clipping problem and hey presto
we can clip the precipitation effect and not the scene.

All these changes are now checked into svn/trunk and will be part of
the up coming 2.7.8 dev release.

Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to