Hello
Firstly im new to the forum so Hello everyone!
I am learning basics with Jmonkeyengine book and I am at the setting button part.
here’s my code:
package mygame;
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.input.;
import com.jme3.input.controls.;
import com.jme3.scene.Node;
/**
-
test
-
@author normenhansen
*/
public class Main extends SimpleApplication {private final static Trigger TRIGGER_COLOR =
new KeyTrigger(KeyInput.KEY_SPACE);
private final static Trigger TRIGGER_ROTATE =
new MouseButtonTrigger(MouseInput.BUTTON_LEFT);
private final static String MAPPING_COLOR = “Toggle Color”;
private final static String MAPPING_ROTATE = “Rotate”;
private final static Trigger TRIGGER_COLOR2 =
new KeyTrigger(KeyInput.KEY_C);
private Geometry geom;public static void main(String[] args) {
Main app = new Main();
app.start();
}@Override
public void simpleInitApp() {Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); Node nic = new Node(); nic.attachChild(geom); rootNode.attachChild(nic); inputManager.addMapping(MAPPING_COLOR, TRIGGER_COLOR); inputManager.addMapping(MAPPING_ROTATE, TRIGGER_ROTATE); inputManager.addMapping(MAPPING_COLOR, TRIGGER_COLOR, TRIGGER_COLOR2); inputManager.addListener(actionListener, new String[]{MAPPING_COLOR}); inputManager.addListener(analogListener, new String[]{MAPPING_ROTATE});
}
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
geom.move(0, 0, 1);
}
};
private AnalogListener analogListener = new AnalogListener() {
public void onAnalog(String name, float intensity, float tpf) {
System.out.println("You triggered: " + name);}
};
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
and here’s whole error:
run:
maj 30, 2014 9:01:28 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.5
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.0 context running on thread LWJGL Renderer Thread
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: igdumdim64
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 9.18.10.3107
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: Intel
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.0.0 - Build 9.18.10.3107
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: Intel® HD Graphics 4600
maj 30, 2014 9:01:28 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.00 - Build 9.18.10.3107
maj 30, 2014 9:01:28 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Device: OpenAL Soft
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Vendor: OpenAL Community
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Renderer: OpenAL Soft
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Version: 1.1 ALSOFT 1.15.1
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
maj 30, 2014 9:01:28 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
maj 30, 2014 9:01:28 AM com.jme3.input.InputManager addMapping
WARNING: Attempted to add mapping “Toggle Color” twice to trigger.
maj 30, 2014 9:01:29 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Main$1.onAction(Main.java:63)
at com.jme3.input.InputManager.invokeActions(InputManager.java:169)
at com.jme3.input.InputManager.onKeyEventQueued(InputManager.java:455)
at com.jme3.input.InputManager.processQueue(InputManager.java:831)
at com.jme3.input.InputManager.update(InputManager.java:883)
at com.jme3.app.Application.update(Application.java:604)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
BUILD SUCCESSFUL (total time: 6 seconds)
Please show me where I have an error.
I know that " geom.move(0, 0, 1); " cause error, but I tried to move node, rotate geom even when I try to move it by " geom.move(0, 0, 0); " I still have this error message.
Thanks for Your help