[osg-users] SetAttribute / RemoveAttribute Question

Hakan Gedek hgedek at gmail.com
Wed Nov 29 04:58:41 PST 2017


Hey,

question = you ve a tree of items which correspond to osg nodes ? and whenever you select any of them you wish to show "it selected " ???

If so :


Code:


const osg::Vec4 normalColor(1.0f, 1.0f, 1.0f, 1.0f);
const osg::Vec4 selectedColor(1.0f, 0.0f, 0.0f, 0.8f);

void setSelected(bool value)
{
	osg::ref_ptr<osg::Material> mat = new osg::Material;
	auto color = value ? selectedColor : normalColor;
	mat->setDiffuse(osg::Material::FRONT_AND_BACK, color);
	mModel->getOrCreateStateSet()->setAttributeAndModes(mat, osg::StateAttribute::ON);
	mModel->getOrCreateStateSet()->setAttributeAndModes(mat, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}





If its a wrong answer sorry - i didnt understand well !!![/code]

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







More information about the osg-users mailing list