use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class HelloCollision method setUpKeys.
/** We over-write some navigational key mappings here, so we can
* add physics-controlled walking and jumping: */
private void setUpKeys() {
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, "Left");
inputManager.addListener(this, "Right");
inputManager.addListener(this, "Up");
inputManager.addListener(this, "Down");
inputManager.addListener(this, "Jump");
}
use of com.jme3.input.controls.KeyTrigger 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");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestRenderToTexture method simpleInitApp.
@Override
public void simpleInitApp() {
cam.setLocation(new Vector3f(3, 3, 3));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
//setup main scene
Geometry quad = new Geometry("box", new Box(1, 1, 1));
Texture offTex = setupOffscreenView();
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", offTex);
quad.setMaterial(mat);
rootNode.attachChild(quad);
inputManager.addMapping(TOGGLE_UPDATE, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, TOGGLE_UPDATE);
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestFog method initInputs.
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("DensityUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("DensityDown", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("DistanceUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("DistanceDown", new KeyTrigger(KeyInput.KEY_J));
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);
} else {
enabled = true;
viewPort.addProcessor(fpp);
}
}
}
};
AnalogListener anl = new AnalogListener() {
public void onAnalog(String name, float isPressed, float tpf) {
if (name.equals("DensityUp")) {
fog.setFogDensity(fog.getFogDensity() + 0.001f);
System.out.println("Fog density : " + fog.getFogDensity());
}
if (name.equals("DensityDown")) {
fog.setFogDensity(fog.getFogDensity() - 0.010f);
System.out.println("Fog density : " + fog.getFogDensity());
}
if (name.equals("DistanceUp")) {
fog.setFogDistance(fog.getFogDistance() + 0.5f);
System.out.println("Fog Distance : " + fog.getFogDistance());
}
if (name.equals("DistanceDown")) {
fog.setFogDistance(fog.getFogDistance() - 0.5f);
System.out.println("Fog Distance : " + fog.getFogDistance());
}
}
};
inputManager.addListener(acl, "toggle");
inputManager.addListener(anl, "DensityUp", "DensityDown", "DistanceUp", "DistanceDown");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class SSAOUI method init.
private void init(InputManager inputManager) {
System.out.println("----------------- SSAO UI Debugger --------------------");
System.out.println("-- Sample Radius : press Y to increase, H to decrease");
System.out.println("-- AO Intensity : press U to increase, J to decrease");
System.out.println("-- AO scale : press I to increase, K to decrease");
System.out.println("-- AO bias : press O to increase, P to decrease");
System.out.println("-- Toggle AO on/off : press space bar");
System.out.println("-- Use only AO : press Num pad 0");
System.out.println("-- Output config declaration : press P");
System.out.println("-------------------------------------------------------");
inputManager.addMapping("sampleRadiusUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("sampleRadiusDown", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("intensityUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("intensityDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("scaleUp", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("scaleDown", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("biasUp", new KeyTrigger(KeyInput.KEY_O));
inputManager.addMapping("biasDown", new KeyTrigger(KeyInput.KEY_L));
inputManager.addMapping("outputConfig", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("toggleUseAO", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("toggleUseOnlyAo", new KeyTrigger(KeyInput.KEY_NUMPAD0));
inputManager.addMapping("toggleApprox", new KeyTrigger(KeyInput.KEY_NUMPAD5));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggleUseAO") && keyPressed) {
filter.setEnabled(!filter.isEnabled());
// filter.setUseAo(!filter.isUseAo());
System.out.println("use AO : " + filter.isEnabled());
}
if (name.equals("toggleApprox") && keyPressed) {
filter.setApproximateNormals(!filter.isApproximateNormals());
System.out.println("Approximate Normals : " + filter.isApproximateNormals());
}
if (name.equals("toggleUseOnlyAo") && keyPressed) {
filter.setUseOnlyAo(!filter.isUseOnlyAo());
System.out.println("use Only AO : " + filter.isUseOnlyAo());
}
if (name.equals("outputConfig") && keyPressed) {
System.out.println("new SSAOFilter(" + filter.getSampleRadius() + "f," + filter.getIntensity() + "f," + filter.getScale() + "f," + filter.getBias() + "f);");
}
}
};
AnalogListener anl = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("sampleRadiusUp")) {
filter.setSampleRadius(filter.getSampleRadius() + 0.01f);
System.out.println("Sample Radius : " + filter.getSampleRadius());
}
if (name.equals("sampleRadiusDown")) {
filter.setSampleRadius(filter.getSampleRadius() - 0.01f);
System.out.println("Sample Radius : " + filter.getSampleRadius());
}
if (name.equals("intensityUp")) {
filter.setIntensity(filter.getIntensity() + 0.01f);
System.out.println("Intensity : " + filter.getIntensity());
}
if (name.equals("intensityDown")) {
filter.setIntensity(filter.getIntensity() - 0.01f);
System.out.println("Intensity : " + filter.getIntensity());
}
if (name.equals("scaleUp")) {
filter.setScale(filter.getScale() + 0.01f);
System.out.println("scale : " + filter.getScale());
}
if (name.equals("scaleDown")) {
filter.setScale(filter.getScale() - 0.01f);
System.out.println("scale : " + filter.getScale());
}
if (name.equals("biasUp")) {
filter.setBias(filter.getBias() + 0.001f);
System.out.println("bias : " + filter.getBias());
}
if (name.equals("biasDown")) {
filter.setBias(filter.getBias() - 0.001f);
System.out.println("bias : " + filter.getBias());
}
}
};
inputManager.addListener(acl, "toggleUseAO", "toggleApprox", "toggleUseOnlyAo", "outputConfig");
inputManager.addListener(anl, "sampleRadiusUp", "sampleRadiusDown", "intensityUp", "intensityDown", "scaleUp", "scaleDown", "biasUp", "biasDown");
}
Aggregations