1

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

Mitrakov Artem
  • 1,355
  • 2
  • 14
  • 22
  • If you don't initialize the `FlyCamAppState` (e.g. by not using the default constructor of `SimpleApplication`) the `flyCam` will be NULL. `inputManager` will be NULL if you set "UseInput" in the config to false. – 1000ml Sep 14 '16 at 17:24

1 Answers1

0

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!

Mitrakov Artem
  • 1,355
  • 2
  • 14
  • 22
  • 1
    The "disastrous" application as you call it saved its settings as "default". Any other app that uses 'new AppSettings(true)' (true here means "use default settings") will use that setting. This is why resolution preferences etc gets saved between sessions. It's not jme or the SDK itself that remembers it, just the settings. – reden Sep 19 '16 at 12:44
  • You're absolutely right, reden. The best solution, in my opinion, is to always set up the settings and not to rely on defaults – Mitrakov Artem Sep 20 '16 at 05:03