use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestDirectionalLightShadow method initInputs.
private void initInputs() {
inputManager.addMapping("ThicknessUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("ThicknessDown", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("lambdaUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("lambdaDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("switchGroundMat", new KeyTrigger(KeyInput.KEY_M));
inputManager.addMapping("debug", new KeyTrigger(KeyInput.KEY_X));
inputManager.addMapping("stabilize", new KeyTrigger(KeyInput.KEY_B));
inputManager.addMapping("distance", new KeyTrigger(KeyInput.KEY_N));
inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_NUMPAD8));
inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_NUMPAD2));
inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_NUMPAD6));
inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_NUMPAD4));
inputManager.addMapping("fwd", new KeyTrigger(KeyInput.KEY_PGUP));
inputManager.addMapping("back", new KeyTrigger(KeyInput.KEY_PGDN));
inputManager.addMapping("pp", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("backShadows", new KeyTrigger(KeyInput.KEY_K));
inputManager.addListener(this, "lambdaUp", "lambdaDown", "ThicknessUp", "ThicknessDown", "switchGroundMat", "debug", "up", "down", "right", "left", "fwd", "back", "pp", "stabilize", "distance", "ShadowUp", "ShadowDown", "backShadows");
ShadowTestUIManager uiMan = new ShadowTestUIManager(assetManager, dlsr, dlsf, guiNode, inputManager, viewPort);
inputManager.addListener(this, "Size+", "Size-");
inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S));
shadowStabilizationText = new BitmapText(guiFont, false);
shadowStabilizationText.setSize(guiFont.getCharSet().getRenderedSize() * 0.75f);
shadowStabilizationText.setText("(b:on/off) Shadow stabilization : " + dlsr.isEnabledStabilization());
shadowStabilizationText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 100, 0);
guiNode.attachChild(shadowStabilizationText);
shadowZfarText = new BitmapText(guiFont, false);
shadowZfarText.setSize(guiFont.getCharSet().getRenderedSize() * 0.75f);
shadowZfarText.setText("(n:on/off) Shadow extend to 500 and fade to 50 : " + (dlsr.getShadowZExtend() > 0));
shadowZfarText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 120, 0);
guiNode.attachChild(shadowZfarText);
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestShadowsPerf method simpleInitApp.
@Override
public void simpleInitApp() {
Logger.getLogger("com.jme3").setLevel(Level.SEVERE);
flyCam.setMoveSpeed(50);
flyCam.setEnabled(false);
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
cam.setLocation(new Vector3f(-53.952988f, 27.15874f, -32.875023f));
cam.setRotation(new Quaternion(0.1564309f, 0.6910534f, -0.15713608f, 0.6879555f));
// cam.setLocation(new Vector3f(53.64627f, 130.56f, -11.247704f));
// cam.setRotation(new Quaternion(-6.5737107E-4f, 0.76819664f, -0.64021313f, -7.886125E-4f));
////
cam.setFrustumFar(500);
mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
Box b = new Box(800, 1, 700);
b.scaleTextureCoordinates(new Vector2f(50, 50));
Geometry ground = new Geometry("ground", b);
ground.setMaterial(mat);
rootNode.attachChild(ground);
ground.setShadowMode(ShadowMode.Receive);
Sphere sphMesh = new Sphere(32, 32, 1);
sphMesh.setTextureMode(Sphere.TextureMode.Projected);
sphMesh.updateGeometry(32, 32, 1, false, false);
TangentBinormalGenerator.generate(sphMesh);
sphere = new Geometry("Rock Ball", sphMesh);
sphere.setLocalTranslation(0, 5, 0);
sphere.setMaterial(mat);
sphere.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(sphere);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(0, -1, 0).normalizeLocal());
dl.setColor(ColorRGBA.White);
rootNode.addLight(dl);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.7f));
rootNode.addLight(al);
//rootNode.setShadowMode(ShadowMode.CastAndReceive);
createballs();
final DirectionalLightShadowRenderer pssmRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 4);
viewPort.addProcessor(pssmRenderer);
//
// final PssmShadowFilter pssmRenderer = new PssmShadowFilter(assetManager, 1024, 4);
// FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
// fpp.addFilter(pssmRenderer);
// viewPort.addProcessor(fpp);
pssmRenderer.setLight(dl);
pssmRenderer.setLambda(0.55f);
pssmRenderer.setShadowIntensity(0.55f);
pssmRenderer.setShadowCompareMode(com.jme3.shadow.CompareMode.Software);
pssmRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
//pssmRenderer.displayDebug();
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("display") && isPressed) {
//pssmRenderer.debugFrustrums();
System.out.println("tetetetet");
}
if (name.equals("add") && isPressed) {
createballs();
}
}
}, "display", "add");
inputManager.addMapping("display", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("add", new KeyTrigger(KeyInput.KEY_RETURN));
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestPbrEnv method initInputs.
private void initInputs() {
inputManager.addMapping("switchGroundMat", new KeyTrigger(KeyInput.KEY_M));
inputManager.addMapping("snapshot", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("fc", new KeyTrigger(KeyInput.KEY_F));
inputManager.addMapping("debugProbe", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addMapping("debugTex", new KeyTrigger(KeyInput.KEY_T));
inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("delete", new KeyTrigger(KeyInput.KEY_DELETE));
inputManager.addListener(this, "delete", "switchGroundMat", "snapshot", "debugTex", "debugProbe", "fc", "up", "down", "left", "right");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestMatParamOverride method simpleInitApp.
@Override
public void simpleInitApp() {
inputManager.setCursorVisible(true);
createBox(-3, ColorRGBA.Red);
createBox(0, ColorRGBA.Green);
createBox(3, ColorRGBA.Blue);
inputManager.addMapping("override", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("override") && isPressed) {
if (!rootNode.getLocalMatParamOverrides().isEmpty()) {
rootNode.clearMatParamOverrides();
} else {
rootNode.addMatParamOverride(override);
}
System.out.println(rootNode.getLocalMatParamOverrides());
}
}
}, "override");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class HelloPicking method initKeys.
/** Declaring the "Shoot" action and mapping to its triggers. */
private void initKeys() {
inputManager.addMapping("Shoot", // trigger 1: spacebar
new KeyTrigger(KeyInput.KEY_SPACE), // trigger 2: left-button click
new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "Shoot");
}
Aggregations