Search in sources :

Example 61 with ActionListener

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

the class TestLineWidthRenderState method simpleInitApp.

@Override
public void simpleInitApp() {
    setDisplayFps(false);
    setDisplayStatView(false);
    cam.setLocation(new Vector3f(5.5826545f, 3.6192513f, 8.016988f));
    cam.setRotation(new Quaternion(-0.04787097f, 0.9463123f, -0.16569641f, -0.27339742f));
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    mat.getAdditionalRenderState().setWireframe(true);
    mat.getAdditionalRenderState().setLineWidth(2);
    geom.setMaterial(mat);
    rootNode.attachChild(geom);
    inputManager.addListener(new ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("up") && isPressed) {
                mat.getAdditionalRenderState().setLineWidth(mat.getAdditionalRenderState().getLineWidth() + 1);
            }
            if (name.equals("down") && isPressed) {
                mat.getAdditionalRenderState().setLineWidth(Math.max(mat.getAdditionalRenderState().getLineWidth() - 1, 1));
            }
        }
    }, "up", "down");
    inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_U));
    inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_J));
}
Also used : Geometry(com.jme3.scene.Geometry) ActionListener(com.jme3.input.controls.ActionListener) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 62 with ActionListener

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

the class TerrainTest method setupKeys.

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

Example 63 with ActionListener

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

the class TerrainTestAdvanced method setupKeys.

private void setupKeys() {
    flyCam.setMoveSpeed(50);
    inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
    inputManager.addListener(actionListener, "wireframe");
    inputManager.addMapping("triPlanar", new KeyTrigger(KeyInput.KEY_P));
    inputManager.addListener(actionListener, "triPlanar");
    inputManager.addMapping("WardIso", new KeyTrigger(KeyInput.KEY_9));
    inputManager.addListener(actionListener, "WardIso");
    inputManager.addMapping("DetachControl", new KeyTrigger(KeyInput.KEY_0));
    inputManager.addListener(actionListener, "DetachControl");
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger)

Example 64 with ActionListener

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

the class TerrainTestAndroid method setupKeys.

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

Example 65 with ActionListener

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

the class TestBatchNodeTower method simpleInitApp.

@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    batchNode.batch();
    batchNode.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(batchNode);
    shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    shadowRenderer.setLight(dl);
    shadowRenderer.setLambda(0.55f);
    shadowRenderer.setShadowIntensity(0.6f);
    shadowRenderer.setShadowCompareMode(CompareMode.Hardware);
    shadowRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(shadowRenderer);
    viewPort.addProcessor(fpp);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) NanoTimer(com.jme3.system.NanoTimer) Vector2f(com.jme3.math.Vector2f) BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter)

Aggregations

KeyTrigger (com.jme3.input.controls.KeyTrigger)50 ActionListener (com.jme3.input.controls.ActionListener)44 Vector3f (com.jme3.math.Vector3f)27 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)18 Geometry (com.jme3.scene.Geometry)16 DirectionalLight (com.jme3.light.DirectionalLight)15 Material (com.jme3.material.Material)14 Spatial (com.jme3.scene.Spatial)13 AnalogListener (com.jme3.input.controls.AnalogListener)11 Quaternion (com.jme3.math.Quaternion)11 FilterPostProcessor (com.jme3.post.FilterPostProcessor)10 Node (com.jme3.scene.Node)10 Sphere (com.jme3.scene.shape.Sphere)10 Box (com.jme3.scene.shape.Box)9 AmbientLight (com.jme3.light.AmbientLight)7 BitmapText (com.jme3.font.BitmapText)6 MouseAxisTrigger (com.jme3.input.controls.MouseAxisTrigger)5 ChaseCamera (com.jme3.input.ChaseCamera)4 ColorRGBA (com.jme3.math.ColorRGBA)4 Vector2f (com.jme3.math.Vector2f)4