设置颜色数组
前3 个参数设置颜色,第四个参数为透明度,0-1透明度越来越小。
设置geode的属性:
GL_BLEND:混合渲染,把同一位置的前一个像素和后一个像素进行叠加后显示.所以透明渲染会影响渲染速度
osg::ref_ptr<osg::Geode> cubeGeode=new osg::Geode();
osg::ref_ptr<osg::Geometry>geom=new osg::Geometry;
osg::ref_ptr<osg::Vec4dArray>colors=new osg::Vec4dArray;
colors->push_back(osg::Vec4d(1.0f,1.0f,1.0f,0.25f));
geom->setColorArray(colors);
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
cubeGeode->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
cubeGeode->addDrawable(geom);