use of com.jme3.input.controls.MouseButtonTrigger in project jmonkeyengine by jMonkeyEngine.
the class HelloAudio method initKeys.
/** Declaring "Shoot" action, mapping it to a trigger (mouse left click). */
private void initKeys() {
inputManager.addMapping("Shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "Shoot");
}
use of com.jme3.input.controls.MouseButtonTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestChaseCameraAppState method simpleInitApp.
public void simpleInitApp() {
// Load a teapot model
teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
Material mat_tea = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
teaGeom.setMaterial(mat_tea);
rootNode.attachChild(teaGeom);
// Load a floor model
Material mat_ground = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat_ground.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
Geometry ground = new Geometry("ground", new Quad(50, 50));
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
ground.setLocalTranslation(-25, -1, 25);
ground.setMaterial(mat_ground);
rootNode.attachChild(ground);
//disable the flyCam
stateManager.detach(stateManager.getState(FlyCamAppState.class));
// Enable a chase cam
ChaseCameraAppState chaseCamAS = new ChaseCameraAppState();
chaseCamAS.setTarget(teaGeom);
stateManager.attach(chaseCamAS);
//Uncomment this to invert the camera's vertical rotation Axis
//chaseCamAS.setInvertVerticalAxis(true);
//Uncomment this to invert the camera's horizontal rotation Axis
//chaseCamAS.setInvertHorizontalAxis(true);
//Uncomment this to enable rotation when the middle mouse button is pressed (like Blender)
//WARNING : setting this trigger disable the rotation on right and left mouse button click
//chaseCamAS.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));
//Uncomment this to set mutiple triggers to enable rotation of the cam
//Here space bar and middle mouse button
//chaseCamAS.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE),new KeyTrigger(KeyInput.KEY_SPACE));
//registering inputs for target's movement
registerInput();
}
use of com.jme3.input.controls.MouseButtonTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestJoystick method simpleInitApp.
@Override
public void simpleInitApp() {
getFlyByCamera().setEnabled(false);
Joystick[] joysticks = inputManager.getJoysticks();
if (joysticks == null)
throw new IllegalStateException("Cannot find any joysticks!");
try {
PrintWriter out = new PrintWriter(new FileWriter("joysticks-" + System.currentTimeMillis() + ".txt"));
dumpJoysticks(joysticks, out);
out.close();
} catch (IOException e) {
throw new RuntimeException("Error writing joystick dump", e);
}
int gamepadSize = cam.getHeight() / 2;
float scale = gamepadSize / 512.0f;
gamepad = new GamepadView();
gamepad.setLocalTranslation(cam.getWidth() - gamepadSize - (scale * 20), 0, 0);
gamepad.setLocalScale(scale, scale, scale);
guiNode.attachChild(gamepad);
joystickInfo = new Node("joystickInfo");
joystickInfo.setLocalTranslation(0, cam.getHeight(), 0);
guiNode.attachChild(joystickInfo);
// Add a raw listener because it's eisier to get all joystick events
// this way.
inputManager.addRawInputListener(new JoystickEventListener());
// add action listener for mouse click
// to all easier custom mapping
inputManager.addMapping("mouseClick", new MouseButtonTrigger(mouseInput.BUTTON_LEFT));
inputManager.addListener(new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) {
pickGamePad(getInputManager().getCursorPosition());
}
}
}, "mouseClick");
}
use of com.jme3.input.controls.MouseButtonTrigger in project jmonkeyengine by jMonkeyEngine.
the class HelloPhysics method initInputs.
/** Add InputManager action: Left click triggers shooting. */
private void initInputs() {
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot");
}
use of com.jme3.input.controls.MouseButtonTrigger in project jmonkeyengine by jMonkeyEngine.
the class HelloInput method initKeys.
/** Custom Keybinding: Map named actions to inputs. */
private void initKeys() {
/** You can map one or several inputs to one named mapping. */
inputManager.addMapping("Pause", new KeyTrigger(keyInput.KEY_P));
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_K));
// spacebar!
inputManager.addMapping(// spacebar!
"Rotate", // spacebar!
new KeyTrigger(KeyInput.KEY_SPACE), // left click!
new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
/** Add the named mappings to the action listeners. */
inputManager.addListener(actionListener, "Pause");
inputManager.addListener(analogListener, "Left", "Right", "Rotate");
}
Aggregations