Hi guys.
Recently I have been experiencing the following error:
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalStateException: Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!
Problem spatial name: Root Node
at com.jme3.scene.Spatial.checkCulling(Spatial.java:260)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:647)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:640)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:974)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
It does not happen all the time, and when it does happen, is only when I try to use my āfly through featureā. Hereās the code for the fly through:
public void flyThrough(String fromLocation, final String toLocation, final boolean pathHighlight, boolean flyThrough) {
PathFinder pf = new PathFinder(box.getXExtent(), box.getZExtent(), buildings);
Vector3f fromVector;
final Vector3f toVector = buildings.getBuildingJumpCoords(toLocation)[0];
if (!(fromLocation.equals("Current"))) {
jumpToLocation(fromLocation);
}
fromVector = player.getPhysicsLocation();
pf.setPath(fromVector, toVector);
ArrayList<Vector3f> vList = pf.getPath();
//cam.lookAt(vList.get(1), Vector3f.UNIT_Y);
if (pathHighlight) {
setPathH(vList);
}
if (flyThrough) {
path = new MotionPath();
for (int i = 0; i < vList.size(); i++) {
path.addWayPoint(vList.get(i));
}
//cam.setLocation(fromVector);
cam.lookAt(path.getWayPoint(1), Vector3f.UNIT_Y);
player.setPhysicsLocation(fromVector);
camNode = new CameraNode("Motion cam", cam);
camNode.setControlDir(ControlDirection.SpatialToCamera);
camNode.setEnabled(false);
path.setCurveTension(0.5f);
cameraMotionControl = new MotionEvent(camNode, path);
rootNode.attachChild(camNode);
camNode.setEnabled(true);
cameraMotionControl.setSpeed(10f);
cameraMotionControl.setInitialDuration(path.getNbWayPoints() / 2);
cameraMotionControl.setDirectionType(MotionEvent.Direction.Path);
cameraMotionControl.play();
path.addListener(new MotionPathListener() {
public void onWayPointReach(MotionEvent control, int wayPointIndex) {
if (path.getNbWayPoints() == wayPointIndex + 1) {
if (pathHighlight) {
removePathH();
}
cameraMotionControl.stop();
camNode.setEnabled(false);
player.setPhysicsLocation(toVector);
cam.lookAt(buildings.getBuildingJumpCoords(toLocation)[1], Vector3f.UNIT_Y);
} else {
player.setPhysicsLocation(path.getWayPoint(wayPointIndex));
}
}
});
}
}[/java]
This method is called via an outside Java Dialog class (user clicks button which send information to this method). The code for the button in the other class:
[java]flyBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
setVisible(false);
Robot robot = new Robot();
robot.mouseMove(cursorX, cursorY);
app.flyThrough(flyComboBoxF.getSelectedItem().toString(),
flyComboBoxT.getSelectedItem().toString(), pathH.isSelected(),
true);
} catch (AWTException ex) {
}
}
});[/java]