Detatching scene nodes [Solved]

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Detatching scene nodes [Solved]

Post by lonewolff »

Hi Guys,

I am having some problems with scenenodes.

I have two scenenodes mNode1 and mNode2. They are both attached to the root scenenode.

How do I detach mNode2 to the root and re-attach it to mNode1 (mNode1 being the new parent).

I have tried this but I just get an exception;

Code: Select all

mNode1->addChild(mNode2);
Any help would be greatly appreciated :)
Last edited by lonewolff on Thu Jul 24, 2014 3:35 am, edited 1 time in total.
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: Detatching scene nodes

Post by lonewolff »

Ok, I have gotten this far

Code: Select all

	SceneNode *mNode1=mSceneMgr->getSceneNode(name1);
	SceneNode *mNode2=mSceneMgr->getSceneNode(name2);

	Node *mNodeParent=mNode2->getParent();
	mNodeParent->removeChild(mNode2);

	mNode1->addChild(mNode2);
But, things are still not working as anticipated. Time for me to have a big think about what I am doing :)
User avatar
lonewolff
Ogre Magi
Posts: 1207
Joined: Wed Dec 28, 2005 12:58 am
x 6

Re: Detatching scene nodes

Post by lonewolff »

8) 8)
lonewolff wrote:Ok, I have gotten this far

Code: Select all

	SceneNode *mNode1=mSceneMgr->getSceneNode(name1);
	SceneNode *mNode2=mSceneMgr->getSceneNode(name2);

	Node *mNodeParent=mNode2->getParent();
	mNodeParent->removeChild(mNode2);

	mNode1->addChild(mNode2);
But, things are still not working as anticipated. Time for me to have a big think about what I am doing :)
[edit]
Yep, the above code works. I just had to pull out the old pen and paper to get my head around what is going on - LOL :)

Geez I am 'self solving' a lot lately - Hehe 8)
Post Reply