Detaching and re-attaching nodes / moving nodes in the graph

WarehouseJim

22-09-2009 15:42:27

This should be a simple question, but I keep on getting AccessViolationExceptions and stuff missing from the scene, so I'm obviously not getting it quite right. I'm trying to create a scene node with subnodes / entities, then move that scenenode between various locations in the scenegraph. In doing so I will also create a number of unnecessary scenenodes, so I wish to destroy some of them.

So, in pseudo code I want to do something like:

var sceneNode1 = sceneManager.RootSceneNode.CreateChildSceneNode();
var sceneNode2 = sceneManager.RootSceneNode.CreateChildSceneNode();

var interestingNode= new SceneNode(sceneManager);
var entity = sceneManager.CreateEntity(...);
interestingNode.attach(entity);
interestingNode.Scale(...)
... etc...

sceneNode1.AddChildSceneNode(interestingNode);
...render a few frames...

sceneNode1.RemoveChildSceneNode(interestingNode);
sceneManager.DestroySceneNode(sceneNode1);
sceneNode2.AddChildSceneNode(interestingNode);
..render more frames...


I'm using Mogre 1.4.8 at the moment. I'll get round to upgrading soon!

Does anyone know how to do this? Thanks in advance for any help.

smiley80

22-09-2009 18:58:45

Use SceneManager.CreateSceneNode() instead of the constructor.
Constructor, only to be called by the creator SceneManager.