|
如何改变模型材质?我的代码如下但效果不正确
osg::ref_ptr<osg::StateSet>stateset=new osg::StateSet();
stateset=model1->getOrCreateStateSet();
stateset->setMode(GL_BLEND,osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE);
osg::ref_ptr<osg::Material>material=new osg::Material();
material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(0.03,0.03,0.01,1));
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(0.03,0.03,0.01,1));
material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(0.03,0.03,0.01,1));
material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(0.03,0.03,0.01,1));
material->setShininess(osg::Material::FRONT_AND_BACK,0);
material->setTransparency(osg::Material::FRONT_AND_BACK,0.5);
material->setAlpha(osg::Material::FRONT_AND_BACK,0.5);
stateset->setAttribute(material.get(),osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE);
效果图:
模型是3dmax做的茶壶,可以看到rgba值不是我想要的0.03,0.03,0.01,0.5这为什么?该怎么做?
谢谢! |
-
|