Hi Eric, 

To answer the last question first: if your new local scenegraph isn't attached 
to the scene that the viewer has, you can safely do whatever you want to it - 
that memory isn't being accessed by the viewer, since the viewer doesn't even 
know it exists.

As for the rest, it depends a bit on how you are setting up your application 
and scene.  How are you deciding where in the viewer's scene to add this new 
subgraph?  If you know where it will be (e.g. you have a pointer to the group 
to which you wish to add your new subgraph, either predefined or by picking), 
it would be pretty straightforward to add the new subgraph - 
dynamic_cast<osg::Group*>(yourPtr)->addChild(newRoot) would work.  You just 
need to make sure your viewer isn't accessing the scenegraph at the time.  What 
I do is have a custom viewer loop like so:


Code:
while(!viewer.done())
{
viewer.frame();
if(modificationIsNecessary)
{
viewer.stopThreading();
//modify the scene graph tree
//groupThatGetsNewScene->addChild(newSceneRoot);
viewer.startThreading();
}
}




I've been running something along these lines without problems - whether it's 
the *right* way to do it, I don't know.  If your viewer is running in single 
threaded mode already, just being between frame()s is enough, and the 
stopThreading/startThreading isn't doing anything.  If you want to have an 
update callback in the existing viewer scene, that could probably work too - in 
that case I'd think you would want to make sure the parent node data variance 
is set to dynamic to be safe.  It looks like you have a good idea of how you'd 
go about making that updateCallback already.

Cheers,
Tom[/code]

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





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

Reply via email to