Camera doesn't updated in AWT Canvas

I’m writing an Eclipse RCP application. Within this application I use a jMonkey Canvas. Now, I’m trying to change the camera position from outside the jMonkey rendering thread without any effect. It seems the canvas isn’t redrawing but if I click into my jMonkey canvas and just move the mouse a little bit then camera jumps to the correct postion.

The following code is executing by a Callable via SimpleApplication.enqueue

orbitCamera.setRotationCenter(rotCenter);
orbitCamera.setDefaultHorizontalRotation(hRot);
orbitCamera.setDefaultVerticalRotation(vRot);
orbitCamera.setDefaultDistance(dist);
cam.setFrustumPerspective(fovY, settings.getWidth() / settings.getHeight(), 1, 1000);
orbitCamera.update(1);
cam.update();

It is possible to force redrawing the canvas? I tried to called update and redraw methods on the Canvas object and its parents and the update method of the SimpleApplication but without success.

Maybe you forgot to set your application to run even while out of focus:

app.setPauseOnLostFocus(false);

Javadoc

Yes, this attribute is already set.

If I add a box to my root node then it’s immediately visible but just camera makes some problems. Someone an idea how can I investigate this problem?

Are you sure the only problem is the camera or is the entire jME canvas “frozen” until you click? Does an object move even while the canvas is out of focus?

Problem was I had disabled the ChaseCamera, after I did orbitCamera.setEnabled(true); it works. orbitCamera is a instance of ChaseCamera. But still the behavior is a bit strange I would expected if the camera disabled then it mustn’t work.

1 Like

In this case it won’t disable because the ChaseCamera controls an instance of a Camera. Disabling it disables the control it has over Camera and not the Camera itself.

1 Like