Java Code Examples for com.jme3.input.InputManager#addListener()
The following examples show how to use
com.jme3.input.InputManager#addListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScreenshotAppState.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { if (!super.isInitialized()){ InputManager inputManager = app.getInputManager(); inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ)); inputManager.addListener(this, "ScreenShot"); List<ViewPort> vps = app.getRenderManager().getPostViews(); ViewPort last = vps.get(vps.size()-1); last.addProcessor(this); appName = app.getClass().getSimpleName(); } super.initialize(stateManager, app); }
Example 2
Source File: BattlefieldInputInterpreter.java From OpenRTS with MIT License | 6 votes |
@Override protected void registerInputs(InputManager inputManager) { inputManager.addMapping(SWITCH_CTRL_1, new KeyTrigger(KeyInput.KEY_F1)); inputManager.addMapping(SWITCH_CTRL_2, new KeyTrigger(KeyInput.KEY_F2)); inputManager.addMapping(SWITCH_CTRL_3, new KeyTrigger(KeyInput.KEY_F3)); inputManager.addMapping(SELECT, new MouseButtonTrigger(0)); inputManager.addMapping(ACTION, new MouseButtonTrigger(1)); inputManager.addMapping(MOVE_ATTACK, new KeyTrigger(KeyInput.KEY_A)); inputManager.addMapping(MULTIPLE_SELECTION, new KeyTrigger(KeyInput.KEY_LCONTROL), new KeyTrigger(KeyInput.KEY_RCONTROL)); inputManager.addMapping(HOLD, new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping(PAUSE, new KeyTrigger(KeyInput.KEY_SPACE)); inputManager.addListener(this, mappings); logger.info("battlefield controller online"); }
Example 3
Source File: GroundCameraManager.java From OpenRTS with MIT License | 6 votes |
@Override public void registerInputs(InputManager inputManager){ inputManager.addMapping(ROTATE_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false)); inputManager.addMapping(ROTATE_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true)); inputManager.addMapping(ROTATE_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true)); inputManager.addMapping(ROTATE_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false)); inputManager.addMapping(STRAFE_LEFT, new KeyTrigger(KeyInput.KEY_Q), new KeyTrigger(KeyInput.KEY_LEFT)); inputManager.addMapping(STRAFE_RIGHT, new KeyTrigger(KeyInput.KEY_D), new KeyTrigger(KeyInput.KEY_RIGHT)); inputManager.addMapping(MOVE_FOREWARD, new KeyTrigger(KeyInput.KEY_Z), new KeyTrigger(KeyInput.KEY_UP)); inputManager.addMapping(MOVE_BACKWARD, new KeyTrigger(KeyInput.KEY_S), new KeyTrigger(KeyInput.KEY_DOWN)); inputManager.addListener(this, mappings); }
Example 4
Source File: ScreenshotAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { if (!super.isInitialized()){ InputManager inputManager = app.getInputManager(); inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ)); inputManager.addListener(this, "ScreenShot"); List<ViewPort> vps = app.getRenderManager().getPostViews(); ViewPort last = vps.get(vps.size()-1); last.addProcessor(this); if (shotName == null) { shotName = app.getClass().getSimpleName(); } } super.initialize(stateManager, app); }
Example 5
Source File: AdvancedAbstractEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Register the analog listener. * * @param inputManager the input manager */ @JmeThread protected void registerAnalogListener(@NotNull final InputManager inputManager) { inputManager.addListener(analogListener, MOUSE_X_AXIS, MOUSE_X_AXIS_NEGATIVE, MOUSE_Y_AXIS, MOUSE_Y_AXIS_NEGATIVE, MOUSE_MOVE_CAMERA_X_AXIS, MOUSE_MOVE_CAMERA_X_AXIS_NEGATIVE, MOUSE_MOVE_CAMERA_Y_AXIS, MOUSE_MOVE_CAMERA_Y_AXIS_NEGATIVE); }
Example 6
Source File: GroundInputInterpreter.java From OpenRTS with MIT License | 5 votes |
@Override protected void registerInputs(InputManager inputManager) { inputManager.addMapping(SWITCH_CTRL_1, new KeyTrigger(KeyInput.KEY_F1)); inputManager.addMapping(SWITCH_CTRL_2, new KeyTrigger(KeyInput.KEY_F2)); inputManager.addMapping(SWITCH_CTRL_3, new KeyTrigger(KeyInput.KEY_F3)); inputManager.addListener(this, mappings); logger.info("Ground conroller online"); }
Example 7
Source File: IsometricCameraManager.java From OpenRTS with MIT License | 5 votes |
@Override public void registerInputs(InputManager inputManager){ inputManager.addMapping(STRAFE_NORTH, new KeyTrigger(KeyInput.KEY_UP)); inputManager.addMapping(STRAFE_SOUTH, new KeyTrigger(KeyInput.KEY_DOWN)); inputManager.addMapping(STRAFE_EAST, new KeyTrigger(KeyInput.KEY_RIGHT)); inputManager.addMapping(STRAFE_WEST, new KeyTrigger(KeyInput.KEY_LEFT)); inputManager.addMapping(ZOOM_IN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); inputManager.addMapping(ZOOM_OUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); inputManager.addListener(this, mappings); }
Example 8
Source File: ShadowTestUIManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ShadowTestUIManager(AssetManager assetManager,AbstractShadowRenderer plsr, AbstractShadowFilter plsf, Node guiNode, InputManager inputManager, ViewPort viewPort) { this.plsr = plsr; this.plsf = plsf; this.viewPort = viewPort; BitmapFont guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); shadowTypeText = createText(guiFont); shadowCompareText = createText(guiFont); shadowFilterText = createText(guiFont); shadowIntensityText = createText(guiFont); shadowTypeText.setText(TYPE_TEXT + "Processor"); shadowCompareText.setText(COMPARE_TEXT + (hardwareShadows ? "Hardware" : "Software")); shadowFilterText.setText(FILTERING_TEXT + plsr.getEdgeFilteringMode().toString()); shadowIntensityText.setText(INTENSITY_TEXT + plsr.getShadowIntensity()); shadowTypeText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 20, 0); shadowCompareText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 40, 0); shadowFilterText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 60, 0); shadowIntensityText.setLocalTranslation(10, viewPort.getCamera().getHeight() - 80, 0); guiNode.attachChild(shadowTypeText); guiNode.attachChild(shadowCompareText); guiNode.attachChild(shadowFilterText); guiNode.attachChild(shadowIntensityText); inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE)); inputManager.addMapping("changeFiltering", new KeyTrigger(KeyInput.KEY_F)); inputManager.addMapping("ShadowUp", new KeyTrigger(KeyInput.KEY_T)); inputManager.addMapping("ShadowDown", new KeyTrigger(KeyInput.KEY_G)); inputManager.addMapping("ThicknessUp", new KeyTrigger(KeyInput.KEY_Y)); inputManager.addMapping("ThicknessDown", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("toggleHW", new KeyTrigger(KeyInput.KEY_RETURN)); inputManager.addListener(this, "toggleHW", "toggle", "ShadowUp", "ShadowDown", "ThicknessUp", "ThicknessDown", "changeFiltering"); }
Example 9
Source File: AdvancedAbstractEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Register the action listener. * * @param inputManager the input manager */ @JmeThread protected void registerActionListener(@NotNull final InputManager inputManager) { inputManager.addListener(actionListener, MOUSE_RIGHT_CLICK, MOUSE_LEFT_CLICK, MOUSE_MIDDLE_CLICK); inputManager.addListener(actionListener, KEY_CTRL, KEY_SHIFT, KEY_ALT, KEY_CTRL_S, KEY_CTRL_Z, KEY_CTRL_Y, KEY_NUM_1, KEY_NUM_2, KEY_NUM_3, KEY_NUM_4, KEY_NUM_5, KEY_NUM_6, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9, KEY_FLY_CAMERA_W, KEY_FLY_CAMERA_S, KEY_FLY_CAMERA_A, KEY_FLY_CAMERA_D); }
Example 10
Source File: WaterUI.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public WaterUI(InputManager inputManager, SimpleWaterProcessor proc) { processor=proc; System.out.println("----------------- SSAO UI Debugger --------------------"); System.out.println("-- Water transparency : press Y to increase, H to decrease"); System.out.println("-- Water depth : press U to increase, J to decrease"); // System.out.println("-- AO scale : press I to increase, K to decrease"); // System.out.println("-- AO bias : press O to increase, P to decrease"); // System.out.println("-- Toggle AO on/off : press space bar"); // System.out.println("-- Use only AO : press Num pad 0"); // System.out.println("-- Output config declaration : press P"); System.out.println("-------------------------------------------------------"); inputManager.addMapping("transparencyUp", new KeyTrigger(KeyInput.KEY_Y)); inputManager.addMapping("transparencyDown", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("depthUp", new KeyTrigger(KeyInput.KEY_U)); inputManager.addMapping("depthDown", new KeyTrigger(KeyInput.KEY_J)); // inputManager.addMapping("scaleUp", new KeyTrigger(KeyInput.KEY_I)); // inputManager.addMapping("scaleDown", new KeyTrigger(KeyInput.KEY_K)); // inputManager.addMapping("biasUp", new KeyTrigger(KeyInput.KEY_O)); // inputManager.addMapping("biasDown", new KeyTrigger(KeyInput.KEY_L)); // inputManager.addMapping("outputConfig", new KeyTrigger(KeyInput.KEY_P)); // inputManager.addMapping("toggleUseAO", new KeyTrigger(KeyInput.KEY_SPACE)); // inputManager.addMapping("toggleUseOnlyAo", new KeyTrigger(KeyInput.KEY_NUMPAD0)); // ActionListener acl = new ActionListener() { // // public void onAction(String name, boolean keyPressed, float tpf) { // // if (name.equals("toggleUseAO") && keyPressed) { // ssaoConfig.setUseAo(!ssaoConfig.isUseAo()); // System.out.println("use AO : "+ssaoConfig.isUseAo()); // } // if (name.equals("toggleUseOnlyAo") && keyPressed) { // ssaoConfig.setUseOnlyAo(!ssaoConfig.isUseOnlyAo()); // System.out.println("use Only AO : "+ssaoConfig.isUseOnlyAo()); // // } // if (name.equals("outputConfig") && keyPressed) { // System.out.println("new SSAOConfig("+ssaoConfig.getSampleRadius()+"f,"+ssaoConfig.getIntensity()+"f,"+ssaoConfig.getScale()+"f,"+ssaoConfig.getBias()+"f,"+ssaoConfig.isUseOnlyAo()+","+ssaoConfig.isUseAo()+");"); // } // // } // }; AnalogListener anl = new AnalogListener() { @Override public void onAnalog(String name, float value, float tpf) { if (name.equals("transparencyUp")) { processor.setWaterTransparency(processor.getWaterTransparency()+0.001f); System.out.println("Water transparency : "+processor.getWaterTransparency()); } if (name.equals("transparencyDown")) { processor.setWaterTransparency(processor.getWaterTransparency()-0.001f); System.out.println("Water transparency : "+processor.getWaterTransparency()); } if (name.equals("depthUp")) { processor.setWaterDepth(processor.getWaterDepth()+0.001f); System.out.println("Water depth : "+processor.getWaterDepth()); } if (name.equals("depthDown")) { processor.setWaterDepth(processor.getWaterDepth()-0.001f); System.out.println("Water depth : "+processor.getWaterDepth()); } } }; // inputManager.addListener(acl,"toggleUseAO","toggleUseOnlyAo","outputConfig"); inputManager.addListener(anl, "transparencyUp","transparencyDown","depthUp","depthDown"); }
Example 11
Source File: BloomUI.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public BloomUI(InputManager inputManager, final BloomFilter filter) { System.out.println("----------------- Bloom UI Debugger --------------------"); System.out.println("-- blur Scale : press Y to increase, H to decrease"); System.out.println("-- exposure Power : press U to increase, J to decrease"); System.out.println("-- exposure CutOff : press I to increase, K to decrease"); System.out.println("-- bloom Intensity : press O to increase, P to decrease"); System.out.println("-------------------------------------------------------"); inputManager.addMapping("blurScaleUp", new KeyTrigger(KeyInput.KEY_Y)); inputManager.addMapping("blurScaleDown", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("exposurePowerUp", new KeyTrigger(KeyInput.KEY_U)); inputManager.addMapping("exposurePowerDown", new KeyTrigger(KeyInput.KEY_J)); inputManager.addMapping("exposureCutOffUp", new KeyTrigger(KeyInput.KEY_I)); inputManager.addMapping("exposureCutOffDown", new KeyTrigger(KeyInput.KEY_K)); inputManager.addMapping("bloomIntensityUp", new KeyTrigger(KeyInput.KEY_O)); inputManager.addMapping("bloomIntensityDown", new KeyTrigger(KeyInput.KEY_L)); AnalogListener anl = new AnalogListener() { @Override public void onAnalog(String name, float value, float tpf) { if (name.equals("blurScaleUp")) { filter.setBlurScale(filter.getBlurScale() + 0.01f); System.out.println("blurScale : " + filter.getBlurScale()); } if (name.equals("blurScaleDown")) { filter.setBlurScale(filter.getBlurScale() - 0.01f); System.out.println("blurScale : " + filter.getBlurScale()); } if (name.equals("exposurePowerUp")) { filter.setExposurePower(filter.getExposurePower() + 0.01f); System.out.println("exposurePower : " + filter.getExposurePower()); } if (name.equals("exposurePowerDown")) { filter.setExposurePower(filter.getExposurePower() - 0.01f); System.out.println("exposurePower : " + filter.getExposurePower()); } if (name.equals("exposureCutOffUp")) { filter.setExposureCutOff(Math.min(1.0f, Math.max(0.0f, filter.getExposureCutOff() + 0.001f))); System.out.println("exposure CutOff : " + filter.getExposureCutOff()); } if (name.equals("exposureCutOffDown")) { filter.setExposureCutOff(Math.min(1.0f, Math.max(0.0f, filter.getExposureCutOff() - 0.001f))); System.out.println("exposure CutOff : " + filter.getExposureCutOff()); } if (name.equals("bloomIntensityUp")) { filter.setBloomIntensity(filter.getBloomIntensity() + 0.01f); System.out.println("bloom Intensity : " + filter.getBloomIntensity()); } if (name.equals("bloomIntensityDown")) { filter.setBloomIntensity(filter.getBloomIntensity() - 0.01f); System.out.println("bloom Intensity : " + filter.getBloomIntensity()); } } }; inputManager.addListener(anl, "blurScaleUp", "blurScaleDown", "exposurePowerUp", "exposurePowerDown", "exposureCutOffUp", "exposureCutOffDown", "bloomIntensityUp", "bloomIntensityDown"); }
Example 12
Source File: AbstractSceneEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @JmeThread protected void registerActionListener(@NotNull final InputManager inputManager) { super.registerActionListener(inputManager); inputManager.addListener(actionListener, KEY_S, KEY_G, KEY_R, KEY_DEL); }
Example 13
Source File: EditorInputInterpreter.java From OpenRTS with MIT License | 4 votes |
@Override protected void registerInputs(InputManager inputManager) { inputManager.addMapping(SWITCH_CTRL_1, new KeyTrigger(KeyInput.KEY_F1)); inputManager.addMapping(SWITCH_CTRL_2, new KeyTrigger(KeyInput.KEY_F2)); inputManager.addMapping(SWITCH_CTRL_3, new KeyTrigger(KeyInput.KEY_F3)); inputManager.addMapping(PRIMARY_ACTION, new MouseButtonTrigger(0)); inputManager.addMapping(SECONDARY_ACTION, new MouseButtonTrigger(1)); inputManager.addMapping(TOGGLE_PENCIL_SHAPE, new KeyTrigger(KeyInput.KEY_A)); inputManager.addMapping(TOGGLE_PENCIL_MODE, new KeyTrigger(KeyInput.KEY_Z)); inputManager.addMapping(INC_SELECTOR_RADIUS, new KeyTrigger(KeyInput.KEY_Q)); inputManager.addMapping(DEC_SELECTOR_RADIUS, new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping(SET_CLIFF_TOOL, new KeyTrigger(KeyInput.KEY_1)); inputManager.addMapping(SET_HEIGHT_TOOL, new KeyTrigger(KeyInput.KEY_2)); inputManager.addMapping(SET_ATLAS_TOOL, new KeyTrigger(KeyInput.KEY_3)); inputManager.addMapping(SET_RAMP_TOOL, new KeyTrigger(KeyInput.KEY_4)); inputManager.addMapping(SET_UNIT_TOOL, new KeyTrigger(KeyInput.KEY_5)); inputManager.addMapping(TOGGLE_GRID, new KeyTrigger(KeyInput.KEY_G)); inputManager.addMapping(TOGGLE_SOWER, new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping(STEP_SOWER, new KeyTrigger(KeyInput.KEY_B)); inputManager.addMapping(TOGGLE_OPERATION, new KeyTrigger(KeyInput.KEY_E)); inputManager.addMapping(TOGGLE_SET, new KeyTrigger(KeyInput.KEY_D)); inputManager.addMapping(TOGGLE_LIGHT_COMP, new KeyTrigger(KeyInput.KEY_NUMPAD7)); inputManager.addMapping(INC_DAYTIME, new KeyTrigger(KeyInput.KEY_NUMPAD8)); inputManager.addMapping(DEC_DAYTIME, new KeyTrigger(KeyInput.KEY_NUMPAD5)); inputManager.addMapping(COMPASS_EAST, new KeyTrigger(KeyInput.KEY_NUMPAD6)); inputManager.addMapping(COMPASS_WEST, new KeyTrigger(KeyInput.KEY_NUMPAD4)); inputManager.addMapping(INC_INTENSITY, new KeyTrigger(KeyInput.KEY_ADD)); inputManager.addMapping(DEC_INTENSITY, new KeyTrigger(KeyInput.KEY_SUBTRACT)); inputManager.addMapping(TOGGLE_SPEED, new KeyTrigger(KeyInput.KEY_NUMPAD9)); inputManager.addMapping(DEC_RED, new KeyTrigger(KeyInput.KEY_NUMPAD1)); inputManager.addMapping(DEC_GREEN, new KeyTrigger(KeyInput.KEY_NUMPAD2)); inputManager.addMapping(DEC_BLUE, new KeyTrigger(KeyInput.KEY_NUMPAD3)); inputManager.addMapping(RESET_COLOR, new KeyTrigger(KeyInput.KEY_NUMPAD0)); inputManager.addMapping(SAVE, new KeyTrigger(KeyInput.KEY_F5)); inputManager.addMapping(LOAD, new KeyTrigger(KeyInput.KEY_F9)); inputManager.addMapping(NEW, new KeyTrigger(KeyInput.KEY_F12)); inputManager.addMapping(REPORT, new KeyTrigger(KeyInput.KEY_SPACE)); inputManager.addListener(this, mappings); }
Example 14
Source File: StaticCamera.java From OpenRTS with MIT License | 4 votes |
/** * Registers the FlyByCamera to receive input events from the provided * Dispatcher. * @param dispacher */ public void registerWithInput(InputManager inputManager){ this.inputManager = inputManager; String[] mappings = new String[]{ "FLYCAM_Left", "FLYCAM_Right", "FLYCAM_Up", "FLYCAM_Down", // "FLYCAM_ZoomIn", // "FLYCAM_ZoomOut", "FLYCAM_RotateDrag", }; // both mouse and button - rotation of cam inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true), new KeyTrigger(KeyInput.KEY_LEFT)); inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false), new KeyTrigger(KeyInput.KEY_RIGHT)); inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new KeyTrigger(KeyInput.KEY_UP)); inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true), new KeyTrigger(KeyInput.KEY_DOWN)); // mouse only - zoom in/out with wheel, and rotate drag // inputManager.addMapping("FLYCAM_ZoomIn", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // inputManager.addMapping("FLYCAM_ZoomOut", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); inputManager.addMapping("FLYCAM_RotateDrag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(this, mappings); inputManager.setCursorVisible(dragToRotate); Joystick[] joysticks = inputManager.getJoysticks(); if (joysticks != null && joysticks.length > 0){ Joystick joystick = joysticks[0]; joystick.assignAxis("FLYCAM_Right", "FLYCAM_Left", joystick.getXAxisIndex()); joystick.assignAxis("FLYCAM_Down", "FLYCAM_Up", joystick.getYAxisIndex()); } }
Example 15
Source File: AzertyFlyByCamera.java From OpenRTS with MIT License | 4 votes |
@Override public void registerWithInput(InputManager inputManager){ this.inputManager = inputManager; String[] mappings = new String[]{ "FLYCAM_Left", "FLYCAM_Right", "FLYCAM_Up", "FLYCAM_Down", "FLYCAM_StrafeLeft", "FLYCAM_StrafeRight", "FLYCAM_Forward", "FLYCAM_Backward", "FLYCAM_ZoomIn", "FLYCAM_ZoomOut", "FLYCAM_RotateDrag", "FLYCAM_Rise", "FLYCAM_Lower" }; // both mouse and button - rotation of cam inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true), new KeyTrigger(KeyInput.KEY_LEFT)); inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false), new KeyTrigger(KeyInput.KEY_RIGHT)); inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new KeyTrigger(KeyInput.KEY_UP)); inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true), new KeyTrigger(KeyInput.KEY_DOWN)); // mouse only - zoom in/out with wheel, and rotate drag inputManager.addMapping("FLYCAM_ZoomIn", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); inputManager.addMapping("FLYCAM_ZoomOut", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); inputManager.addMapping("FLYCAM_RotateDrag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); // keyboard only WASD for movement and WZ for rise/lower height inputManager.addMapping("FLYCAM_StrafeLeft", new KeyTrigger(KeyInput.KEY_Q)); inputManager.addMapping("FLYCAM_StrafeRight", new KeyTrigger(KeyInput.KEY_D)); inputManager.addMapping("FLYCAM_Forward", new KeyTrigger(KeyInput.KEY_Z)); inputManager.addMapping("FLYCAM_Backward", new KeyTrigger(KeyInput.KEY_S)); inputManager.addMapping("FLYCAM_Rise", new KeyTrigger(KeyInput.KEY_R)); inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_F)); inputManager.addListener(this, mappings); inputManager.setCursorVisible(dragToRotate); Joystick[] joysticks = inputManager.getJoysticks(); if (joysticks != null && joysticks.length > 0){ Joystick joystick = joysticks[0]; joystick.assignAxis("FLYCAM_StrafeRight", "FLYCAM_StrafeLeft", JoyInput.AXIS_POV_X); joystick.assignAxis("FLYCAM_Forward", "FLYCAM_Backward", JoyInput.AXIS_POV_Y); joystick.assignAxis("FLYCAM_Right", "FLYCAM_Left", joystick.getXAxisIndex()); joystick.assignAxis("FLYCAM_Down", "FLYCAM_Up", joystick.getYAxisIndex()); } }
Example 16
Source File: BaseMaterialEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @JmeThread protected void registerActionListener(@NotNull final InputManager inputManager) { super.registerActionListener(inputManager); inputManager.addListener(actionListener, KEY_S, KEY_C, KEY_P, KEY_L); }
Example 17
Source File: BloomUI.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public BloomUI(InputManager inputManager, final BloomFilter filter) { System.out.println("----------------- Bloom UI Debugger --------------------"); System.out.println("-- blur Scale : press Y to increase, H to decrease"); System.out.println("-- exposure Power : press U to increase, J to decrease"); System.out.println("-- exposure CutOff : press I to increase, K to decrease"); System.out.println("-- bloom Intensity : press O to increase, P to decrease"); System.out.println("-------------------------------------------------------"); inputManager.addMapping("blurScaleUp", new KeyTrigger(KeyInput.KEY_Y)); inputManager.addMapping("blurScaleDown", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("exposurePowerUp", new KeyTrigger(KeyInput.KEY_U)); inputManager.addMapping("exposurePowerDown", new KeyTrigger(KeyInput.KEY_J)); inputManager.addMapping("exposureCutOffUp", new KeyTrigger(KeyInput.KEY_I)); inputManager.addMapping("exposureCutOffDown", new KeyTrigger(KeyInput.KEY_K)); inputManager.addMapping("bloomIntensityUp", new KeyTrigger(KeyInput.KEY_O)); inputManager.addMapping("bloomIntensityDown", new KeyTrigger(KeyInput.KEY_L)); AnalogListener anl = new AnalogListener() { public void onAnalog(String name, float value, float tpf) { if (name.equals("blurScaleUp")) { filter.setBlurScale(filter.getBlurScale() + 0.01f); System.out.println("blurScale : " + filter.getBlurScale()); } if (name.equals("blurScaleDown")) { filter.setBlurScale(filter.getBlurScale() - 0.01f); System.out.println("blurScale : " + filter.getBlurScale()); } if (name.equals("exposurePowerUp")) { filter.setExposurePower(filter.getExposurePower() + 0.01f); System.out.println("exposurePower : " + filter.getExposurePower()); } if (name.equals("exposurePowerDown")) { filter.setExposurePower(filter.getExposurePower() - 0.01f); System.out.println("exposurePower : " + filter.getExposurePower()); } if (name.equals("exposureCutOffUp")) { filter.setExposureCutOff(Math.min(1.0f, Math.max(0.0f, filter.getExposureCutOff() + 0.001f))); System.out.println("exposure CutOff : " + filter.getExposureCutOff()); } if (name.equals("exposureCutOffDown")) { filter.setExposureCutOff(Math.min(1.0f, Math.max(0.0f, filter.getExposureCutOff() - 0.001f))); System.out.println("exposure CutOff : " + filter.getExposureCutOff()); } if (name.equals("bloomIntensityUp")) { filter.setBloomIntensity(filter.getBloomIntensity() + 0.01f); System.out.println("bloom Intensity : " + filter.getBloomIntensity()); } if (name.equals("bloomIntensityDown")) { filter.setBloomIntensity(filter.getBloomIntensity() - 0.01f); System.out.println("bloom Intensity : " + filter.getBloomIntensity()); } } }; inputManager.addListener(anl, "blurScaleUp", "blurScaleDown", "exposurePowerUp", "exposurePowerDown", "exposureCutOffUp", "exposureCutOffDown", "bloomIntensityUp", "bloomIntensityDown"); }
Example 18
Source File: WaterUI.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public WaterUI(InputManager inputManager, SimpleWaterProcessor proc) { processor=proc; System.out.println("----------------- SSAO UI Debugger --------------------"); System.out.println("-- Water transparency : press Y to increase, H to decrease"); System.out.println("-- Water depth : press U to increase, J to decrease"); // System.out.println("-- AO scale : press I to increase, K to decrease"); // System.out.println("-- AO bias : press O to increase, P to decrease"); // System.out.println("-- Toggle AO on/off : press space bar"); // System.out.println("-- Use only AO : press Num pad 0"); // System.out.println("-- Output config declaration : press P"); System.out.println("-------------------------------------------------------"); inputManager.addMapping("transparencyUp", new KeyTrigger(KeyInput.KEY_Y)); inputManager.addMapping("transparencyDown", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("depthUp", new KeyTrigger(KeyInput.KEY_U)); inputManager.addMapping("depthDown", new KeyTrigger(KeyInput.KEY_J)); // inputManager.addMapping("scaleUp", new KeyTrigger(KeyInput.KEY_I)); // inputManager.addMapping("scaleDown", new KeyTrigger(KeyInput.KEY_K)); // inputManager.addMapping("biasUp", new KeyTrigger(KeyInput.KEY_O)); // inputManager.addMapping("biasDown", new KeyTrigger(KeyInput.KEY_L)); // inputManager.addMapping("outputConfig", new KeyTrigger(KeyInput.KEY_P)); // inputManager.addMapping("toggleUseAO", new KeyTrigger(KeyInput.KEY_SPACE)); // inputManager.addMapping("toggleUseOnlyAo", new KeyTrigger(KeyInput.KEY_NUMPAD0)); // ActionListener acl = new ActionListener() { // // public void onAction(String name, boolean keyPressed, float tpf) { // // if (name.equals("toggleUseAO") && keyPressed) { // ssaoConfig.setUseAo(!ssaoConfig.isUseAo()); // System.out.println("use AO : "+ssaoConfig.isUseAo()); // } // if (name.equals("toggleUseOnlyAo") && keyPressed) { // ssaoConfig.setUseOnlyAo(!ssaoConfig.isUseOnlyAo()); // System.out.println("use Only AO : "+ssaoConfig.isUseOnlyAo()); // // } // if (name.equals("outputConfig") && keyPressed) { // System.out.println("new SSAOConfig("+ssaoConfig.getSampleRadius()+"f,"+ssaoConfig.getIntensity()+"f,"+ssaoConfig.getScale()+"f,"+ssaoConfig.getBias()+"f,"+ssaoConfig.isUseOnlyAo()+","+ssaoConfig.isUseAo()+");"); // } // // } // }; AnalogListener anl = new AnalogListener() { public void onAnalog(String name, float value, float tpf) { if (name.equals("transparencyUp")) { processor.setWaterTransparency(processor.getWaterTransparency()+0.001f); System.out.println("Water transparency : "+processor.getWaterTransparency()); } if (name.equals("transparencyDown")) { processor.setWaterTransparency(processor.getWaterTransparency()-0.001f); System.out.println("Water transparency : "+processor.getWaterTransparency()); } if (name.equals("depthUp")) { processor.setWaterDepth(processor.getWaterDepth()+0.001f); System.out.println("Water depth : "+processor.getWaterDepth()); } if (name.equals("depthDown")) { processor.setWaterDepth(processor.getWaterDepth()-0.001f); System.out.println("Water depth : "+processor.getWaterDepth()); } } }; // inputManager.addListener(acl,"toggleUseAO","toggleUseOnlyAo","outputConfig"); inputManager.addListener(anl, "transparencyUp","transparencyDown","depthUp","depthDown"); }