You will need to write a node visitor to traverse your scene graph
osgDB::readNodeFile("file.osg"); will typically return a osg::Group
( see examples on node visitors )


This has been discussed several times in the last 2-3 months on this list (
with example code I believe ), 

a search of the email archives should find this


____________________________________________________________________________
__
Gordon Tomlinson 

[email protected] IM: [email protected] 
www.vis-sim.com        www.gordontomlinson.com 
____________________________________________________________________________
__

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Simon
Hammett
Sent: Saturday, January 03, 2009 12:40 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Node Names After Picking

2009/1/3 Simon Hammett <[email protected]>:
> 2009/1/2 Ryan Morris <[email protected]>:
>> Just to be clear, would something like:
>>
>> osg::Node *node = osgDB::readNodeFile("file.osg");
>> osg::Geode *geode = osg::dynamic_cast<osg::Geode>node;
>>
>> geode->getDrawable()->setName("New name");
>>
>> should work? (syntax might be a little off I'm not at my home system
right now).
>>
>
> Well it will work if the root of the scene is a geode,
> which is extremely unlikely for any non-trivial scene graph.
>
> It's much more likely that the root will be a class which derives
> from osg::Group
>

Doh. Should be:

geode->getDrawable( 0 )->setName("New name");

Or better yet:

for(unsigned i = 0, iC = geode->getNumDrawables(); i != iC; ++i )
    geode->getDrawable( i )->setName( GenerateName( i ) );

-- 
The truth is out there. Usually in header files.
_______________________________________________
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