use of com.jme3.input.controls.ActionListener in project jmonkeyengine by jMonkeyEngine.
the class TestCameraMotionPath method initInputs.
private void initInputs() {
inputManager.addMapping("display_hidePath", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("SwitchPathInterpolation", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("tensionUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("tensionDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("play_stop", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("display_hidePath") && keyPressed) {
if (active) {
active = false;
path.disableDebugShape();
} else {
active = true;
path.enableDebugShape(assetManager, rootNode);
}
}
if (name.equals("play_stop") && keyPressed) {
if (playing) {
playing = false;
cameraMotionControl.stop();
chaser.setEnabled(true);
camNode.setEnabled(false);
} else {
playing = true;
chaser.setEnabled(false);
camNode.setEnabled(true);
cameraMotionControl.play();
}
}
if (name.equals("SwitchPathInterpolation") && keyPressed) {
if (path.getPathSplineType() == SplineType.CatmullRom) {
path.setPathSplineType(SplineType.Linear);
} else {
path.setPathSplineType(SplineType.CatmullRom);
}
}
if (name.equals("tensionUp") && keyPressed) {
path.setCurveTension(path.getCurveTension() + 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
if (name.equals("tensionDown") && keyPressed) {
path.setCurveTension(path.getCurveTension() - 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
}
};
inputManager.addListener(acl, "display_hidePath", "play_stop", "SwitchPathInterpolation", "tensionUp", "tensionDown");
}
use of com.jme3.input.controls.ActionListener in project jmonkeyengine by jMonkeyEngine.
the class TestJaime method setupInput.
public void setupInput() {
inputManager.addMapping("start", new KeyTrigger(KeyInput.KEY_PAUSE));
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("start") && isPressed) {
if (cinematic.getPlayState() != PlayState.Playing) {
cinematic.play();
} else {
cinematic.pause();
}
}
}
}, "start");
}
use of com.jme3.input.controls.ActionListener in project jmonkeyengine by jMonkeyEngine.
the class TestMotionPath method initInputs.
private void initInputs() {
inputManager.addMapping("display_hidePath", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("SwitchPathInterpolation", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("tensionUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("tensionDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("play_stop", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("display_hidePath") && keyPressed) {
if (active) {
active = false;
path.disableDebugShape();
} else {
active = true;
path.enableDebugShape(assetManager, rootNode);
}
}
if (name.equals("play_stop") && keyPressed) {
if (playing) {
playing = false;
motionControl.stop();
} else {
playing = true;
motionControl.play();
}
}
if (name.equals("SwitchPathInterpolation") && keyPressed) {
if (path.getPathSplineType() == SplineType.CatmullRom) {
path.setPathSplineType(SplineType.Linear);
} else {
path.setPathSplineType(SplineType.CatmullRom);
}
}
if (name.equals("tensionUp") && keyPressed) {
path.setCurveTension(path.getCurveTension() + 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
if (name.equals("tensionDown") && keyPressed) {
path.setCurveTension(path.getCurveTension() - 0.1f);
System.err.println("Tension : " + path.getCurveTension());
}
}
};
inputManager.addListener(acl, "display_hidePath", "play_stop", "SwitchPathInterpolation", "tensionUp", "tensionDown");
}
use of com.jme3.input.controls.ActionListener in project jmonkeyengine by jMonkeyEngine.
the class TestSoftParticles method simpleInitApp.
@Override
public void simpleInitApp() {
cam.setLocation(new Vector3f(-7.2221026f, 4.1183004f, 7.759811f));
cam.setRotation(new Quaternion(0.06152846f, 0.91236454f, -0.1492115f, 0.37621948f));
flyCam.setMoveSpeed(10);
// -------- floor
Box b = new Box(10, 0.1f, 10);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Gray);
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
geom.setMaterial(mat);
rootNode.attachChild(geom);
Box b2 = new Box(1, 1, 1);
Geometry geom2 = new Geometry("Box", b2);
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.DarkGray);
geom2.setMaterial(mat2);
rootNode.attachChild(geom2);
geom2.setLocalScale(0.1f, 0.2f, 1);
fpp = new FilterPostProcessor(assetManager);
tbf = new TranslucentBucketFilter(true);
fpp.addFilter(tbf);
int samples = context.getSettings().getSamples();
if (samples > 0) {
fpp.setNumSamples(samples);
}
viewPort.addProcessor(fpp);
particleNode = new Node("particleNode");
rootNode.attachChild(particleNode);
createParticles();
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed && name.equals("toggle")) {
// tbf.setEnabled(!tbf.isEnabled());
softParticles = !softParticles;
if (softParticles) {
viewPort.addProcessor(fpp);
} else {
viewPort.removeProcessor(fpp);
}
}
}
}, "toggle");
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
// emit again
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed && name.equals("refire")) {
//fpp.removeFilter(tbf); // <-- add back in to fix
particleNode.detachAllChildren();
createParticles();
//fpp.addFilter(tbf);
}
}
}, "refire");
inputManager.addMapping("refire", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
}
use of com.jme3.input.controls.ActionListener 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");
}
Aggregations