Package com.ardor3d.input.logical

Examples of com.ardor3d.input.logical.InputTrigger


        projectedGrid = new ProjectedGrid("ProjectedGrid", externalCamera, 100, 70, 0.01f, new WaterHeightGenerator(),
                _timer);
        _root.attachChild(projectedGrid);

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                projectedGrid.setFreezeUpdate(!projectedGrid.isFreezeUpdate());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() - 1);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                projectedGrid.setNrUpdateThreads(projectedGrid.getNrUpdateThreads() + 1);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                projectedGrid.setDrawDebug(!projectedGrid.isDrawDebug());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                projectedGrid.setDrawDebug(true);
                animateExternalCamera = !animateExternalCamera;
                updateText();
            }
View Full Code Here


        final BasicText repeatText = BasicText.createDefaultTextLabel("text", getWrapText(controller));
        repeatText.setTranslation(5, 10 + speedText.getHeight(), 0);
        _root.attachChild(repeatText);

        // Add a trigger to change the repeat type on the controller
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                switch (controller.getRepeatType()) {
                    case CLAMP:
                        controller.setRepeatType(RepeatType.CYCLE);
                        break;
                    case CYCLE:
                        controller.setRepeatType(RepeatType.WRAP);
                        break;
                    case WRAP:
                        controller.setRepeatType(RepeatType.CLAMP);
                        break;
                }
                repeatText.setText(getWrapText(controller));
            }
        }));

        // Add a slow down command
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.LBRACKET), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
                controller.setSpeed(getNewSpeed(false, controller));
                speedText.setText(getSpeedText(controller));
            }
        }));

        // Add a speed up command
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.RBRACKET), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
                controller.setSpeed(getNewSpeed(true, controller));
                speedText.setText(getSpeedText(controller));
            }
        }));
View Full Code Here

        keyText.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
        keyText.getSceneHints().setLightCombineMode(LightCombineMode.Off);
        keyText.setTranslation(new Vector3(10, 10, 0));
        _root.attachChild(keyText);

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                mode++;
                mode %= 3;
                switch (mode) {
                    case 0:
View Full Code Here

        // set the default as current
        manager.setActiveWidget(rotateWidget);

        // add triggers to change which widget is active
        manager.getLogicalLayer().registerTrigger(
                new InputTrigger(new KeyHeldCondition(Key.LSHIFT), new TriggerAction() {
                    @Override
                    public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                        manager.setActiveWidget(scaleWidget);
                    }
                }));
        manager.getLogicalLayer().registerTrigger(
                new InputTrigger(new KeyReleasedCondition(Key.LSHIFT), new TriggerAction() {
                    @Override
                    public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                        manager.setActiveWidget(rotateWidget);
                    }
                }));
        manager.getLogicalLayer().registerTrigger(
                new InputTrigger(new KeyHeldCondition(Key.LCONTROL), new TriggerAction() {
                    @Override
                    public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                        manager.setActiveWidget(moveWidget);
                    }
                }));
        manager.getLogicalLayer().registerTrigger(
                new InputTrigger(new KeyReleasedCondition(Key.LCONTROL), new TriggerAction() {
                    @Override
                    public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                        manager.setActiveWidget(rotateWidget);
                    }
                }));

        // add toggle for matrix mode on widgets.
        manager.getLogicalLayer().registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                rotateWidget.setInteractMatrix(rotateWidget.getInteractMatrix() == InteractMatrix.World ? InteractMatrix.Local
                        : InteractMatrix.World);
                rotateWidget.targetDataUpdated(manager);
                moveWidget.setInteractMatrix(rotateWidget.getInteractMatrix());
                moveWidget.targetDataUpdated(manager);
            }
        }));

        // add triggers to change which widget is active
        manager.getLogicalLayer().registerTrigger(
                new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
                    @Override
                    public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                        manager.getSpatialTarget().setRotation(Matrix3.IDENTITY);
                        manager.fireTargetDataUpdated();
                    }
View Full Code Here

        final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);

        logicalLayer.registerInput(canvas1, pl);

        logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.H), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (source != canvas1) {
                    return;
                }

                if (_showCursor1.get(canvas1)) {
                    mouseManager.setCursor(_cursor1);
                } else {
                    mouseManager.setCursor(_cursor2);
                }

                _showCursor1.put(canvas1, !_showCursor1.get(canvas1));
            }
        }));
        logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (source != canvas1) {
                    return;
                }

                mouseManager.setCursor(MouseCursor.SYSTEM_DEFAULT);
            }
        }));
        logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.G), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (source != canvas1) {
                    return;
                }
