[osg-users] Culling with custom clip planes

Jannik Heller scrawl at baseoftrash.de
Sat Oct 24 14:50:58 PDT 2015


Ok, setting on projectionCullingStack works fine for the whole subgraph, you just have to transform the plane to view space first:


Code:

    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
    {
        osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
        if (cv)
        {
            osg::CullingSet& cullingStack = cv->getProjectionCullingStack().back();

            osg::Polytope::PlaneList origPlaneList = cullingStack.getFrustum().getPlaneList();

            osg::Plane transformed = mCullPlane;
            transformed.transform(cv->getCurrentCamera()->getViewMatrix());

            cullingStack.getFrustum().add(transformed);

            traverse(node, nv);

            // undo
            cullingStack.getFrustum().set(origPlaneList);
        }
        else
            traverse(node, nv);
    }



It's a bit ugly, but good enough for me. Unless Robert has a better idea, I'll stick with this approach!

Cheers,
Jannik[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65434#65434








More information about the osg-users mailing list