Search in sources :

Example 46 with KeyTrigger

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

the class TestCinematic method initInputs.

private void initInputs() {
    inputManager.addMapping("togglePause", new KeyTrigger(keyInput.KEY_RETURN));
    inputManager.addMapping("navFwd", new KeyTrigger(keyInput.KEY_RIGHT));
    inputManager.addMapping("navBack", new KeyTrigger(keyInput.KEY_LEFT));
    ActionListener acl = new ActionListener() {

        public void onAction(String name, boolean keyPressed, float tpf) {
            if (name.equals("togglePause") && keyPressed) {
                if (cinematic.getPlayState() == PlayState.Playing) {
                    cinematic.pause();
                    time = cinematic.getTime();
                } else {
                    cinematic.play();
                }
            }
            if (cinematic.getPlayState() != PlayState.Playing) {
                if (name.equals("navFwd") && keyPressed) {
                    time += 0.25;
                    FastMath.clamp(time, 0, cinematic.getInitialDuration());
                    cinematic.setTime(time);
                }
                if (name.equals("navBack") && keyPressed) {
                    time -= 0.25;
                    FastMath.clamp(time, 0, cinematic.getInitialDuration());
                    cinematic.setTime(time);
                }
            }
        }
    };
    inputManager.addListener(acl, "togglePause", "navFwd", "navBack");
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 47 with KeyTrigger

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

the class TestBatchNodeCluster method simpleInitApp.

//protected
//    protected Geometry player;
@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    batchNode = new SimpleBatchNode("BatchNode");
    xPosition.add(0);
    yPosition.add(0);
    zPosition.add(0);
    mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.White);
    mat1.setColor("GlowColor", ColorRGBA.Blue.mult(10));
    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.White);
    mat2.setColor("GlowColor", ColorRGBA.Red.mult(10));
    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat3.setColor("Color", ColorRGBA.White);
    mat3.setColor("GlowColor", ColorRGBA.Yellow.mult(10));
    mat4 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat4.setColor("Color", ColorRGBA.White);
    mat4.setColor("GlowColor", ColorRGBA.Orange.mult(10));
    randomGenerator();
    //rootNode.attachChild(SkyFactory.createSky(
    //  assetManager, "Textures/SKY02.zip", false));
    inputManager.addMapping("Start Game", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addListener(al, new String[] { "Start Game" });
    cam.setLocation(new Vector3f(-34.403286f, 126.65158f, 434.791f));
    cam.setRotation(new Quaternion(0.022630932f, 0.9749435f, -0.18736298f, 0.11776358f));
    batchNode.batch();
    terrain = new Node("terrain");
    terrain.setLocalTranslation(50, 0, 50);
    terrain.attachChild(batchNode);
    flyCam.setMoveSpeed(100);
    rootNode.attachChild(terrain);
    Vector3f pos = new Vector3f(-40, 0, -40);
    batchNode.setLocalTranslation(pos);
    Arrow a = new Arrow(new Vector3f(0, 50, 0));
    Geometry g = new Geometry("a", a);
    g.setLocalTranslation(terrain.getLocalTranslation());
    Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m.setColor("Color", ColorRGBA.Blue);
    g.setMaterial(m);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
    //        SSAOFilter ssao = new SSAOFilter(8.630104f,22.970434f,2.9299977f,0.2999997f);    
    //        fpp.addFilter(ssao);
    viewPort.addProcessor(fpp);
//   viewPort.setBackgroundColor(ColorRGBA.DarkGray);
}
Also used : Arrow(com.jme3.scene.debug.Arrow) NanoTimer(com.jme3.system.NanoTimer) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 48 with KeyTrigger

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

the class TestHoveringTank method setupKeys.

private void setupKeys() {
    inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("Space", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("Reset", new KeyTrigger(KeyInput.KEY_RETURN));
    inputManager.addListener(this, "Lefts");
    inputManager.addListener(this, "Rights");
    inputManager.addListener(this, "Ups");
    inputManager.addListener(this, "Downs");
    inputManager.addListener(this, "Space");
    inputManager.addListener(this, "Reset");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 49 with KeyTrigger

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

the class TestIK method simpleInitApp.

@Override
public void simpleInitApp() {
    super.simpleInitApp();
    final KinematicRagdollControl ikControl = model.getControl(KinematicRagdollControl.class);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("stop") && isPressed) {
                ikControl.setEnabled(!ikControl.isEnabled());
                ikControl.setIKMode();
            }
            if (name.equals("one") && isPressed) {
                //ragdoll.setKinematicMode();
                targetPoint = model.getWorldTranslation().add(new Vector3f(0, 2, 4));
                targetNode.setLocalTranslation(targetPoint);
                ikControl.setIKTarget(ikControl.getBone("Hand.L"), targetPoint, 2);
                ikControl.setIKMode();
            }
            if (name.equals("two") && isPressed) {
                //ragdoll.setKinematicMode();
                targetPoint = model.getWorldTranslation().add(new Vector3f(-3, 3, 0));
                targetNode.setLocalTranslation(targetPoint);
                ikControl.setIKTarget(ikControl.getBone("Hand.R"), targetPoint, 3);
                ikControl.setIKMode();
            }
        }
    }, "one", "two");
    inputManager.addMapping("one", new KeyTrigger(KeyInput.KEY_1));
    inputManager.addMapping("two", new KeyTrigger(KeyInput.KEY_2));
    inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_H));
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) KinematicRagdollControl(com.jme3.bullet.control.KinematicRagdollControl)

Example 50 with KeyTrigger

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

the class TestPhysicsCar method setupKeys.

private void setupKeys() {
    inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H));
    inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K));
    inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U));
    inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addMapping("Space", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("Reset", new KeyTrigger(KeyInput.KEY_RETURN));
    inputManager.addListener(this, "Lefts");
    inputManager.addListener(this, "Rights");
    inputManager.addListener(this, "Ups");
    inputManager.addListener(this, "Downs");
    inputManager.addListener(this, "Space");
    inputManager.addListener(this, "Reset");
}
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