Search in sources :

Example 81 with KeyTrigger

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

the class TestBloomAlphaThreshold method initInputs.

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

        @Override
        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 82 with KeyTrigger

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

the class TestHWSkinning method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(3.8664846f, 6.2704787f, 9.664585f));
    cam.setRotation(new Quaternion(-0.054774776f, 0.94064945f, -0.27974048f, -0.18418397f));
    makeHudText();
    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);
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
            model.setLocalScale(0.1f);
            model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
            control = model.getControl(AnimControl.class);
            channel = control.createChannel();
            channel.setAnim(animNames[(i + j) % 4]);
            SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
            skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
            skControls.add(skeletonControl);
            rootNode.attachChild(model);
        }
    }
    inputManager.addListener(this, "toggleHWS");
    inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 83 with KeyTrigger

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

the class TestOgreAnim method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
    cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
    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);
    Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    model.center();
    control = model.getControl(AnimControl.class);
    control.addListener(this);
    channel = control.createChannel();
    for (String anim : control.getAnimationNames()) System.out.println(anim);
    channel.setAnim("stand");
    geom = (Geometry) ((Node) model).getChild(0);
    SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
    Box b = new Box(.25f, 3f, .25f);
    Geometry item = new Geometry("Item", b);
    item.move(0, 1.5f, 0);
    item.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    Node n = skeletonControl.getAttachmentsNode("hand.right");
    n.attachChild(item);
    rootNode.attachChild(model);
    inputManager.addListener(this, "Attack");
    inputManager.addMapping("Attack", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : Geometry(com.jme3.scene.Geometry) ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Node(com.jme3.scene.Node) KeyTrigger(com.jme3.input.controls.KeyTrigger) Box(com.jme3.scene.shape.Box)

Example 84 with KeyTrigger

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

the class TestSkeletonControlRefresh method simpleInitApp.

@Override
public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.White);
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(3.8664846f, 6.2704787f, 9.664585f));
    cam.setRotation(new Quaternion(-0.054774776f, 0.94064945f, -0.27974048f, -0.18418397f));
    makeHudText();
    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);
    Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey k = new TextureKey("Models/Oto/Oto.jpg", false);
    m.setTexture("ColorMap", assetManager.loadTexture(k));
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
            //setting a different material
            model.setMaterial(m.clone());
            model.setLocalScale(0.1f);
            model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
            control = model.getControl(AnimControl.class);
            channel = control.createChannel();
            channel.setAnim(animNames[(i + j) % 4]);
            channel.setLoopMode(LoopMode.DontLoop);
            SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
            //This is a workaround the issue. this call will make the SkeletonControl gather the targets again.
            //skeletonControl.setSpatial(model);
            skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
            skControls.add(skeletonControl);
            rootNode.attachChild(model);
        }
    }
    rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    setupFloor();
    inputManager.addListener(this, "toggleHWS");
    inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
    //        DirectionalLightShadowRenderer pssm = new DirectionalLightShadowRenderer(assetManager, 1024, 2);
    //        pssm.setLight(dl);
    //        viewPort.addProcessor(pssm);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    DirectionalLightShadowFilter sf = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    sf.setLight(dl);
    fpp.addFilter(sf);
    fpp.addFilter(new SSAOFilter());
    viewPort.addProcessor(fpp);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter) TextureKey(com.jme3.asset.TextureKey) ColorRGBA(com.jme3.math.ColorRGBA) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight)

Example 85 with KeyTrigger

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

the class TestParallaxPBR method simpleInitApp.

@Override
public void simpleInitApp() {
    cam.setLocation(new Vector3f(-15.445636f, 30.162927f, 60.252777f));
    cam.setRotation(new Quaternion(0.05173137f, 0.92363626f, -0.13454558f, 0.35513034f));
    flyCam.setMoveSpeed(30);
    setupLighting();
    setupSkyBox();
    setupFloor();
    setupSignpost();
    inputManager.addListener(new AnalogListener() {

        public void onAnalog(String name, float value, float tpf) {
            if ("heightUP".equals(name)) {
                parallaxHeigh += 0.01;
                mat.setFloat("ParallaxHeight", parallaxHeigh);
            }
            if ("heightDown".equals(name)) {
                parallaxHeigh -= 0.01;
                parallaxHeigh = Math.max(parallaxHeigh, 0);
                mat.setFloat("ParallaxHeight", parallaxHeigh);
            }
        }
    }, "heightUP", "heightDown");
    inputManager.addMapping("heightUP", new KeyTrigger(KeyInput.KEY_I));
    inputManager.addMapping("heightDown", new KeyTrigger(KeyInput.KEY_K));
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (isPressed && "toggleSteep".equals(name)) {
                steep = !steep;
                mat.setBoolean("SteepParallax", steep);
            }
        }
    }, "toggleSteep");
    inputManager.addMapping("toggleSteep", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) KeyTrigger(com.jme3.input.controls.KeyTrigger) 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