View Full Code Here

        textNodes.updateGeometricState(0.0);
        updateText();

        // Register keyboard triggers for manipulating example
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ZERO), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setDrawShaderDebug(!_pssmPass.isDrawShaderDebug());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _updateLight = !_updateLight;
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setUpdateMainCamera(!_pssmPass.isUpdateMainCamera());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setDrawDebug(!_pssmPass.isDrawDebug());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (_pssmPass.getNumOfSplits() > ParallelSplitShadowMapPass._MIN_SPLITS) {
                    _pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() - 1);
                    updateText();
                    _quadsDirty = true;
                }
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FIVE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (_pssmPass.getNumOfSplits() < ParallelSplitShadowMapPass._MAX_SPLITS) {
                    _pssmPass.setNumOfSplits(_pssmPass.getNumOfSplits() + 1);
                    updateText();
                    _quadsDirty = true;
                }
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SIX), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (_pssmPass.getShadowMapSize() > 1) {
                    _pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() / 2);
                    updateText();
                    _quadsDirty = true;
                }
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SEVEN), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (_pssmPass.getShadowMapSize() < 2048) {
                    _pssmPass.setShadowMapSize(_pssmPass.getShadowMapSize() * 2);
                    updateText();
                    _quadsDirty = true;
                }
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.EIGHT), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final double maxShadowDistance = _pssmPass.getMaxShadowDistance();
                if (maxShadowDistance > 200.0) {
                    _pssmPass.setMaxShadowDistance(maxShadowDistance - 100.0);
                    updateText();
                }
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.NINE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                final double maxShadowDistance = _pssmPass.getMaxShadowDistance();
                _pssmPass.setMaxShadowDistance(maxShadowDistance + 100.0);
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.U), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setNumOfSplits(1);
                _pssmPass.setShadowMapSize(1024);
                updateText();
                _quadsDirty = true;
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.I), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setNumOfSplits(3);
                _pssmPass.setShadowMapSize(512);
                updateText();
                _quadsDirty = true;
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setUseSceneTexturing(!_pssmPass.isUseSceneTexturing());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.K), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setUseObjectCullFace(!_pssmPass.isUseObjectCullFace());
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _pssmPass.setEnabled(!_pssmPass.isEnabled());
                updateText();
                _quadsDirty = true;
            }
View Full Code Here

                    .nextDouble() * 100.0 - 250.0));

            sphereBase.attachChild(sphere);
        }

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                vboMode = (vboMode + 1) % 3;
                if (vboMode == 0) {
                    t.setText("[SPACE] VBO Off");
                    sphereBase.getSceneHints().setDataMode(DataMode.Arrays);
View Full Code Here

        final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper);

        logicalLayer.registerInput(theCanvas, pl);

        logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.H), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (source != theCanvas) {
                    return;
                }

                if (_showCursor1.get(theCanvas)) {
                    mouseManager.setCursor(_cursor1);
                } else {
                    mouseManager.setCursor(_cursor2);
                }

                _showCursor1.put(theCanvas, !_showCursor1.get(theCanvas));
            }
        }));
        logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.J), new TriggerAction() {
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                if (source != theCanvas) {
                    return;
                }
View Full Code Here

        // widget.getHandle().setRenderState(_lightState);
        manager.addWidget(widget);
        manager.setActiveWidget(widget);

        // add toggle for matrix mode on widget
        manager.getLogicalLayer().registerTrigger(new InputTrigger(new KeyPressedCondition(Key.R), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                widget.setInteractMatrix(widget.getInteractMatrix() == InteractMatrix.World ? InteractMatrix.Local
                        : InteractMatrix.World);
                widget.targetDataUpdated(manager);
View Full Code Here

            hud.add(_exampleInfo[i]);
        }

        updateText();

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ONE), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(5);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.TWO), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(50);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.THREE), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(400);
                updateText();
            }
        }));
        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.FOUR), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                _controlHandle.setMoveSpeed(1000);
                updateText();
            }
        }));

        _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.SPACE), new TriggerAction() {
            @Override
            public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
                groundCamera = !groundCamera;
                updateText();
            }
View Full Code Here

TOP

Related Classes of com.ardor3d.input.logical.InputTrigger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.