<div dir="ltr">Hi Clement+Tony,<br><div><div class="gmail_extra"><br><div class="gmail_quote">On 26 March 2016 at 02:16, Tony Vasile <span dir="ltr"><<a href="mailto:minghia@gmail.com" target="_blank">minghia@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Clement,<br>
This is rather easy to do. All you need is to define a NodeVisitor and run it on the group. Using this way you only need to have an accept call for the Geode and process the drawables under the Geode.<br>
<br>
Code:<br>
<br>
class InfoVisitor : public osg::NodeVisitor<br>
{<br>
public:<br>
InfoVisitor()<br>
{<br>
setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN );<br>
}<br>
<br>
void apply( osg::Geode& geode )<br>
{<br>
for ( unsigned int i=0; i<geode.getNumDrawables(); ++i )<br>
{<br>
// Do what you have to do, for example store in a data structure<br>
}<br>
}<br>
};<br></blockquote><div><br><br></div><div>In OSG-3.4 onwards osg::Drawable subclasses from osg::Node (this also means osg::Geometry is a Node as it subclasses from Drawable) so can now be used directly in NodeVisitor so you can implement:<br><br>class InfoVisitor : public osg::NodeVisitor<br>
{<br>
public:<br>
InfoVisitor() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ) {}<br><br> void apply( osg::Geometry& geometry )<br>
{<br> // Do what you have to do, for example store in a data structure<br> }<br>
};<br><br></div><div>As Drawable/Geometry is a Node you don't actually required osg::Geode so the above revision will handle new and old style subgraphs.<br><br></div><div>Robert.<br></div><div> </div></div></div></div></div>