com.jme3.input.KeyInput Java Examples
The following examples show how to use
com.jme3.input.KeyInput.
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: TestBloom.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initInputs() { inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE)); ActionListener acl = new ActionListener() { @Override public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("toggle") && keyPressed) { if(active){ active=false; viewPort.removeProcessor(fpp); }else{ active=true; viewPort.addProcessor(fpp); } } } }; inputManager.addListener(acl, "toggle"); }
Example #2
Source File: TestPosterization.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void initInputs() { 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(active){ active=false; viewPort.removeProcessor(fpp); }else{ active=true; viewPort.addProcessor(fpp); } } } }; inputManager.addListener(acl, "toggle"); }
Example #3
Source File: InputSystemJme.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void onKeyEventQueued(KeyInputEvent evt, NiftyInputConsumer nic) { int code = evt.getKeyCode(); if (code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT) { shiftDown = evt.isPressed(); } else if (code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL) { ctrlDown = evt.isPressed(); } KeyboardInputEvent keyEvt = new KeyboardInputEvent(code, evt.getKeyChar(), evt.isPressed(), shiftDown, ctrlDown); if (nic.processKeyboardEvent(keyEvt)){ evt.setConsumed(); } }
Example #4
Source File: TerrainTestCollision.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void setupKeys() { flyCam.setMoveSpeed(50); inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T)); inputManager.addListener(actionListener, "wireframe"); inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K)); inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U)); inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J)); inputManager.addMapping("Forwards", new KeyTrigger(KeyInput.KEY_Y)); inputManager.addMapping("Backs", new KeyTrigger(KeyInput.KEY_I)); inputManager.addListener(actionListener, "Lefts"); inputManager.addListener(actionListener, "Rights"); inputManager.addListener(actionListener, "Ups"); inputManager.addListener(actionListener, "Downs"); inputManager.addListener(actionListener, "Forwards"); inputManager.addListener(actionListener, "Backs"); inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(actionListener, "shoot"); inputManager.addMapping("cameraDown", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); inputManager.addListener(actionListener, "cameraDown"); }
Example #5
Source File: TestBitmapFont.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { inputManager.addMapping("WordWrap", new KeyTrigger(KeyInput.KEY_TAB)); inputManager.addListener(keyListener, "WordWrap"); inputManager.addRawInputListener(textListener); BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt"); txt = new BitmapText(fnt, false); txt.setBox(new Rectangle(0, 0, settings.getWidth(), settings.getHeight())); txt.setSize(fnt.getPreferredSize() * 2f); txt.setText(txtB); txt.setLocalTranslation(0, txt.getHeight(), 0); guiNode.attachChild(txt); txt2 = new BitmapText(fnt, false); txt2.setSize(fnt.getPreferredSize() * 1.2f); txt2.setText("Text without restriction. \nText without restriction. Text without restriction. Text without restriction"); txt2.setLocalTranslation(0, txt2.getHeight(), 0); guiNode.attachChild(txt2); txt3 = new BitmapText(fnt, false); txt3.setBox(new Rectangle(0, 0, settings.getWidth(), 0)); txt3.setText("Press Tab to toggle word-wrap. type text and enter to input text"); txt3.setLocalTranslation(0, settings.getHeight()/2, 0); guiNode.attachChild(txt3); }
Example #6
Source File: PbrSceneTest.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override public void simpleInitApp() { super.simpleInitApp(); SceneLoader.install(this, postProcessor); rootNode.attachChild(assetManager.loadModel("Scene/TestPbrScene.j3s")); getFlyByCamera().setMoveSpeed(5); getInputManager().addMapping("mouse", new KeyTrigger(KeyInput.KEY_SPACE)); getInputManager().addListener(new ActionListener() { @Override public void onAction(final String name, final boolean isPressed, final float tpf) { if (isPressed) { getFlyByCamera().setEnabled(!getFlyByCamera().isEnabled()); } } }, "mouse"); }
Example #7
Source File: TestJaime.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setupInput() { inputManager.addMapping("start", new KeyTrigger(KeyInput.KEY_PAUSE)); inputManager.addListener(new ActionListener() { @Override public void onAction(String name, boolean isPressed, float tpf) { if(name.equals("start") && isPressed){ if(cinematic.getPlayState() != PlayState.Playing){ cinematic.play(); }else{ cinematic.pause(); } } } }, "start"); }
Example #8
Source File: TestWalkingChar.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void setupKeys() { inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T)); inputManager.addListener(this, "wireframe"); inputManager.addMapping("CharLeft", new KeyTrigger(KeyInput.KEY_A)); inputManager.addMapping("CharRight", new KeyTrigger(KeyInput.KEY_D)); inputManager.addMapping("CharUp", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("CharDown", new KeyTrigger(KeyInput.KEY_S)); inputManager.addMapping("CharSpace", new KeyTrigger(KeyInput.KEY_RETURN)); inputManager.addMapping("CharShoot", new KeyTrigger(KeyInput.KEY_SPACE)); inputManager.addListener(this, "CharLeft"); inputManager.addListener(this, "CharRight"); inputManager.addListener(this, "CharUp"); inputManager.addListener(this, "CharDown"); inputManager.addListener(this, "CharSpace"); inputManager.addListener(this, "CharShoot"); }
Example #9
Source File: TestParallelProjection.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void simpleInitApp() { Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl); rootNode.attachChild(teaGeom); // Setup first view cam.setParallelProjection(true); float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); inputManager.addListener(this, "Size+", "Size-"); inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S)); }
Example #10
Source File: TestAnisotropicFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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"); }
Example #11
Source File: TestParallelProjection.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl); rootNode.attachChild(teaGeom); // Setup first view cam.setParallelProjection(true); float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); inputManager.addListener(this, "Size+", "Size-"); inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S)); }
Example #12
Source File: ArmatureDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void initialize(Application app) { vp = app.getRenderManager().createMainView("debug", app.getCamera()); vp.attachScene(debugNode); vp.setClearDepth(true); this.app = app; for (ArmatureDebugger armatureDebugger : armatures.values()) { armatureDebugger.initialize(app.getAssetManager(), app.getCamera()); } app.getInputManager().addListener(actionListener, "shoot", "toggleJoints"); app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT), new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); app.getInputManager().addMapping("toggleJoints", new KeyTrigger(KeyInput.KEY_F10)); debugNode.addLight(new DirectionalLight(new Vector3f(-1f, -1f, -1f).normalizeLocal())); debugNode.addLight(new DirectionalLight(new Vector3f(1f, 1f, 1f).normalizeLocal(), new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f))); vp.setEnabled(false); }
Example #13
Source File: TextEntryComponent.java From Lemur with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setSingleLine( boolean f ) { this.singleLine = f; if( singleLine ) { actionMap.put(new KeyAction(KeyInput.KEY_RETURN), FOCUS_NEXT); actionMap.put(new KeyAction(KeyInput.KEY_NUMPADENTER), FOCUS_NEXT); actionMap.put(new KeyAction(KeyInput.KEY_TAB), FOCUS_NEXT); actionMap.put(new KeyAction(KeyInput.KEY_TAB, KeyModifiers.SHIFT_DOWN), FOCUS_PREVIOUS); actionMap.put(new KeyAction(KeyInput.KEY_UP), FOCUS_UP); actionMap.put(new KeyAction(KeyInput.KEY_DOWN), FOCUS_DOWN); } else { actionMap.put(new KeyAction(KeyInput.KEY_RETURN), NEW_LINE); actionMap.put(new KeyAction(KeyInput.KEY_NUMPADENTER), NEW_LINE); // We may choose to do something different with tab someday... but // the user can also just remove the action if they like. actionMap.put(new KeyAction(KeyInput.KEY_TAB), FOCUS_NEXT); actionMap.put(new KeyAction(KeyInput.KEY_TAB, KeyModifiers.SHIFT_DOWN), FOCUS_PREVIOUS); actionMap.put(new KeyAction(KeyInput.KEY_UP), PREV_LINE); actionMap.put(new KeyAction(KeyInput.KEY_DOWN), NEXT_LINE); } }
Example #14
Source File: KeyInterceptState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void dispatch(KeyInputEvent evt) { if( !isEnabled() ) return; // Intercept for key modifiers int code = evt.getKeyCode(); if( code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT ) { setModifier(KeyModifiers.SHIFT_DOWN, evt.isPressed()); } if( code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL ) { setModifier(KeyModifiers.CONTROL_DOWN, evt.isPressed()); } if( code == KeyInput.KEY_LMENU || code == KeyInput.KEY_RMENU ) { setModifier(KeyModifiers.ALT_DOWN, evt.isPressed()); } ModifiedKeyInputEvent wrapper = null; for( KeyListener l : keyListeners.getArray() ) { // Only wrap if we will actually deliver if( wrapper == null ) { wrapper = new ModifiedKeyInputEvent(evt, modifiers); } l.onKeyEvent(wrapper); } }
Example #15
Source File: TestSimpleWater.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void initInput() { flyCam.setMoveSpeed(3); //init input inputManager.addMapping("use_water", new KeyTrigger(KeyInput.KEY_O)); inputManager.addListener(this, "use_water"); inputManager.addMapping("lightup", new KeyTrigger(KeyInput.KEY_T)); inputManager.addListener(this, "lightup"); inputManager.addMapping("lightdown", new KeyTrigger(KeyInput.KEY_G)); inputManager.addListener(this, "lightdown"); inputManager.addMapping("lightleft", new KeyTrigger(KeyInput.KEY_H)); inputManager.addListener(this, "lightleft"); inputManager.addMapping("lightright", new KeyTrigger(KeyInput.KEY_K)); inputManager.addListener(this, "lightright"); inputManager.addMapping("lightforward", new KeyTrigger(KeyInput.KEY_U)); inputManager.addListener(this, "lightforward"); inputManager.addMapping("lightback", new KeyTrigger(KeyInput.KEY_J)); inputManager.addListener(this, "lightback"); }
Example #16
Source File: TestRenderToTexture.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(3, 3, 3)); cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); //setup main scene Geometry quad = new Geometry("box", new Box(Vector3f.ZERO, 1,1,1)); Texture offTex = setupOffscreenView(); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", offTex); quad.setMaterial(mat); rootNode.attachChild(quad); inputManager.addMapping(TOGGLE_UPDATE, new KeyTrigger(KeyInput.KEY_SPACE)); inputManager.addListener(this, TOGGLE_UPDATE); }
Example #17
Source File: WorldOfInception.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
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"); }
Example #18
Source File: TestIssue801.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void simpleInitApp() { viewPort.setBackgroundColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1f)); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); rootNode.attachChild(geom); inputManager.addMapping("changeBpp", new KeyTrigger(KeyInput.KEY_P)); ActionListener listener = new ActionListener() { @Override public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("changeBpp") && keyPressed) { goWindowed(); } } }; inputManager.addListener(listener, "changeBpp"); }
Example #19
Source File: ComposerCameraController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onKeyEvent(KeyInputEvent kie) { //don't forget the super call super.onKeyEvent(kie); if (kie.isPressed()) { if (KeyInput.KEY_LSHIFT == kie.getKeyCode()) { forceCameraControls = true; } } else if (kie.isReleased()) { if (KeyInput.KEY_LSHIFT == kie.getKeyCode()) { forceCameraControls = false; } } }
Example #20
Source File: TestQ3.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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"); }
Example #21
Source File: OpenRTSApplication.java From OpenRTS with MIT License | 5 votes |
@Override public void initialize() { bulletAppState = new BulletAppState(); bulletAppState.startPhysics(); super.initialize(); guiNode.setQueueBucket(Bucket.Gui); guiNode.setCullHint(CullHint.Never); initTexts(); loadStatsView(); viewPort.attachScene(rootNode); guiViewPort.attachScene(guiNode); if (inputManager != null) { flyCam = new AzertyFlyByCamera(cam); flyCam.setMoveSpeed(1f); flyCam.registerWithInput(inputManager); if (context.getType() == Type.Display) { inputManager.addMapping("SIMPLEAPP_Exit", new KeyTrigger(KeyInput.KEY_ESCAPE)); } inputManager.addMapping("SIMPLEAPP_CameraPos", new KeyTrigger(KeyInput.KEY_C)); inputManager.addMapping("SIMPLEAPP_Memory", new KeyTrigger(KeyInput.KEY_M)); inputManager.addListener(actionListener, "SIMPLEAPP_Exit", "SIMPLEAPP_CameraPos", "SIMPLEAPP_Memory"); } // call user code simpleInitApp(); stateManager.attach(bulletAppState); getPhysicsSpace().addTickListener(this); }
Example #22
Source File: TestPointSprite.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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)); }
Example #23
Source File: TestBrickWall.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); bulletCollisionShape = new SphereCollisionShape(0.4f); brick = new Box(bLength, bHeight, bWidth); brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); initMaterial(); initWall(); initFloor(); initCrossHairs(); this.cam.setLocation(new Vector3f(0, 6f, 6f)); cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0)); cam.setFrustumFar(15); inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(actionListener, "shoot"); inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X)); inputManager.addListener(actionListener, "gc"); rootNode.setShadowMode(ShadowMode.Off); }
Example #24
Source File: TestBetterCharacter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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"); }
Example #25
Source File: TerrainCameraController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onKeyEvent(KeyInputEvent kie) { super.onKeyEvent(kie); if (kie.isPressed()) { if (KeyInput.KEY_LSHIFT == kie.getKeyCode()) { forceCameraControls = true; } } else if (kie.isReleased()) { if (KeyInput.KEY_LSHIFT == kie.getKeyCode()) { forceCameraControls = false; } } }
Example #26
Source File: TestMovingParticle.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { emit = new ParticleEmitter("Emitter", Type.Triangle, 300); emit.setGravity(0, 0, 0); emit.getParticleInfluencer().setVelocityVariation(1); emit.setLowLife(1); emit.setHighLife(1); emit.getParticleInfluencer() .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() { @Override 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)); }
Example #27
Source File: TerrainTestModifyHeight.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void setupKeys() { flyCam.setMoveSpeed(100); inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T)); inputManager.addListener(actionListener, "wireframe"); inputManager.addMapping("Raise", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(actionListener, "Raise"); inputManager.addMapping("Lower", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); inputManager.addListener(actionListener, "Lower"); }
Example #28
Source File: TerrainTestAdvanced.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
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"); }
Example #29
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 #30
Source File: TestTriangleCollision.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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" }); }