remove parent

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Papa Lazarou
Posts: 12
Joined: Wed May 14, 2008 12:31 pm

remove parent

Post by Papa Lazarou »

How can I change the parent of a scene node to have no parent?
I tried ->setParent(0);
but then after that if i then try to change the parent again it crashes.
piiichan
Posts: 59
Joined: Thu May 01, 2008 1:20 am
Location: New Caledonia (France - Pacific)
Contact:

Post by piiichan »

Call node->setParent( smgr->getRootSceneNode() )

As it is written in the API doc:
The root scene node "is parent of all scene nodes. The root scene node is a special scene node which only exists to manage all scene nodes. It will not be rendered and cannot be removed from the scene. "
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: remove parent

Post by rogerborg »

Papa Lazarou wrote:How can I change the parent of a scene node to have no parent?
I tried ->setParent(0);
but then after that if i then try to change the parent again it crashes.
It crashes because its parent is the only thing that has a reference to it. Without a parent, it gets deleted at the end of setParent(0).

Call node->grab() before node->setParent(0) so that your app holds a reference to it, and then node->drop() after you set a valid parent.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply