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

Well, does it work if you delete it again.

BTW check isPressed in your onAction otherwise you toggle your flycam wenn pressing your key and toggling again after releasing

No one application works correctly anymore… even new ones

Do regular java apps run outside JME SDK work properly?

Do regular java apps run outside JME SDK work properly?

Yeah, regular java apps work normally. Tested with IntelliJ IDEA and even with non-JME app within JME-IDE

That’s weird. Maybe something gone wrong with your libraries?

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 JMONKEY KEEPS ITS UNSTABLE SETTINGS GLOBALLY AND PERMANENTLY? All of other applications crush, reinstalling SDK doesn’t help and so on!

Because the all have the same title and so share the same stored preferences… though really relying on JME for that is hit or miss. (This may have been fixed in 3.1 since I seem to have to specifically load my settings now.)

Set a title for your app in the app settings and they will use different stored settings.

Edit: actually it would be helpful to see one of the classes that is failing’s main method and not just the one method that is failing.

Of course I’d like to help!
Very simple class:

public class Main extends SimpleApplication {
    public static void main(String[] args) {
        Main app = new Main();
        AppSettings settings = new AppSettings(true);
        settings.setUseInput(false);
        app.setSettings(settings);
        app.start();
    }

    @Override
    public void simpleInitApp() {
        System.out.println("inputManager = " + inputManager + 
               "; flyCam = " + flyCam); // output: null, null
        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);
        Material mat = new Material(assetManager, "...Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);
        rootNode.attachChild(geom);
    }

    @Override
    public void simpleUpdate(float tpf) {}

    @Override
    public void simpleRender(RenderManager rm) {}
}

… that destroys every JME application once and for all.

Moreover every JME application (when finishes) throws an Exception:

java.lang.NullPointerException
    at com.jme3.app.DebugKeysAppState.cleanup(DebugKeysAppState.java:86)
    ...

The solution to revive the Engine is appeared to (just once) launch any JME application that includes:

Main app = new Main();
AppSettings s = new AppSettings(true);
app.setSettings(s);
app.start();

Ah, so the failing apps weren’t setting an AppSettings I guess. I didn’t even know that worked. :slight_smile:

Exactly! All those applications are from the Book. I suppose such important settings as “useNoInput” should not be on a global level :slight_smile:

They aren’t if you setup your app right to either load defaults or give it a title so that it loads its own values.