Randam Exception

Hi,

When I start the application, the below exception is throwing randomly,

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalStateException: Scene graph is not properly updated for rendering.

Make sure scene graph state was not changed after

rootNode.updateGeometricState() call.

Problem spatial name: Root Node

at com.jme3.scene.Spatial.checkCulling(Spatial.java:217)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:775)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1116)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1162)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:264)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)

at java.lang.Thread.run(Thread.java:619)[/java]

I am getting this exception when i start the application, if i retries, it starts on 2 or 3rd time properly.

Please guide to resolve this issue.

Thanks in advance,

If you change a spatial (anything attached to a Node in this case rootNode) after it has updated, you will get this error.



What this means is that you have to do all your movement/rotation/etc before the rootNode is updated. Then it’s safe. If you change it after it’s been updated you will get the above error.

Quoting from @pspeed

The cases where you run into this:
1) you are modifying the scene graph outside of the update loop (ie: from another thread)
2) you are modifying the scene graph in some control’s or app state’s render call.
3) the root node you are using is not the same one that your Application is calling updateGeometricState() on… ie: you’ve setup your own viewport with its own root node or something.

Ya, I am attaching the spatial dynamically(outside the update).



Now it is fine once moved inside the update method.



Thanks,