Search in sources :

Example 6 with KeyTrigger

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

the class TestPosterization method initInputs.

private void initInputs() {
    inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
    ActionListener acl = new ActionListener() {

        public void onAction(String name, boolean keyPressed, float tpf) {
            if (name.equals("toggle") && keyPressed) {
                pf.setEnabled(!pf.isEnabled());
            }
        }
    };
    inputManager.addListener(acl, "toggle");
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 7 with KeyTrigger

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

the class TestBloom method initInputs.

private void initInputs() {
    inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
    ActionListener acl = new ActionListener() {

        public void onAction(String name, boolean keyPressed, float tpf) {
            if (name.equals("toggle") && keyPressed) {
                if (active) {
                    active = false;
                    viewPort.removeProcessor(fpp);
                } else {
                    active = true;
                    viewPort.addProcessor(fpp);
                }
            }
        }
    };
    inputManager.addListener(acl, "toggle");
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 8 with KeyTrigger

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

the class TestCrossHatch method initInputs.

private void initInputs() {
    inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
    ActionListener acl = new ActionListener() {

        public void onAction(String name, boolean keyPressed, float tpf) {
            if (name.equals("toggle") && keyPressed) {
                if (active) {
                    active = false;
                    viewPort.removeProcessor(fpp);
                } else {
                    active = true;
                    viewPort.addProcessor(fpp);
                }
            }
        }
    };
    inputManager.addListener(acl, "toggle");
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 9 with KeyTrigger

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

the class TestAnimBlendBug method simpleInitApp.

@Override
public void simpleInitApp() {
    inputManager.addMapping("One", new KeyTrigger(KeyInput.KEY_1));
    inputManager.addListener(this, "One");
    flyCam.setMoveSpeed(100f);
    cam.setLocation(new Vector3f(0f, 150f, -325f));
    cam.lookAt(new Vector3f(0f, 100f, 0f), Vector3f.UNIT_Y);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    Node model1 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
    Node model2 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
    //        Node model2 = model1.clone();
    model1.setLocalTranslation(-60, 0, 0);
    model2.setLocalTranslation(60, 0, 0);
    AnimControl control1 = model1.getControl(AnimControl.class);
    animNames = control1.getAnimationNames().toArray(new String[0]);
    channel1 = control1.createChannel();
    AnimControl control2 = model2.getControl(AnimControl.class);
    channel2 = control2.createChannel();
    SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton1", control1.getSkeleton());
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    mat.setColor("Color", ColorRGBA.Green);
    mat.getAdditionalRenderState().setDepthTest(false);
    skeletonDebug.setMaterial(mat);
    model1.attachChild(skeletonDebug);
    skeletonDebug = new SkeletonDebugger("skeleton2", control2.getSkeleton());
    skeletonDebug.setMaterial(mat);
    model2.attachChild(skeletonDebug);
    rootNode.attachChild(model1);
    rootNode.attachChild(model2);
}
Also used : SkeletonDebugger(com.jme3.scene.debug.SkeletonDebugger) ColorRGBA(com.jme3.math.ColorRGBA) KeyTrigger(com.jme3.input.controls.KeyTrigger) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Node(com.jme3.scene.Node) Material(com.jme3.material.Material) AnimControl(com.jme3.animation.AnimControl)

Example 10 with KeyTrigger

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

the class TestToneMapFilter method initInputs.

private void initInputs() {
    inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("WhitePointUp", new KeyTrigger(KeyInput.KEY_Y));
    inputManager.addMapping("WhitePointDown", new KeyTrigger(KeyInput.KEY_H));
    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);
                    System.out.println("Tone Mapping OFF");
                } else {
                    enabled = true;
                    viewPort.addProcessor(fpp);
                    System.out.println("Tone Mapping ON");
                }
            }
        }
    };
    AnalogListener anl = new AnalogListener() {

        public void onAnalog(String name, float isPressed, float tpf) {
            if (name.equals("WhitePointUp")) {
                whitePointLog += tpf * 1.0;
                if (whitePointLog > 4f) {
                    whitePointLog = 4f;
                }
                float wp = FastMath.exp(whitePointLog);
                toneMapFilter.setWhitePoint(new Vector3f(wp, wp, wp));
                System.out.println("White point: " + wp);
            }
            if (name.equals("WhitePointDown")) {
                whitePointLog -= tpf * 1.0;
                if (whitePointLog < -4f) {
                    whitePointLog = -4f;
                }
                float wp = FastMath.exp(whitePointLog);
                toneMapFilter.setWhitePoint(new Vector3f(wp, wp, wp));
                System.out.println("White point: " + wp);
            }
        }
    };
    inputManager.addListener(acl, "toggle");
    inputManager.addListener(anl, "WhitePointUp", "WhitePointDown");
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger) Vector3f(com.jme3.math.Vector3f) AnalogListener(com.jme3.input.controls.AnalogListener)

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