I am trying to write a NodeVisitor class that does something to
osgTerrain::TerrainTile nodes, but for some reason it never enters my
apply(TerrainTile& tile) function. It just seems to fall back into the
apply(Group& group) of the base NodeVisitor class. Finally I just gave
up and overrided the apply(Group& group) and attempted to dynamic cast
each group to a TerrainTile and then called my apply(TerrainTile&)
function and that worked, but it doesn't seem like the proper way to do
it.

What am I doing wrong? Here is my code (in short):

class TerrainTileVisitor : public osg::NodeVisitor
{
public:    
    TerrainTileVisitor() :
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
    {
    }

    virtual void apply(osgTerrain::TerrainTile& tile)
    {
        std::cout << "TerrainTile Found!" << std::endl;
      traverse(tile);
    }

//Added this function to make it work
    virtual void apply(osg::Group& group)
    {
        osgTerrain::TerrainTile* tile =
dynamic_cast<osgTerrain::TerrainTile*>(&group);
        if(tile)
            apply(*tile);
        else
            traverse(group);
    }
};

Thanks.

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

Reply via email to