|
楼主 |
发表于 2009-5-26 16:10:04
|
显示全部楼层
设置材质的代码如下
osg::BlendFunc *blendFunc = new osg::BlendFunc();
osg::BlendColor *blendColor= new osg::BlendColor(color);
blendFunc->setSource(osg::BlendFunc::CONSTANT_ALPHA);
blendFunc->setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);
osg::StateSet* ss = wave->getOrCreateStateSet();
ss->setAttributeAndModes(blendFunc,osg::StateAttribute::ON);
ss->setAttributeAndModes(blendColor,osg::StateAttribute::ON);
osg::Material* mat = new osg::Material;
mat->setAmbient(osg::Material::FRONT,color/2.0);
mat->setDiffuse(osg::Material::FRONT,color);
mat->setSpecular(osg::Material::FRONT,osg::Vec4(1.0,1.0,1,1));
ss->setAttribute(mat); |
|