Hi Andrea, Positional state like clip planes are handled in a special way by the OSG as they have to be assigned a particular modelview matrix to position them correctly, and this means that you can't arbitarily state sort them and have any modelview matrix current when they are applied. The solves this problem by using a positional state node, and in the case of clip planes its the osg::ClipNode. The OSG also limits the setting of cliplanes so that a one clip plane can only be in one place at one time, and in OpenGL terms this means clip plane 0 can only be set once per rendering stage. OpenGL supports multiple clip planes, 6 being the minimum that OpenGL drivers have to support, so the OSG allows also allows you to assign each one of these clip planes at the same time - you just can't reuse the same GL clip plane index more than once.
In you case it sounds like you are using multiple clip nodes and multiple clip planes which is perfectly safe usage, but the mistake is in not assigning a different clip plane number to each of the clip planes so they don't overlap in usage. Another important thing is that the ClipNode positions the (gl/osg::)ClipPlane while you'll need enable the appropropriate GL_CLIPPLANEi mode on the subgraphs that you want the clip plane to take effect. Robert. On Tue, Mar 1, 2011 at 6:30 PM, Andrea Martini <[email protected]> wrote: > Hi, > > i would like to use more than one clipnode in my application. I use two > different clipnode in the scene, each relating to a different 3D object such > as a cube and a cylinder. I created the first clipnode (CN_A) and I've > associated with the tree of the cylinder, and the other clipnode (CN_B) the > structure of the cube. Then I created a plane and a clipplane for each > clipnode like this : > > ... > // cylinder : > > osg::ClipNode* cnCylinder=new osg::ClipNode(); > > cnCylinder->addChild(cylinderModel); > > groupCylynder->addChild(cnCylinder); > > clipPlaneForCylinder=new osg::ClipPlane(); > > planeForCylinder=new osg::Plane(NormalCylinder,CenterCylinder); > > clipPlaneForCylinder->setClipPlane(planeForCylinder); > > cnCylinder->addClipPlane(clipPlaneForCylinder); > > cnCylinder->setCullingActive(false); > > ..... > > // ... cube > > osg::ClipNode* cnCube=new osg::ClipNode(); > > cnCube->addChild(cubeModel); > > groupCube->addChild(cnCube); > > clipPlaneForCube=new osg::ClipPlane(); > > planeForCube=new osg::Plane(NormalCube,CenterCube); > > clipPlaneForCube->setClipPlane(planeForCube); > > cnCube->addClipPlane(clipPlaneForCube); > > cnCube->setCullingActive(false); > > My application allows me to move each plane (in a separate way) in order to > see how 3D model is "cutted". BUT .... > If i work with only one model and clipnode, it works correctly. > If i use two models and two clipnodes i see only one cut effect on a 3D model > and the other 3D model completely disappears. > I.e. : If i apply clipnodes simultaneosly on CUBE and CYLINDER, i see the > CUBE cutted and don't see CYLINDER. When i disable clipnode on CUBE, suddenly > i see again the CUBE with the CUT effect. Again, if i apply clipnode on > CYLINDER, i don't see anything. > > So , my question is : Is it possible to use more than one clipnode? > > > Thank you! > > Cheers, > Andrea > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=37226#37226 > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

