How to disable default mouse processing?

I didn’t understand this: http://hub.jmonkeyengine.org/groups/general-2/forum/topic/disable-mouse-move/

And this: http://hub.jmonkeyengine.org/groups/graphics/forum/topic/how-to-remove-default-camera-movement/



I wan’t to make Earth rotating in front of user on mouse moving.



I tried following code:



[java]public class HelloMaterial1 extends SimpleApplication {



Geometry earth;



public static void main(String[] args) {

HelloMaterial1 app = new HelloMaterial1();

app.start();

}



@Override

public void simpleInitApp() {





Material earthMaterial = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

earthMaterial.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/earth.png”));



Sphere earthForm = new Sphere(32, 32, 2f);



earth = new Geometry(“earth”, earthForm);

earth.setMaterial(earthMaterial);



rootNode.attachChild(earth);





initKeys();



}



/** Custom Keybinding: Map named actions to inputs. /

private void initKeys() {





inputManager.addMapping(“RotateX”, new MouseAxisTrigger(MouseInput.AXIS_X, false));

inputManager.addMapping(“RotateY”, new MouseAxisTrigger(MouseInput.AXIS_Y, false));



inputManager.addListener(analogListener, new String[]{“RotateX”, “RotateY”});





}

private AnalogListener analogListener = new AnalogListener() {



public void onAnalog(String name, float value, float tpf) {

if (name.equals(“RotateX”)) {



earth.rotate(0, value
speed, 0);

System.out.println(“RotateX”);



} else if (name.equals(“RotateY”)) {

earth.rotate(value*speed, 0, 0);

System.out.println(“RotateY”);

}

}

};

}[/java]



But the earth not only rotates, but also moves. Also it rotates only in one direction, but I didn’t debuggin it yet.

I did the following



[java]private void initKeys() {



inputManager.clearMappings();



inputManager.addMapping("RotateX", new MouseAxisTrigger(MouseInput.AXIS_X, false));

inputManager.addMapping("RotateY", new MouseAxisTrigger(MouseInput.AXIS_Y, false));



inputManager.addListener(analogListener, new String[]{"RotateX", "RotateY"});





}[/java]



but lost the ability to quit app by ESC :slight_smile:

You can also just flyCam.setEnabled(false) in simpleInit.



This question is asked about once a week… so you’ve covered this week. :slight_smile:

:slight_smile:



I found setEnabled() too. But still can’t realize how to disable everything, except ESC, or only mouse?

Also I can’t understand yet, am I really obliged to create 4 listeners for 4 directions of mouse movement?



Why not to put the answer onto HelloInput page? It has an appropriate paragraph at the beginning, when telling about default WASD.

You can have one listener for everything if you want to… but you’d at least have to register it once for each axis.