/** * 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); }
public void onAnalog(String name, float value, float tpf) { if (isEnabled()) { if (canRotate) { if (name.equals(CameraInput.CHASECAM_MOVELEFT)) { horizontalRotation -= value * rotationSpeed; rotateCamera(); } else if (name.equals(CameraInput.CHASECAM_MOVERIGHT)) { horizontalRotation += value * rotationSpeed; rotateCamera(); } else if (name.equals(CameraInput.CHASECAM_UP)) { verticalRotation += value * rotationSpeed; rotateCamera(); } else if (name.equals(CameraInput.CHASECAM_DOWN)) { verticalRotation -= value * rotationSpeed; rotateCamera(); } } if (name.equals(CameraInput.CHASECAM_ZOOMIN)) { zoomCamera(-value * zoomSpeed); } else if (name.equals(CameraInput.CHASECAM_ZOOMOUT)) { zoomCamera(+value * zoomSpeed); } } }
ChaseCameraAppState chaseCam = new ChaseCameraAppState(); chaseCam.setTarget(target); getStateManager().attach(chaseCam); chaseCam.setInvertHorizontalAxis(true); chaseCam.setInvertVerticalAxis(true); chaseCam.setZoomSpeed(0.5f); chaseCam.setMinVerticalRotation(-FastMath.HALF_PI); chaseCam.setRotationSpeed(3); chaseCam.setDefaultDistance(3); chaseCam.setMinDistance(0.01f); chaseCam.setZoomSpeed(0.01f); chaseCam.setDefaultVerticalRotation(0.3f);
rootNode.attachChild(camTarget); ChaseCameraAppState chaser = new ChaseCameraAppState(); chaser.setTarget(camTarget); chaser.setMaxDistance(150); chaser.setDefaultDistance(70); chaser.setDefaultHorizontalRotation(FastMath.HALF_PI); chaser.setMinVerticalRotation(-FastMath.PI); chaser.setMaxVerticalRotation(FastMath.PI * 2); chaser.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); stateManager.attach(chaser); flyCam.setEnabled(false);
dl.setColor(ColorRGBA.White); ChaseCameraAppState chaser = new ChaseCameraAppState(); chaser.setDragToRotate(true); chaser.setMinVerticalRotation(-FastMath.HALF_PI); chaser.setMaxDistance(1000); chaser.setInvertVerticalAxis(true); getStateManager().attach(chaser); chaser.setTarget(rootNode); flyCam.setEnabled(false);
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.inputManager = app.getInputManager(); target = new Node("ChaseCamTarget"); camNode.setCamera(app.getCamera()); camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera); target.attachChild(camNode); camNode.setLocalTranslation(0, 0, distance); upVector = app.getCamera().getUp().clone(); leftVector = app.getCamera().getLeft().clone(); registerWithInput(); rotateCamera(); }
/** * Sets the max zoom distance of the camera (default is 40) * * @param maxDistance */ public void setMaxDistance(float maxDistance) { this.maxDistance = maxDistance; if(initialized){ zoomCamera(distance); } }
/** * Sets the minimal vertical rotation angle in radian of the camera around * the target default is 0; * * @param minHeight */ public void setMinVerticalRotation(float minHeight) { this.minVerticalRotation = minHeight; if(initialized){ rotateCamera(); } }
ChaseCameraAppState chaseCamAS = new ChaseCameraAppState(); chaseCamAS.setTarget(teaGeom); stateManager.attach(chaseCamAS);
/** * invert the vertical axis movement of the mouse * * @param invertYaxis */ public void setInvertVerticalAxis(boolean invertYaxis) { this.invertYaxis = invertYaxis; if (inputManager != null) { inputManager.deleteMapping(CameraInput.CHASECAM_DOWN); inputManager.deleteMapping(CameraInput.CHASECAM_UP); initVerticalAxisInputs(); inputManager.addListener(this, CameraInput.CHASECAM_DOWN, CameraInput.CHASECAM_UP); } }
/** * invert the Horizontal axis movement of the mouse * * @param invertXaxis */ public void setInvertHorizontalAxis(boolean invertXaxis) { this.invertXaxis = invertXaxis; if (inputManager != null) { inputManager.deleteMapping(CameraInput.CHASECAM_MOVELEFT); inputManager.deleteMapping(CameraInput.CHASECAM_MOVERIGHT); initHorizontalAxisInput(); inputManager.addListener(this, CameraInput.CHASECAM_MOVELEFT, CameraInput.CHASECAM_MOVERIGHT); } }
/** * Sets custom triggers for toggling the rotation of the cam default are * new MouseButtonTrigger(MouseInput.BUTTON_LEFT) left mouse button new * MouseButtonTrigger(MouseInput.BUTTON_RIGHT) right mouse button * * @param triggers */ public void setToggleRotationTrigger(Trigger... triggers) { toggleRotateTrigger = triggers; if (inputManager != null) { inputManager.deleteMapping(CameraInput.CHASECAM_TOGGLEROTATE); initTogleRotateInput(); inputManager.addListener(this, CameraInput.CHASECAM_TOGGLEROTATE); } }
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); } } } } } }
ChaseCameraAppState chaseCam = new ChaseCameraAppState(); chaseCam.setTarget(target); getStateManager().attach(chaseCam); chaseCam.setInvertHorizontalAxis(true); chaseCam.setInvertVerticalAxis(true); chaseCam.setZoomSpeed(0.5f); chaseCam.setMinVerticalRotation(-FastMath.HALF_PI); chaseCam.setRotationSpeed(3); chaseCam.setDefaultDistance(3); chaseCam.setMinDistance(0.01f); chaseCam.setZoomSpeed(0.01f); chaseCam.setDefaultVerticalRotation(0.3f);
rootNode.attachChild(camTarget); ChaseCameraAppState chaser = new ChaseCameraAppState(); chaser.setTarget(camTarget); chaser.setMaxDistance(150); chaser.setDefaultDistance(70); chaser.setDefaultHorizontalRotation(FastMath.HALF_PI); chaser.setMinVerticalRotation(-FastMath.PI); chaser.setMaxVerticalRotation(FastMath.PI * 2); chaser.setToggleRotationTrigger(new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); stateManager.attach(chaser); flyCam.setEnabled(false);
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.inputManager = app.getInputManager(); target = new Node("ChaseCamTarget"); camNode.setCamera(app.getCamera()); camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera); target.attachChild(camNode); camNode.setLocalTranslation(0, 0, distance); upVector = app.getCamera().getUp().clone(); leftVector = app.getCamera().getLeft().clone(); registerWithInput(); rotateCamera(); }
/** * Sets the min zoom distance of the camera (default is 1) * * @param minDistance */ public void setMinDistance(float minDistance) { this.minDistance = minDistance; if(initialized){ zoomCamera(distance); } }
/** * Sets the maximal vertical rotation angle in radian of the camera around * the target. Default is Pi/2; * * @param maxVerticalRotation */ public void setMaxVerticalRotation(float maxVerticalRotation) { this.maxVerticalRotation = maxVerticalRotation; if(initialized){ rotateCamera(); } }
ChaseCameraAppState chaser = new ChaseCameraAppState(); chaser.setTarget(aGeometry); getStateManager().attach(chaser);
/** * invert the vertical axis movement of the mouse * * @param invertYaxis */ public void setInvertVerticalAxis(boolean invertYaxis) { this.invertYaxis = invertYaxis; if (inputManager != null) { inputManager.deleteMapping(CameraInput.CHASECAM_DOWN); inputManager.deleteMapping(CameraInput.CHASECAM_UP); initVerticalAxisInputs(); inputManager.addListener(this, CameraInput.CHASECAM_DOWN, CameraInput.CHASECAM_UP); } }