protected Vec4 getSurfacePoint(LatLon latlon, double elevation) { Vec4 point = null; SceneController sc = this.getApp().getWwd().getSceneController(); Globe globe = this.getApp().getWwd().getModel().getGlobe(); if (sc.getTerrain() != null) { point = sc.getTerrain() .getSurfacePoint( latlon.getLatitude(), latlon.getLongitude(), elevation * sc.getVerticalExaggeration()); } if (point == null) { double e = globe.getElevation(latlon.getLatitude(), latlon.getLongitude()); point = globe.computePointFromPosition( latlon.getLatitude(), latlon.getLongitude(), (e + elevation) * sc.getVerticalExaggeration()); } return point; }
protected Vec4 getPoint(LatLon latlon, double elevation) { SceneController sc = this.getApp().getWwd().getSceneController(); Globe globe = this.getApp().getWwd().getModel().getGlobe(); double e = globe.getElevation(latlon.getLatitude(), latlon.getLongitude()); return globe.computePointFromPosition( latlon.getLatitude(), latlon.getLongitude(), (e + elevation) * sc.getVerticalExaggeration()); }
protected void updateView(ScreenAnnotation control, String controlType) { if (this.wwd == null) return; if (!(this.wwd.getView() instanceof OrbitView)) return; OrbitView view = (OrbitView) this.wwd.getView(); view.stopAnimations(); view.stopMovement(); if (controlType.equals(AVKey.VIEW_PAN)) { resetOrbitView(view); // Go some distance in the control mouse direction Angle heading = computePanHeading(view, control); Angle distance = computePanAmount(this.wwd.getModel().getGlobe(), view, control, panStep); LatLon newViewCenter = LatLon.greatCircleEndPosition(view.getCenterPosition(), heading, distance); // Turn around if passing by a pole - TODO: better handling of the pole crossing situation if (this.isPathCrossingAPole(newViewCenter, view.getCenterPosition())) view.setHeading(Angle.POS180.subtract(view.getHeading())); // Set new center pos view.setCenterPosition(new Position(newViewCenter, view.getCenterPosition().getElevation())); } else if (controlType.equals(AVKey.VIEW_LOOK)) { setupFirstPersonView(view); Angle heading = computeLookHeading(view, control, headingStep); Angle pitch = computeLookPitch(view, control, pitchStep); // Check whether the view will still point at terrain Vec4 surfacePoint = computeSurfacePoint(view, heading, pitch); if (surfacePoint != null) { // Change view state final Position eyePos = view.getEyePosition(); // Save current eye position view.setHeading(heading); view.setPitch(pitch); view.setZoom(0); view.setCenterPosition(eyePos); // Set center at the eye position } } else if (controlType.equals(AVKey.VIEW_ZOOM_IN)) { resetOrbitView(view); view.setZoom(computeNewZoom(view, -zoomStep)); } else if (controlType.equals(AVKey.VIEW_ZOOM_OUT)) { resetOrbitView(view); view.setZoom(computeNewZoom(view, zoomStep)); } else if (controlType.equals(AVKey.VIEW_HEADING_LEFT)) { resetOrbitView(view); view.setHeading(view.getHeading().addDegrees(headingStep)); } else if (controlType.equals(AVKey.VIEW_HEADING_RIGHT)) { resetOrbitView(view); view.setHeading(view.getHeading().addDegrees(-headingStep)); } else if (controlType.equals(AVKey.VIEW_PITCH_UP)) { resetOrbitView(view); if (view.getPitch().degrees >= pitchStep) view.setPitch(view.getPitch().addDegrees(-pitchStep)); } else if (controlType.equals(AVKey.VIEW_PITCH_DOWN)) { resetOrbitView(view); if (view.getPitch().degrees <= 90 - pitchStep) view.setPitch(view.getPitch().addDegrees(pitchStep)); } else if (controlType.equals(AVKey.VIEW_FOV_NARROW)) { if (view.getFieldOfView().degrees / fovStep >= 4) view.setFieldOfView(view.getFieldOfView().divide(fovStep)); } else if (controlType.equals(AVKey.VIEW_FOV_WIDE)) { if (view.getFieldOfView().degrees * fovStep < 120) view.setFieldOfView(view.getFieldOfView().multiply(fovStep)); } else if (controlType.equals(AVKey.VERTICAL_EXAGGERATION_UP)) { SceneController sc = this.wwd.getSceneController(); sc.setVerticalExaggeration(sc.getVerticalExaggeration() + this.veStep); } else if (controlType.equals(AVKey.VERTICAL_EXAGGERATION_DOWN)) { SceneController sc = this.wwd.getSceneController(); sc.setVerticalExaggeration(Math.max(1d, sc.getVerticalExaggeration() - this.veStep)); } view.firePropertyChange(AVKey.VIEW, null, view); }