Hi Steve,
On the other hand, you don't have to write a visitor, if you know the node was
only once added to the graph.
Simply use getParent( 0 ) method to obtain node parent. Eg:
node->getParent(0)->removeChild( node );
One may be tempted to call removeParent( 0 ) and expect that parent will
consequently remove its child. But this will not work like that. removeParent
does not invoke removeChild.
Cheers,
Wojtek
----- Original Message -----
From: Steve Smith
To: OpenSceneGraph Users
Sent: Monday, April 21, 2008 12:11 AM
Subject: Re: [osg-users] Removing an object from the SceneGraph
Paul,
Thank for the clarification and tip!
Steve
On Sun, Apr 20, 2008 at 3:41 PM, Paul Martz <[EMAIL PROTECTED]> wrote:
You'll want to call removeChild() on the Node's parent.
You mentioned calling removeChild() on the root Node, and having OSG
support this by walking the tree to find and delete the Node. First, if this is
indeed what you want, you can write a NodeVisitor to do this task. Second, be
aware that you'll need to handle cases where the Node is multi-parented (more
than one parent Node references the child Node).
-Paul
--------------------------------------------------------------------------
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Smith
Sent: Sunday, April 20, 2008 12:09 PM
To: [email protected]
Subject: Re: [osg-users] Removing an object from the SceneGraph
Robert,
Thanks for the sanity check. From what I could tell scouring the
documentation (and a few google hits) this was the correct way to remove
something. I did the usual stepping through code and such before wanting to
post on the list to make sure I wasn't doing something real obvious code wise.
After my first post, I had one other idea. I called removeChild(), but
not on the root of the scene graph, but on the parent node of the node I wanted
to remove. This worked as expected.
So the followup question is... must removeChild() be called on the
immediate parent node instead of the root node (or any node up the chain)? I
assumed, perhaps incorrectly, that if I asked the root node to remove a child,
it would traverse the tree for me. If this _should_ work, then I will continue
to look for the cause on my end... I just want to make sure I have a proper
understanding of the expected behavior.
I should also have mentioned in the first post, I'm using OSG 2.2 (on OS
X if that is important as well).
Steve
>Hi Steve,
>
>The line you are using to remove a child is the appropriate one, as to
>why it doesn't work in your case, we'll this isn't something I can
>answer. To find out why you'll need to do more debugging at your end.
>Perhaps a bug in your code is occurring such that pointers are wrong,
>or code isn't being executed.
>
>Robert.
_______________________________________________
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