|
本帖最后由 garyliyong 于 2012-5-21 22:35 编辑
以前也遇到过类似的问题,一直没解决。现在时间越来越紧了,望大侠们帮忙呀!先看下现象
左边的球有斑纹现象,右边的圆柱颜色深浅会不一样
,左边的球有斑纹,右边的圆柱颜色深浅不一样。代码如下:
- #include <osgViewer/Viewer>
- #include <osg/Group>
- #include <osg/ShapeDrawable>
- #include <osgViewer/ViewerEventHandlers>
- osg::Geode* CreateTransGeode()
- {
- osg::ref_ptr<osg::Sphere> pSphere = new osg::Sphere();
- osg::ref_ptr<osg::ShapeDrawable> pSdSphere = new osg::ShapeDrawable(pSphere);
- pSdSphere->setColor(osg::Vec4(1.0,0.0,0.0,0.5));
- osg::ref_ptr<osg::Cylinder> pCy = new osg::Cylinder(osg::Vec3(0,5,0),1,2);
- osg::ref_ptr<osg::ShapeDrawable> pSdCy = new osg::ShapeDrawable(pCy);
- pSdCy->setColor(osg::Vec4(0.0,1.0,0.0,0.5));
- osg::ref_ptr<osg::Geode> pGeode = new osg::Geode;
- pGeode->addDrawable(pSdSphere);
- pGeode->addDrawable(pSdCy);
- pGeode->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
- pGeode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
- return pGeode.release();
- }
- int main()
- {
- osg::ref_ptr<osgViewer::Viewer> pView = new osgViewer::Viewer;
- osg::ref_ptr<osg::Group> pGroup = new osg::Group;
- pGroup->addChild(CreateTransGeode());
- pView->setSceneData(pGroup.get());
- pView->addEventHandler(new osgViewer::WindowSizeHandler);
- pView->run();
- return 0;
- }
复制代码 |
|