[SOLVED] How can i manage nodes inside j3o-scene? Example, detach imported model in scene

Hey guys,

long time not see :}

But I’m alive >> with a new question :}
I importe 2 model to my scene.j3o and attached the spatial to a node like this.

sceneModel = assetManager.loadModel("Scenes/Scene.j3o");

this showa the following output:

for this scene explorer:

Now I can remove the whole scene (all imported models) with:


But how can I detach one of this to model?
But how can I detach only the one model?
How get I access to the nodes Male and Female in the scene explorer? To detach or attach them?

Hopfully, that somebody can help me with this newbee question.

Best regards.
EsKay :blush:


Google “scene Graph jmonkey wiki” there are a lot of ways.

Way a) known structure: cast your Scenemodel to the Node Type → use . GetChild() a few times and then RemoveFromParent (). This does the same as detachChild on the rootNode.

Way B) use a SceneGraphVisitor (slow!) this goes to all subnodes and Calls a callback.

There you can use getName() to Check for female and then RemoveFromParent.
Note: read out about app.enqueue() or else your remove Call will Crash Java with an exception

1 Like

Thanks @Darkchaos :}

The tip of the “cast to node type” was key to my understanding.
The function getChild() was familiar to me - but I did not know how it used wisely :expressionless:

Now I can access Male-Node in scenegraph (updated) as follows:

Node scene = (Node)modelNode.getChild(0); 
Node Model = (Node)scene.getChild(0);
Node Male = (Node)Model.getChild(0)
// detach

Thank you very much. :heart_eyes: :heart_eyes: :heart_eyes:

You don’t even need to use getChild(String name) “a few times”, its recursive already and also gets sub-children.


Hi @normen

Thx for your answer :}

You’re right! :smile:

Node Male = (Node)modelNode.getChild("Male");
Node Female = (Node)modelNode.getChild("Female");

is really more prakticable.

Thanks for the really smart hint :relaxed: