It's bad if you add/remove objects in an upper part of you graph (like a
child removing from the graph its parent). But there is no problem for a
parent to remove their children if needed.

2009/5/5 Björn Blissing <[email protected]>

>  No.. When I searched the mail archive I found the previously linked
> message. It stated:
> "It's a bad thing to add/remove items to the scene graph inside an update
> callback.  Apparently, it invalidates the iterators."
>
> It was that message that prompted my initial question.
>
> /Björn
>
>  ------------------------------
>  *Från:* [email protected] [mailto:
> [email protected]] *För *Serge Lages
> *Skickat:* den 5 maj 2009 13:49
>
> *Till:* OpenSceneGraph Users
> *Ämne:* Re: [osg-users] Adding and removing objects
> toscenegraphduringruntime?
>
>  Hi,
>
> Did you try to just add an UpdateCallback to your root node for example who
> makes the job to add or remove nodes ?
>
> 2009/5/5 Björn Blissing <[email protected]>
>
>>  Well that will of course be diffrent depending on if I use Viewer or
>> CompositeViewer.
>>
>> Never the less, I still think it is strange that I would be forced to
>> tear down the Viewer.run() functionallity into pieces just to add and remove
>> objects to the scenegraph during runtime. Which (at least to me) would be a
>> pretty trivial feature. But apparently not?
>>
>> /Björn
>>
>>  ------------------------------
>>  *Från:* [email protected] [mailto:
>> [email protected]] *För *Vincent Bourdier
>> *Skickat:* den 5 maj 2009 13:25
>>
>> *Till:* OpenSceneGraph Users
>> *Ämne:* Re: [osg-users] Adding and removing objects to
>> scenegraphduringruntime?
>>
>>   You can just call frame() in the while loop (if I'm right).
>> See what the viewer.run() do, you'll have a good overview of what to use
>> or not.
>>
>> Vincent.
>>
>> 2009/5/5 Björn Blissing <[email protected]>
>>
>>>  The viewer.sync() and viewer.update() seems to be deprecated. And it
>>> seems a bit odd (at least for me) to just throw away the functionallity
>>> contained in viewer.run().
>>>
>>> I have searched the mail archive but I still can't find any information
>>> how to properly add and remove content to the scenegraph during runtime,
>>> whilst still using the viewer.run() method.
>>>
>>> /Björn
>>>
>>>  ------------------------------
>>> *Från:* [email protected] [mailto:
>>> [email protected]] *För *Vincent Bourdier
>>> *Skickat:* den 5 maj 2009 11:32
>>> *Till:* OpenSceneGraph Users
>>> *Ämne:* Re: [osg-users] Adding and removing objects to scenegraph
>>> duringruntime?
>>>
>>>   Hi,
>>>
>>> I think the most secured way is to do it like that :
>>>
>>> while( !viewer.done() )
>>>>
>>>>    {
>>>>       viewer.sync();
>>>>       viewer.update();
>>>>
>>>>       modify_scene_graph();
>>>>
>>>>       viewer.frame();
>>>>    }
>>>>
>>>>
>>> If I'm good, the callback allow safe graph modifications, but only on
>>> node children... so depending on what you need, that can be a solution too.
>>> The subject have been discussed lots of time on the mailing list, so
>>> check the archive and you will find some good informations.
>>>
>>> Regards,
>>>    Vincent.
>>>
>>> 2009/5/5 Björn Blissing <[email protected]>
>>>
>>>> Hi!
>>>> I have my GameObject class that contains the position of each dynamic
>>>> game object in world coordinates. I also have my GameObjectManager class
>>>> that contains a vector of all game objects. This vector is empty when the
>>>> program starts, but populates with objects during runtime (some objects is
>>>> also removed during runtime).
>>>>
>>>> I've searched the mail achieve but I can't find any good example how to
>>>> add or remove objects to the scenegraph during runtime. I guess it has to 
>>>> be
>>>> done in some form of callback. But which one? According to
>>>> http://www.mail-archive.com/[email protected]/msg00725.htmlit 
>>>> is a bad idea to do it in a updateCallback.
>>>>
>>>> Hopefully someone could give me an example or at least point me at the
>>>> right direction. Maybe there is an osg example I should study in depth?
>>>>
>>>> /Björn Blissing
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>>>
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
>
> --
> Serge Lages
> http://www.tharsis-software.com
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


-- 
Serge Lages
http://www.tharsis-software.com
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to