<div dir="ltr">Hi,<div><br></div><div>maybe you try</div><div><br></div><div><span style="font-size:12.8px">myNode->getOrCreateStateSet()-</span><span style="font-size:12.8px">>setAttributeAndModes(mat, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);</span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 3:32 PM, Andre Sanchez <span dir="ltr"><<a href="mailto:aurumknight.ak@gmail.com" target="_blank">aurumknight.ak@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi OpenSceneGraph forum!<br>
<br>
I'm very new to OSG, and while I'm very familiar with programming, and somewhat familiar with 3D graphics, I am now devoting actual time working in a lab to properly learn C++, and OSG as well.<br>
<br>
My issue is as follows:<br>
I am loading an existing model as a Node, and I want to be able to change the color of the model in real time. How should I go about doing this?<br>
<br>
I know how attach an update callback to the Node, but it's the color that I can't seem to change. I am able to set the diffuse color on a primitive object using a material like so:<br>
<br>
<br>
Code:<br>
<br>
osg::ref_ptr<osg::Material> mat = new osg::Material;<br>
mat->setDiffuse (osg::Material::FRONT_AND_BACK, osg::Vec4(0.8, 0.1, 0.4, 1.0));<br>
myNode->getOrCreateStateSet()->setAttributeAndModes(mat, osg::StateAttribute::ON);<br>
<br>
<br>
<br>
<br>
but this doesn't seem to work on the model.<br>
<br>
I found that if I changed the model's .osg file to not define material colors on particular components of the model, then this color I defined for the model would affect those parts. However I feel there should be a better way to do this, as I will probably end up using models that actually need these colors within their respective .osg files. I know I can probably do this with a shader, and if that's necessary then fine, but if there's an easier way then that would be great.<br>
<br>
So essentially my question is:<br>
What is the easiest way to change the overall diffuse color of an object?<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=65321#65321" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=65321#65321</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">trajce nikolov nick<br></div>
</div>