So I think Robert is saying that you should keep two different
osg::Vec4Array*'s around, one containing the normal color, and the
other containing the selected color. Furthermore, I think the
SecondaryColor API you are looking at doesn't do what you think it
does. I only encountered this API myself recently and thought about
doing something like you are describing. But random web searchs seem
to imply that this is some later OpenGL extension that helps you
control Specular highlight color independently so it can be applied
independently/after texturing to give more realistic results.
So instead, you might try something like this (untested):
osg::Geometry* your_geometry = GetMyGeometry();
// use BIND_PER_VERTEX if you specify every vertex color or BIND_OVERALL
// if you only have one vertex color
// If using PER_VERTEX, make sure the number of vertices matches the number
// in your geometry
your_geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
osg::Vec4Array* normal_color = new osgVec4Array;
normal_color->push_back(osg::Vec4(1.0, 1.0, 1.0, 1.0));
normal_color->push_back(osg::Vec4(1.0, 0.0, 0.0, 1.0));
normal_color->push_back(osg::Vec4(0.0, 0.0, 1.0, 1.0));
osg::Vec4Array* selected_color = new osgVec4Array;
selected_color->push_back(osg::Vec4(1.0, 1.0, 0.0, 1.0));
selected_color->push_back(osg::Vec4(0.0, 1.0, 0.0, 1.0));
selected_color->push_back(osg::Vec4(0.0, 0.0, 0.0, 1.0));
if(IsSelected())
{
your_geometry->setColorArray(selected_color);
your_geometry->dirtyDisplayList();
}
else
{
your_geometry->setColorArray(normal_color);
your_geometry->dirtyDisplayList();
}
-Eric
From: "Antoine Rennuit" <[EMAIL PROTECTED]>
Subject: RE: [osg-users] Secondary array
To: "'osg users'" <[email protected]>
Message-ID: <[EMAIL PROTECTED]> (added by
[EMAIL PROTECTED])
Content-Type: text/plain; charset="iso-8859-1"
Hi Robert,
What I understood from your mail, is if I want to have one color for a
standard mode and one color for a selected mode, I have to put 2 colors in
the colorArray - the standard one being set by default thanks to one call to
setColorIndices and BIND_OVERALL. And when I want to change the color I need
to change the indice previously set by setColorIndices to the one
corresponding to the new color. I don't manage to change this indice, I can
reach the colorIndices array with
<geode>->getDrawable(0)->asGeometry()->getColorIndices(), but how to access
the records in the array?
I am sorry to ask for a question which even seems stupid to me, but there we
are, I am stuck...
Thanks,
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/