How to ask for an update?

Hello all,

I am using jme to build a 3D visualization inside a bigger program.

Is there any way to trigger an update when I remove some objects from outside the jme?
Like a method of SimpleApplication I might call.

Thanks in advance

Normally, JME is rendering the scene continuously. If you add/remove an object, it is updated right now.
However, I think there is a small glitch if your object is not a child of the simpleApplication.rootNode.

Beware: you should not remove objects from the scene outside the JME Thread ! See the enqueue function to make this from anywhere else…

1 Like

The update is this
[java]public void updateMarkers() {
if (markerObserver.hasChanges()) {
// remove old markers
markersNode.detachAllChildren();
// add new markers
this.markers = new HashMap();
Vector markers = markerObserver.consumeNewSetOfMarkers();
for (LogMarker logMarker : markers) {
LocationType location = markerObserver.getLatLonDepth(logMarker.timestamp);
this.markers.put(location, new Marker(assetManager, markersNode, worldInfo, location, logMarker.label));
}
}
}[/java]

This is being called in the update loop of an AbstractAppState that is attached in the simpleInitApp() of my SimpleApplication.

When the frame that contains JME is in focus this works fine.
The problem is that there is a command outside JME that removes a spacial from the scene while the JME frame is visible (look at image).

This makes the JME frame look unresponsive.
If I could trigger an update by calling a method of my SimpleApplication the problem would be solved but I’m not sure if this is possible.

In your simpleInitApp() method add this:

setPauseOnLostFocus(false);

This will stop jME from pausing when it doesn’t have the focus. By default it’s set to true.

2 Likes

If the thread that is being called is not the render thread, you must enqueue that modification for the application, you shouldn’t be doing this in any other way.

Hé-Hé… A very classical problem, but not what you think of ;-).
See SimpleApplication.setPauseOnLostFocus(boolean) :smiley:

1 Like

Thank you so much!
Works like a charm :smiley:

@shirkit how would I do this?
How would I enqueue a modification without SimpleApplication.setPauseOnLostFocus(false) ?

No, if you pause the window on lost focus, you’ll have no update at all in that window. If, and only if your call to something that modifies the scene graph is outside the render thread, you need to enqueue the modification (check Application docs for that).