use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestPosterization method initInputs.
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
pf.setEnabled(!pf.isEnabled());
}
}
};
inputManager.addListener(acl, "toggle");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestBloom method initInputs.
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
if (active) {
active = false;
viewPort.removeProcessor(fpp);
} else {
active = true;
viewPort.addProcessor(fpp);
}
}
}
};
inputManager.addListener(acl, "toggle");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestCrossHatch method initInputs.
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
if (active) {
active = false;
viewPort.removeProcessor(fpp);
} else {
active = true;
viewPort.addProcessor(fpp);
}
}
}
};
inputManager.addListener(acl, "toggle");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestAnimBlendBug method simpleInitApp.
@Override
public void simpleInitApp() {
inputManager.addMapping("One", new KeyTrigger(KeyInput.KEY_1));
inputManager.addListener(this, "One");
flyCam.setMoveSpeed(100f);
cam.setLocation(new Vector3f(0f, 150f, -325f));
cam.lookAt(new Vector3f(0f, 100f, 0f), Vector3f.UNIT_Y);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
Node model1 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
Node model2 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
// Node model2 = model1.clone();
model1.setLocalTranslation(-60, 0, 0);
model2.setLocalTranslation(60, 0, 0);
AnimControl control1 = model1.getControl(AnimControl.class);
animNames = control1.getAnimationNames().toArray(new String[0]);
channel1 = control1.createChannel();
AnimControl control2 = model2.getControl(AnimControl.class);
channel2 = control2.createChannel();
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton1", control1.getSkeleton());
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Green);
mat.getAdditionalRenderState().setDepthTest(false);
skeletonDebug.setMaterial(mat);
model1.attachChild(skeletonDebug);
skeletonDebug = new SkeletonDebugger("skeleton2", control2.getSkeleton());
skeletonDebug.setMaterial(mat);
model2.attachChild(skeletonDebug);
rootNode.attachChild(model1);
rootNode.attachChild(model2);
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestToneMapFilter method initInputs.
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("WhitePointUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("WhitePointDown", new KeyTrigger(KeyInput.KEY_H));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
if (enabled) {
enabled = false;
viewPort.removeProcessor(fpp);
System.out.println("Tone Mapping OFF");
} else {
enabled = true;
viewPort.addProcessor(fpp);
System.out.println("Tone Mapping ON");
}
}
}
};
AnalogListener anl = new AnalogListener() {
public void onAnalog(String name, float isPressed, float tpf) {
if (name.equals("WhitePointUp")) {
whitePointLog += tpf * 1.0;
if (whitePointLog > 4f) {
whitePointLog = 4f;
}
float wp = FastMath.exp(whitePointLog);
toneMapFilter.setWhitePoint(new Vector3f(wp, wp, wp));
System.out.println("White point: " + wp);
}
if (name.equals("WhitePointDown")) {
whitePointLog -= tpf * 1.0;
if (whitePointLog < -4f) {
whitePointLog = -4f;
}
float wp = FastMath.exp(whitePointLog);
toneMapFilter.setWhitePoint(new Vector3f(wp, wp, wp));
System.out.println("White point: " + wp);
}
}
};
inputManager.addListener(acl, "toggle");
inputManager.addListener(anl, "WhitePointUp", "WhitePointDown");
}
Aggregations