[osg-users] Clip plane with osg::ClipNode

Robert Osfield robert.osfield at gmail.com
Thu Oct 24 01:09:24 PDT 2019


HI Catalin,

OpenGL clip planes are positional state which requires them to be applied
with the current modelview matrix to position them in in eye coordinates
where the clipping is done on the GPU.  This positioning means that each
individual OpenGL clip plan can only be in one place at one time, which in
turn means that when the OSG applies the clipplane only the last one
applied will be the one that is effective.

Robert.

On Wed, 23 Oct 2019 at 11:48, Catalin <inbox.icf at gmail.com> wrote:

> Hi,
>
> I have an issue with clipping planes, if you set 2 different clipping
> planes to 2 different objects, only the last clipping plane is used. I was
> expecting each object to be drawn with its clipping plane.
>
> osg::ref_ptr<osg::ClipNode> clipNode1 = new osg::ClipNode;
> clipNode1->addClipPlane(new osg::ClipPlane(0));
> clipNode1->getClipPlane(0)->setClipPlane(1.0, 0.0, 0.0, -2000.0);
>
> osg::ref_ptr<osg::ClipNode> clipNode2 = new osg::ClipNode;
> clipNode2->addClipPlane(new osg::ClipPlane(0));
> clipNode2->getClipPlane(0)->setClipPlane(-1.0, 0.0, 0.0, -2000.0);
>
> osg::ShapeDrawable* s1 = new osg::ShapeDrawable(new
> osg::Box(osg::Vec3(2000, 0, 0), 500));
> clipNode1->addChild(s1);
> osg::ShapeDrawable* s2 = new osg::ShapeDrawable(new
> osg::Box(osg::Vec3(-2000, 0, 0), 500));
> clipNode2->addChild(s2);
>
> Every box is shown in half because of the clipping plane.
>
> *Case 1*
> root->addChild(clipNode1);
> //root->addChild(clipNode2);
>
> [image: image.png]
>
> *Case 2*
> //root->addChild(clipNode1);
> root->addChild(clipNode2);
>
> [image: image.png]
>
> *Case 3*
> root->addChild(clipNode1);
> root->addChild(clipNode2);
>
> [image: image.png]
>
> I was expecting both boxes, S1 and S2 to be drawn.
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191024/ccc623d1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4525 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191024/ccc623d1/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4683 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191024/ccc623d1/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 5114 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191024/ccc623d1/attachment-0002.png>


More information about the osg-users mailing list