Search in sources :

Example 56 with KeyTrigger

use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.

the class ScreenshotAppState method initialize.

@Override
public void initialize(AppStateManager stateManager, Application app) {
    if (!super.isInitialized()) {
        InputManager inputManager = app.getInputManager();
        inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ));
        inputManager.addListener(this, "ScreenShot");
        List<ViewPort> vps = app.getRenderManager().getPostViews();
        ViewPort last = vps.get(vps.size() - 1);
        last.addProcessor(this);
        if (shotName == null) {
            shotName = app.getClass().getSimpleName();
        }
    }
    super.initialize(stateManager, app);
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger) ViewPort(com.jme3.renderer.ViewPort) InputManager(com.jme3.input.InputManager)

Example 57 with KeyTrigger

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

Example 58 with KeyTrigger

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

Example 59 with KeyTrigger

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

Example 60 with KeyTrigger

use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.

the class TestRagdollCharacter method setupKeys.

private void setupKeys() {
    inputManager.addMapping("Rotate Left", new KeyTrigger(KeyInput.KEY_H));
    inputManager.addMapping("Rotate Right", new KeyTrigger(KeyInput.KEY_K));
    inputManager.addMapping("Walk Forward", new KeyTrigger(KeyInput.KEY_U));
    inputManager.addMapping("Walk Backward", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addMapping("Slice", new KeyTrigger(KeyInput.KEY_SPACE), new KeyTrigger(KeyInput.KEY_RETURN));
    inputManager.addListener(this, "Strafe Left", "Strafe Right");
    inputManager.addListener(this, "Rotate Left", "Rotate Right");
    inputManager.addListener(this, "Walk Forward", "Walk Backward");
    inputManager.addListener(this, "Slice");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

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