javajmonkeyengine

jMonkeyEngine: flyCam and inputManager both return NULL


I've got a trouble: suddenly flyCam and inputManager inside simpleInitApp() both became equal to NULL.

I don't understand what happened! They are ALWAYS NULL!

public void simpleInitApp() {
        Box b = new Box(1, 1, 1);
        System.out.println("inputManager = " + inputManager + "; flyCam = " + flyCam);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);
    }

Output: inputManager = null; flyCam = null

All my examples (I did a lot of samples by jMonkey Book) throws NullPointer exceptions now (they worked before).

I tried to:

  1. reinstall jMonkey SDK and clean Windows registry
  2. reinstall video drivers

... nothing helps...

I don't understand what I actually had done... As far as I remember I just had written this:

private final InputListener flyCamListener = new ActionListener() {
        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            boolean enabled = app.getFlyByCamera().isEnabled();
            app.getFlyByCamera().setEnabled(!enabled);
        }
    };

and everything crushed.

===

jMonkey 3.0.10_x86, Java: 1.7.0_51, Windows 7 x86, OpenGL: 3.0.0, GLSL Ver: 1.30 - Intel Build 8.15.10.2342


Solution

  • I guess I solved the problem. On one of the forums I found and included to NEW project such a section:

        Main app = new Main();
        AppSettings settings = new AppSettings(true);
        settings.setRenderer(AppSettings.LWJGL_OPENGL_ANY);
        settings.setResolution(640, 480);
        settings.setFrameRate(30);
        app.setSettings(settings);
        app.start();
    

    ... and everything started to work! Including all of my previous applications that unexpectedly began to crush.

    So I think the key point is setRenderer() method. I remember I had launched my disastrous application without such a line and probably jMonkey "saved" settings for the sake of itself.

    So why does jMonkey keep its UNSTABLE SETTINGS globally and permanently? All of other applications crush, reinstalling SDK doesn't help and so on!