Search in sources :

Example 26 with KeyTrigger

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

the class WorldOfInception method setupKeys.

private void setupKeys() {
    inputManager.addMapping("StrafeLeft", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("StrafeRight", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("Back", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("StrafeUp", new KeyTrigger(KeyInput.KEY_Q));
    inputManager.addMapping("StrafeDown", new KeyTrigger(KeyInput.KEY_Z), new KeyTrigger(KeyInput.KEY_Y));
    inputManager.addMapping("Space", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("Return", new KeyTrigger(KeyInput.KEY_RETURN));
    inputManager.addMapping("Esc", new KeyTrigger(KeyInput.KEY_ESCAPE));
    inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_UP));
    inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_DOWN));
    inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_LEFT));
    inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_RIGHT));
    inputManager.addListener(this, "StrafeLeft", "StrafeRight", "Forward", "Back", "StrafeUp", "StrafeDown", "Space", "Reset", "Esc", "Up", "Down", "Left", "Right");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 27 with KeyTrigger

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

the class TestTriangleCollision method simpleInitApp.

@Override
public void simpleInitApp() {
    // Create two boxes
    Mesh mesh1 = new Box(0.5f, 0.5f, 0.5f);
    geom1 = new Geometry("Box", mesh1);
    geom1.move(2, 2, -.5f);
    Material m1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m1.setColor("Color", ColorRGBA.Blue);
    geom1.setMaterial(m1);
    rootNode.attachChild(geom1);
    // load a character from jme3test-test-data
    golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.scale(0.5f);
    golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);
    // We must add a light to make the model visible
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    golem.addLight(sun);
    rootNode.attachChild(golem);
    // Create input
    inputManager.addMapping("MoveRight", new KeyTrigger(KeyInput.KEY_L));
    inputManager.addMapping("MoveLeft", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addMapping("MoveUp", new KeyTrigger(KeyInput.KEY_I));
    inputManager.addMapping("MoveDown", new KeyTrigger(KeyInput.KEY_K));
    inputManager.addListener(analogListener, new String[] { "MoveRight", "MoveLeft", "MoveUp", "MoveDown" });
}
Also used : Geometry(com.jme3.scene.Geometry) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) Mesh(com.jme3.scene.Mesh) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 28 with KeyTrigger

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

the class TestMovingParticle method simpleInitApp.

@Override
public void simpleInitApp() {
    emit = new ParticleEmitter("Emitter", Type.Triangle, 300);
    emit.setGravity(0, 0, 0);
    emit.setVelocityVariation(1);
    emit.setLowLife(1);
    emit.setHighLife(1);
    emit.setInitialVelocity(new Vector3f(0, .5f, 0));
    emit.setImagesX(15);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    rootNode.attachChild(emit);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if ("setNum".equals(name) && isPressed) {
                emit.setNumParticles(1000);
            }
        }
    }, "setNum");
    inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ActionListener(com.jme3.input.controls.ActionListener) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) Material(com.jme3.material.Material)

Example 29 with KeyTrigger

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

the class TestPointSprite method simpleInitApp.

@Override
public void simpleInitApp() {
    final ParticleEmitter emit = new ParticleEmitter("Emitter", Type.Point, 10000);
    emit.setShape(new EmitterBoxShape(new Vector3f(-1.8f, -1.8f, -1.8f), new Vector3f(1.8f, 1.8f, 1.8f)));
    emit.setGravity(0, 0, 0);
    emit.setLowLife(60);
    emit.setHighLife(60);
    emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
    emit.setImagesX(15);
    emit.setStartSize(0.05f);
    emit.setEndSize(0.05f);
    emit.setStartColor(ColorRGBA.White);
    emit.setEndColor(ColorRGBA.White);
    emit.setSelectRandomImage(true);
    emit.emitAllParticles();
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setBoolean("PointSprite", true);
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    rootNode.attachChild(emit);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if ("setNum".equals(name) && isPressed) {
                emit.setNumParticles(5000);
                emit.emitAllParticles();
            }
        }
    }, "setNum");
    inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
}
Also used : ParticleEmitter(com.jme3.effect.ParticleEmitter) ActionListener(com.jme3.input.controls.ActionListener) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) EmitterBoxShape(com.jme3.effect.shapes.EmitterBoxShape) Material(com.jme3.material.Material)

Example 30 with KeyTrigger

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

the class TestQ3 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.addListener(this, "Lefts");
    inputManager.addListener(this, "Rights");
    inputManager.addListener(this, "Ups");
    inputManager.addListener(this, "Downs");
    inputManager.addListener(this, "Space");
}
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