Hi Antoine,
Hello all

I have a mesh (a osg::Geometry) which I would like to change color depending on 
the mode it s in:

         osg::Geometry all white by default

         osg::Geometry all blue when selected



In order to achieve this I thought of using the BIND_OVERALL mode with 2 
Vec3Arrays (one array for the white color and the other one for the blue color) 
and simply swapping arrays to change the color (with 
osg::Geometry::setColorArray()), and calling dirtyDisplayList() to update.

Don't use display lists if you're planning on updating geometry on a regular base (since rebuilding a display list can be a rather costly operation). Use vertex buffer objects instead. In case you're modifying the complete geometry but no individual faces, you might consider using osg::Material or if you're using shaders anyways, simply set a uniform describing your color and specify it in the geometries state set.




Is this the most efficient way of changing the osg::Geometry color?
Depends ;-)

There usually isn't one most efficient way. In your case, swapping might be efficient, but you simply need to benchmark and decide for yourself which fits the bill.

Cheers
Sebastian

Thanks a lot,

Antoine[/list][/list]

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





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

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

Reply via email to