On 8/25/06, Jeff Kershner <[EMAIL PROTECTED]> wrote:

Thanks…!

 

Does that traverse function take the geode passed in?


Yes.... uncompiled copy n paste example.

Now I am understanding what you guys mean by node visitors!  ;)

 


From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Don Burns
Sent: Friday, August 25, 2006 1:08 PM
To: osg users
Subject: Re: [osg-users] Getting geometry* from name

 

class FindNamedGeometryVisitor : public osg::NodeVisitor
{
    public:
        FindNamedNodeVisitor(std::string gName):
            osg::NodeVisitor(TRAVERSE_ALL_CHILDREN),
            _geometryName(gName) {}

        virtual void apply(osg::Geode& geode)
        {
            for( unsigned int i = 0; i < geode.getNumDrawables(); i++ )
            {
                osg::Geometry *geom = dynamic_cast<osg::Geometry *>(geode.getDrawable(i));
                if( geom && geom->getName() == gName )
                {
                    _foundGeometry = geom;
                    return;
                }
            }

            traverse(node);
        }

        osg::Node *getFoundGeometry()
        {
            return _foundGeometry.get();
        }

    private:
        std::string _geometryName;
        osg::ref_ptr<osg::Geometry> _foundGeometry;
};


main()
{
         .....

    FindNamedGeometryVisitor fngv;
    rootNode->accept( fngv );

    osg::ref_ptr<osg::Geometry> foundGeometry = fngv.getFoundGeometry();
    if( foundGeometry.valid() )
        go_nuts();
}

 

On 8/25/06, Jeff Kershner <[EMAIL PROTECTED]> wrote:

How can I get an osg::Geometry* by name from an osg::Node*?  I don't see any recursive search functions in osg::Node….

 

Thanks,

/jk


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

 


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to