Hey all,

I'd like to render osgText using a material instead of the default
osgText::setColor() method. This is because I instance the same text
geometry, but would like to paint it different colors without
duplicating anything. To do this, I add a material as an attribute to
the text node. The material has colorMode set to OFF. Setting the
diffuse color to my target color doesn't really work (alpha value
works, but colors dont), but setting the emission color works fine.
Why is this? Lighting is on.

osg::Material myMat = new osg::Material;
myMaterial->setColorMode(osg::Material::OFF);
myMaterial->setDiffuse(osg::Material::FRONT,osg::Vec4(1,0,0,1));
...
osgText::Text textChar = new osgText::Text;
textChar->getOrCreateStateSet()->setAttribute(myMaterial.get());   //
black text, but alpha value works

myMaterial->setEmission(osg::Material::FRONT,osg::Vec4(1,0,0,1));   //
red text, alpha works


Regards,

Preet
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to