Search in sources :

Example 16 with KeyTrigger

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);
}
Also used : BitmapText(com.jme3.font.BitmapText) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 17 with KeyTrigger

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));
}
Also used : Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Box(com.jme3.scene.shape.Box) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ActionListener(com.jme3.input.controls.ActionListener) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) AmbientLight(com.jme3.light.AmbientLight)

Example 18 with KeyTrigger

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");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 19 with KeyTrigger

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");
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger) MatParamOverride(com.jme3.material.MatParamOverride) MatParamOverride(com.jme3.material.MatParamOverride)

Example 20 with KeyTrigger

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");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger)

Aggregations

KeyTrigger (com.jme3.input.controls.KeyTrigger)93 ActionListener (com.jme3.input.controls.ActionListener)36 Vector3f (com.jme3.math.Vector3f)30 Geometry (com.jme3.scene.Geometry)23 Material (com.jme3.material.Material)22 DirectionalLight (com.jme3.light.DirectionalLight)21 Quaternion (com.jme3.math.Quaternion)18 Spatial (com.jme3.scene.Spatial)13 FilterPostProcessor (com.jme3.post.FilterPostProcessor)11 Box (com.jme3.scene.shape.Box)11 BitmapText (com.jme3.font.BitmapText)10 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)10 Node (com.jme3.scene.Node)10 AnalogListener (com.jme3.input.controls.AnalogListener)9 ColorRGBA (com.jme3.math.ColorRGBA)9 Sphere (com.jme3.scene.shape.Sphere)8 AmbientLight (com.jme3.light.AmbientLight)7 Quad (com.jme3.scene.shape.Quad)6 ChaseCamera (com.jme3.input.ChaseCamera)4 BulletAppState (com.jme3.bullet.BulletAppState)3