/** * @param dragToRotate When true, the user must hold the mouse button * and drag over the screen to rotate the camera, and the cursor is * visible until dragged. Otherwise, the cursor is invisible at all times * and holding the mouse button is not needed to rotate the camera. * This feature is disabled by default. */ public void setDragToRotate(boolean dragToRotate) { this.dragToRotate = dragToRotate; this.canRotate = !dragToRotate; inputManager.setCursorVisible(dragToRotate); }
/** * @param dragToRotate When true, the user must hold the mouse button and * drag over the screen to rotate the camera, and the cursor is visible * until dragged. Otherwise, the cursor is invisible at all times and * holding the mouse button is not needed to rotate the camera. This feature * is disabled by default. */ public void setDragToRotate(boolean dragToRotate) { this.dragToRotate = dragToRotate; this.canRotate = !dragToRotate; if(inputManager != null){ inputManager.setCursorVisible(dragToRotate); } }
/** * Enable or disable this controller. When disabled, the controller ignored * input. * * @param enable true to enable, false to disable */ public void setEnabled(boolean enable){ if (enabled && !enable){ if (inputManager!= null && (!dragToRotate || (dragToRotate && canRotate))){ inputManager.setCursorVisible(true); } } enabled = enable; }
/** * Enable or disable drag-to-rotate mode. * * When drag-to-rotate mode is enabled, the user must hold the mouse button * and drag over the screen to rotate the camera, and the cursor is visible * until dragged. When drag-to-rotate mode is disabled, the cursor is * invisible at all times and holding the mouse button is not needed to * rotate the camera. This mode is disabled by default. * * @param dragToRotate true to enable, false to disable */ public void setDragToRotate(boolean dragToRotate) { this.dragToRotate = dragToRotate; if (inputManager != null) { inputManager.setCursorVisible(dragToRotate); } }
public void onAction(String name, boolean keyPressed, float tpf) { //toggling rotation on or off if (name.equals("toggleRotate") && keyPressed) { rotate = true; inputManager.setCursorVisible(false); } if (name.equals("toggleRotate") && !keyPressed) { rotate = false; inputManager.setCursorVisible(true); } } }
@Override public void onAction(String name, boolean isPressed, float tpf) { if ("drag".equals(name)) { dragging = isPressed; inputManager.setCursorVisible(!isPressed); } } }
public void onAction(String name, boolean keyPressed, float tpf) { if (dragToRotate) { if (name.equals(CameraInput.CHASECAM_TOGGLEROTATE) && enabled) { if (keyPressed) { canRotate = true; if (hideCursorOnRotate) { inputManager.setCursorVisible(false); } } else { canRotate = false; if (hideCursorOnRotate) { inputManager.setCursorVisible(true); } } } } }
/** * Callback to notify this controller of an action input event. * * @param name name of the input event * @param value true if the action is "pressed", false otherwise * @param tpf time per frame (in seconds) */ @Override public void onAction(String name, boolean value, float tpf) { if (!enabled) return; if (name.equals(CameraInput.FLYCAM_ROTATEDRAG) && dragToRotate){ canRotate = value; inputManager.setCursorVisible(!value); } else if (name.equals(CameraInput.FLYCAM_INVERTY)) { // Invert the "up" direction. if( !value ) { invertY = !invertY; } } } }
public void onAction(String name, boolean keyPressed, float tpf) { if (isEnabled()) { if (dragToRotate) { if (name.equals(CameraInput.CHASECAM_TOGGLEROTATE) && isEnabled()) { if (keyPressed) { canRotate = true; if (hideCursorOnRotate) { inputManager.setCursorVisible(false); } } else { canRotate = false; if (hideCursorOnRotate) { inputManager.setCursorVisible(true); } } } } } }
public Void call(){ if (app instanceof SimpleApplication){ SimpleApplication simpleApp = (SimpleApplication) app; simpleApp.getFlyByCamera().setDragToRotate(true); simpleApp.getInputManager().setCursorVisible(true); } return null; } });
@Override public void simpleInitApp() { flyCam.setEnabled(false); // We need the cursor to be visible. If it is not visible the cursor // will still be "used" and loaded, you just won't see it on the screen. inputManager.setCursorVisible(true); /* * To make jME3 use a custom cursor it is as simple as putting the * .cur/.ico/.ani file in an asset directory. Here we use * "Textures/GUI/Cursors". * * For the purpose of this demonstration we load 3 different cursors and add them * into an array list and switch cursor every 8 seconds. * * The first ico has been made by Sirea and the set can be found here: * http://www.rw-designer.com/icon-set/nyan-cat * * The second cursor has been made by Virum64 and is Public Domain. * http://www.rw-designer.com/cursor-set/memes-faces-v64 * * The animated cursor has been made by Pointer Adic and can be found here: * http://www.rw-designer.com/cursor-set/monkey */ cursors.add((JmeCursor) assetManager.loadAsset("Textures/Cursors/meme.cur")); cursors.add((JmeCursor) assetManager.loadAsset("Textures/Cursors/nyancat.ico")); cursors.add((JmeCursor) assetManager.loadAsset("Textures/Cursors/monkey.ani")); sysTime = System.currentTimeMillis(); inputManager.setMouseCursor(cursors.get(count)); }
/** * Unregister this controller from its input manager. */ public void unregisterInput(){ if (inputManager == null) { return; } for (String s : mappings) { if (inputManager.hasMapping(s)) { inputManager.deleteMapping( s ); } } inputManager.removeListener(this); inputManager.setCursorVisible(!dragToRotate); Joystick[] joysticks = inputManager.getJoysticks(); if (joysticks != null && joysticks.length > 0){ // No way to unassign axis } }
@Override public void simpleInitApp() { clContext = null; NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay( assetManager, inputManager, audioRenderer, guiViewPort); nifty = niftyDisplay.getNifty(); nifty.fromXml("jme3test/opencl/ContextSwitchingScreen.xml", "Screen", this); guiViewPort.addProcessor(niftyDisplay); inputManager.setCursorVisible(true); flyCam.setEnabled(false); }
inputManager.setCursorVisible(true);
inputManager.setCursorVisible(true);
/** * Registers inputs with the input manager * */ public final void registerWithInput() { String[] inputs = {CameraInput.CHASECAM_TOGGLEROTATE, CameraInput.CHASECAM_DOWN, CameraInput.CHASECAM_UP, CameraInput.CHASECAM_MOVELEFT, CameraInput.CHASECAM_MOVERIGHT, CameraInput.CHASECAM_ZOOMIN, CameraInput.CHASECAM_ZOOMOUT}; initVerticalAxisInputs(); initZoomInput(); initHorizontalAxisInput(); initTogleRotateInput(); inputManager.addListener(this, inputs); inputManager.setCursorVisible(dragToRotate); }
@Override public void simpleInitApp() { inputManager.setCursorVisible(true);
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay( assetManager, inputManager, audioRenderer, guiViewPort); nifty = niftyDisplay.getNifty(); nifty.fromXml("Interface/Nifty/HelloJme.xml", "start", this); // attach the nifty display to the gui view port as a processor guiViewPort.addProcessor(niftyDisplay); // disable the fly cam // flyCam.setEnabled(false); // flyCam.setDragToRotate(true); inputManager.setCursorVisible(true); }
@Override public void simpleInitApp() { initOpenCL1(); tex = new Texture2D(settings.getWidth(), settings.getHeight(), 1, com.jme3.texture.Image.Format.RGBA8); Picture pic = new Picture("julia"); pic.setTexture(assetManager, tex, true); pic.setPosition(0, 0); pic.setWidth(settings.getWidth()); pic.setHeight(settings.getHeight()); guiNode.attachChild(pic); initCounter = 0; flyCam.setEnabled(false); inputManager.setCursorVisible(true); inputManager.addMapping("right", new MouseAxisTrigger(MouseInput.AXIS_X, false)); inputManager.addMapping("left", new MouseAxisTrigger(MouseInput.AXIS_X, true)); inputManager.addMapping("up", new MouseAxisTrigger(MouseInput.AXIS_Y, false)); inputManager.addMapping("down", new MouseAxisTrigger(MouseInput.AXIS_Y, true)); inputManager.addMapping("drag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(this, "right", "left", "up", "down", "drag"); dragging = false; }
inputManager.setCursorVisible(dragToRotate || !isEnabled());