Hi,
I have a model created by 3dmax.The model contains many objects which already 
have color or textures.I want to change the color of the model. 
I have tried the method to change the material,but it dosen't work well.My code 
is:

Code:

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(1.0,0.0,0.0,1));   
material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,0.0,0.0,1));   
material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,0.0,0.0,1));  
material->setEmission(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,0.0,0.0,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);



Oringinal model:
[img]
http://photo.163.com/d3d3d353/big/#aid=215946288&id=6638799033
[/img]
result:
[img]
http://photo.163.com/d3d3d353/big/#aid=215817442&id=6638797425
[/img]
As you can see from the picture,the color of the model is not uniformly 
red(osg::Vec4(1.0,0.0,0.0,1)),and also the alpha channel of some part of the 
model don't change to 0.5(when I get a screenshot to read the alpha 
channel).How can I deal with that?

Thank you!

Cheers,
Duan

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=34955#34955





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to