Detached Children Still Rendering

Hello all,

I am new to jMonkey so I was running through the example located here:

While running the example I noticed that the previous state’s spatials were still being rendered even though they were removed from the root node.

What gives? How to I make the example function correctly? Is this a bug in the example or jMonkey?

I’m looking forward to using jMonkey!


What do you mean ?
Obviously a detached object cannot be rendered anymore.

Rendered objects are those that are

  • attached to the application rootNode
  • attached to the viewport as a scene

If your objects are rendered, they are not detached…

That tutorial is pretty broken anyway. It uses stateAttached and stateDetached in bad ways. (Note: there pretty much are no good ways to use stateAttached and stateDetached except to debug something)

Nodes should be added in initialize() and removed in cleanup(). Alternately, there is a bit of dancing you can do with initialize()/cleanup() and setEnabled() to have it add/remove the nodes when enabled and disabled.

And as yang said, only attached objects are rendered. So if they are still being rendered then they are still attached. Either they weren’t detached or there were two sets of objects and they were attached twice and only one was removed. Some basic debugging will sort out what is happening.

Is there a better App State example I should be looking at?

I don’t think so. It’s probably best to work from the application states documentation instead of the tutorial until someone gets a chance to fix it.