Search in sources :

Example 36 with KeyTrigger

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

the class TestBetterCharacter method setupKeys.

private void setupKeys() {
    inputManager.addMapping("Strafe Left", new KeyTrigger(KeyInput.KEY_U), new KeyTrigger(KeyInput.KEY_Z));
    inputManager.addMapping("Strafe Right", new KeyTrigger(KeyInput.KEY_O), new KeyTrigger(KeyInput.KEY_X));
    inputManager.addMapping("Rotate Left", new KeyTrigger(KeyInput.KEY_J), new KeyTrigger(KeyInput.KEY_LEFT));
    inputManager.addMapping("Rotate Right", new KeyTrigger(KeyInput.KEY_L), new KeyTrigger(KeyInput.KEY_RIGHT));
    inputManager.addMapping("Walk Forward", new KeyTrigger(KeyInput.KEY_I), new KeyTrigger(KeyInput.KEY_UP));
    inputManager.addMapping("Walk Backward", new KeyTrigger(KeyInput.KEY_K), new KeyTrigger(KeyInput.KEY_DOWN));
    inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_F), new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("Duck", new KeyTrigger(KeyInput.KEY_G), new KeyTrigger(KeyInput.KEY_LSHIFT), new KeyTrigger(KeyInput.KEY_RSHIFT));
    inputManager.addMapping("Lock View", 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, "Jump", "Duck", "Lock View");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 37 with KeyTrigger

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

the class TestPhysicsHingeJoint method setupKeys.

private void setupKeys() {
    inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_H));
    inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_K));
    inputManager.addMapping("Swing", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addListener(this, "Left", "Right", "Swing");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 38 with KeyTrigger

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

the class TerrainTestTile method setupKeys.

private void setupKeys() {
    flyCam.setMoveSpeed(100);
    inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
    inputManager.addListener(actionListener, "wireframe");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 39 with KeyTrigger

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

the class TestAnisotropicFilter method simpleInitApp.

@Override
public void simpleInitApp() {
    maxAniso = renderer.getLimits().get(Limits.TextureAnisotropy);
    flyCam.setDragToRotate(true);
    flyCam.setMoveSpeed(100);
    cam.setLocation(new Vector3f(197.02617f, 4.6769195f, -194.89545f));
    cam.setRotation(new Quaternion(0.07921988f, 0.8992258f, -0.18292196f, 0.38943136f));
    Quad q = new Quad(1000, 1000);
    q.scaleTextureCoordinates(new Vector2f(1000, 1000));
    Geometry geom = new Geometry("quad", q);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.setMaterial(createCheckerBoardMaterial(assetManager));
    rootNode.attachChild(geom);
    inputManager.addMapping("higher", new KeyTrigger(KeyInput.KEY_1));
    inputManager.addMapping("lower", new KeyTrigger(KeyInput.KEY_2));
    inputManager.addListener(this, "higher");
    inputManager.addListener(this, "lower");
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Quaternion(com.jme3.math.Quaternion) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 40 with KeyTrigger

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

the class TestDepthStencil method simpleInitApp.

@Override
public void simpleInitApp() {
    int w = settings.getWidth();
    int h = settings.getHeight();
    //setup framebuffer
    fb = new FrameBuffer(w, h, 1);
    Texture2D fbTex = new Texture2D(w, h, Format.RGB8);
    fb.setDepthBuffer(Format.Depth24Stencil8);
    fb.setColorTexture(fbTex);
    // setup framebuffer's scene
    Sphere sphMesh = new Sphere(20, 20, 1);
    Material solidColor = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    final Geometry sphere = new Geometry("sphere", sphMesh);
    sphere.setMaterial(solidColor);
    fbNode.attachChild(sphere);
    sphere.addControl(new AbstractControl() {

        @Override
        protected void controlUpdate(float tpf) {
            Material mat = sphere.getMaterial();
            mat.getAdditionalRenderState().setStencil(enableStencil, RenderState.StencilOperation.Keep, RenderState.StencilOperation.Keep, RenderState.StencilOperation.Keep, RenderState.StencilOperation.Keep, RenderState.StencilOperation.Keep, RenderState.StencilOperation.Keep, RenderState.TestFunction.Never, RenderState.TestFunction.Never);
        }

        @Override
        protected void controlRender(RenderManager rm, ViewPort vp) {
        }
    });
    //setup main scene
    Picture p = new Picture("Picture");
    p.setPosition(0, 0);
    p.setWidth(w);
    p.setHeight(h);
    p.setTexture(assetManager, fbTex, false);
    rootNode.attachChild(p);
    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 (enableStencil) {
                    enableStencil = false;
                    System.out.println("Stencil Enabled (model should be hidden)");
                } else {
                    enableStencil = true;
                    System.out.println("Stencil Disabled (model should be visible)");
                }
            }
        }
    };
    inputManager.addListener(acl, "toggle");
    System.out.println("Press space to toggle stencil");
}
Also used : Texture2D(com.jme3.texture.Texture2D) KeyTrigger(com.jme3.input.controls.KeyTrigger) AbstractControl(com.jme3.scene.control.AbstractControl) Material(com.jme3.material.Material) FrameBuffer(com.jme3.texture.FrameBuffer) Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) ActionListener(com.jme3.input.controls.ActionListener) Picture(com.jme3.ui.Picture) ViewPort(com.jme3.renderer.ViewPort) RenderManager(com.jme3.renderer.RenderManager)

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