I'm pretty good at programming in Java but I'm new to jMonkeyEngine. I've gotten everything installed and the HelloPhysics example at the link below works great. My goal is to modify this example so that another class can call the "makeCannonBall()" method in the example code. I ultimately want an Arduino to send a serial message to this class when a button is pushed, and have the class fire the cannonball.

In the second class this line is executed (in the event handler for new data received).

app.makeCannonBall();

The line above produces an error:

Uncaught exception thrown in Thread[jME3 Main,5,main]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

So my question is how am I supposed to accomplish this in jMonkey?

I tried creating another class that extended AbstractAppState but that didn't work. In this class I tried to call makeCannonBall() and update the geometric state before/after but I couldn't get it to do anything. I basically created this class object in main, had the new class create a SerialCommunication object serialComm, then had serialComm call a method in the AppState class that would fire the cannon ball and update. I'm not sure if this would or even could have worked. It's possible I did it wrong but I unfortunately deleted the class so I can't post it. If this is the route I have to go I'd appreciate code examples but I'll take any advice I can get.

O and if your wondering what this is for its the start of my Doomsday box project. I want to make a really cool machined enclosure fit with controls, timer, keypad, buzzer, buttons, and more that basically controls a simple game that goes boom and resets. Its kind of stupid but I saw something like it online (link below) and figured I'd make my own new and improved version.

Hmm I think that what psspeed mentioned is probably what I need to do. I'll try that later and see how it goes.

I hadn't thought of utilizing the Arduino as an input device but it could work. I have an Arduino Yun and a Due which have the capability to be setup to act as a keyboard/joystick/mouse over usb rather than a serial port.