|
楼主 |
发表于 2014-8-30 10:27:33
|
显示全部楼层
本帖最后由 颂鼎 于 2014-8-30 10:30 编辑
下面实现哪里不对呀,咋没效果呢???
- osg::ref_ptr<osg::Geode> m_clipPlane = new osg::Geode;
- (主节点)m_Group->addChild(m_clipPlane);
- osg::ref_ptr<osg::Geometry> top_cap = new osg::Geometry;
- m_clipPlane->addDrawable(top_cap);
- top_cap->setVertexArray(pts);
-
- osg::Vec4Array* colors = new osg::Vec4Array;
- colors->push_back(osg::Vec4(1,0,0,1));
- top_cap->setColorArray(colors);
- top_cap->setColorBinding(osg::Geometry::BIND_OVERALL);
-
- top_cap->addPrimitiveSet( new osg::DrawArrays(
- osg::PrimitiveSet::LINE_LOOP,
- 0,pts->size()));
-
- osgUtil::Tessellator tess;
- tess.setTessellationType( osgUtil::Tessellator::TESS_TYPE_GEOMETRY );
- tess.setWindingType( osgUtil::Tessellator::TESS_WINDING_POSITIVE );
- tess.retessellatePolygons( *(top_cap.get()) );
-
- osg::Stencil* stencil = new osg::Stencil;
- stencil->setFunction(osg::Stencil::ALWAYS, 1, ~0u);
- stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::INCR);
- int ref = stencil->getFunctionRef();
- unsigned int mask = stencil->getFunctionMask();
- m_clipPlane->getOrCreateStateSet()->setAttributeAndModes(stencil, osg::StateAttribute::ON);
- m_clipPlane->getOrCreateStateSet()->setAttributeAndModes(new osg::Depth(osg::Depth::LESS, 0, 1, false), osg::StateAttribute::ON);
- m_clipPlane->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
- m_clipPlane->getOrCreateStateSet()->setAttributeAndModes(new osg::ColorMask(false, false, false, false));
- m_clipPlane->setCullingActive(false);
- m_clipPlane->getOrCreateStateSet()->setRenderBinDetails(-9, "RenderBin");
-
-
- osg::Geode* clearDepthNode = new osg::Geode;
- clearDepthNode->addDrawable(new osgAPEx::ClearDrawable(GL_DEPTH_BUFFER_BIT));
- clearDepthNode->getOrCreateStateSet()->setRenderBinDetails(-8, "RenderBin");
- (主节点)m_Group->addChild(clearDepthNode);
-
- stencil = new osg::Stencil;
- stencil->setFunction(osg::Stencil::NOTEQUAL, 1, 1);
- (地球节点)m_Earth->getOrCreateStateSet()->setAttributeAndModes(stencil, osg::StateAttribute::ON);
复制代码 |
|