public LookAt getAsLookAt(Globe globe, LookAt result) { if (globe == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Navigator", "getAsLookAt", "missingGlobe")); } if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Navigator", "getAsLookAt", "missingResult")); } this.getAsCamera(globe, this.scratchCamera); // get this navigator's properties as a Camera this.cameraToLookAt(globe, this.scratchCamera, result); // convert the Camera to a LookAt return result; }
public Matrix4 getAsViewingMatrix(Globe globe, Matrix4 result) { if (globe == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Navigator", "getAsViewingMatrix", "missingGlobe")); } if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Navigator", "getAsViewingMatrix", "missingResult")); } this.getAsCamera(globe, this.scratchCamera); // get this navigator's properties as a Camera this.cameraToViewingMatrix(globe, this.scratchCamera, result); // convert the Camera to a viewing matrix return result; }
/** * Saves the Navigator's camera data to a SharedPreferences object. */ protected void saveNavigatorState() { WorldWindow wwd = this.getWorldWindow(); if (wwd != null) { SharedPreferences preferences = this.getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); // Write an identifier to the preferences for this session; editor.putLong(SESSION_TIMESTAMP, getSessionTimestamp()); // Write the camera data Camera camera = wwd.getNavigator().getAsCamera(wwd.getGlobe(), new Camera()); editor.putFloat(CAMERA_LATITUDE, (float) camera.latitude); editor.putFloat(CAMERA_LONGITUDE, (float) camera.longitude); editor.putFloat(CAMERA_ALTITUDE, (float) camera.altitude); editor.putFloat(CAMERA_HEADING, (float) camera.heading); editor.putFloat(CAMERA_TILT, (float) camera.tilt); editor.putFloat(CAMERA_ROLL, (float) camera.roll); editor.putInt(CAMERA_ALTITUDE_MODE, camera.altitudeMode); editor.apply(); } }
@Override protected void gestureDidBegin() { if (this.activeGestures++ == 0) { this.wwd.getNavigator().getAsCamera(this.wwd.getGlobe(), this.beginCamera); this.camera.set(this.beginCamera); } }
@Override public void onNavigatorEvent(WorldWindow wwd, NavigatorEvent event) { long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - lastEventTime; int eventAction = event.getAction(); boolean receivedUserInput = (eventAction == WorldWind.NAVIGATOR_MOVED && event.getLastInputEvent() != null); // Update the status overlay views whenever the navigator stops moving, // and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz. if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) { // Get the current navigator state to apply to the overlays event.getNavigator().getAsLookAt(wwd.getGlobe(), lookAt); event.getNavigator().getAsCamera(wwd.getGlobe(), camera); // Update the overlays updateOverlayContents(lookAt, camera); updateOverlayColor(eventAction); lastEventTime = currentTime; } // Show the crosshairs while the user is gesturing and fade them out after the user stops if (receivedUserInput) { showCrosshairs(); } else { fadeCrosshairs(); } } };
@Override public void onNavigatorEvent(WorldWindow wwd, NavigatorEvent event) { long currentTime = System.currentTimeMillis(); long elapsedTime = currentTime - lastEventTime; int eventAction = event.getAction(); boolean receivedUserInput = (eventAction == WorldWind.NAVIGATOR_MOVED && event.getLastInputEvent() != null); // Update the status overlay views whenever the navigator stops moving, // and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz. if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) { // Get the current navigator state to apply to the overlays event.getNavigator().getAsLookAt(wwd.getGlobe(), lookAt); event.getNavigator().getAsCamera(wwd.getGlobe(), camera); // Update the overlays updateOverlayContents(lookAt, camera); updateOverlayColor(eventAction); lastEventTime = currentTime; } // Show the crosshairs while the user is gesturing and fade them out after the user stops if (receivedUserInput) { showCrosshairs(); } else { fadeCrosshairs(); } } };
@Override public void run() { this.wwd.getNavigator().getAsCamera(this.wwd.getGlobe(), this.beginCamera); this.beginPos.set(this.beginCamera.latitude, this.beginCamera.longitude, this.beginCamera.altitude); for (int i = 0; i < this.steps; i++) { double amount = (double) i / (double) (this.steps - 1); this.beginPos.interpolateAlongPath(this.endPos, WorldWind.GREAT_CIRCLE, amount, this.curPos); this.curCamera.latitude = this.curPos.latitude; this.curCamera.longitude = this.curPos.longitude; this.curCamera.altitude = this.curPos.altitude; this.curCamera.heading = WWMath.interpolateAngle360(amount, this.beginCamera.heading, this.endCamera.heading); this.curCamera.tilt = WWMath.interpolateAngle180(amount, this.beginCamera.tilt, this.endCamera.tilt); this.curCamera.roll = WWMath.interpolateAngle180(amount, this.beginCamera.roll, this.endCamera.roll); Runnable setCommand = SetCameraCommand.obtain(this.wwd, this.curCamera); runOnActivityThread(setCommand); sleepQuietly(FRAME_INTERVAL); } } }
this.rc.fieldOfView = this.fieldOfView; this.rc.horizonDistance = this.globe.horizonDistance(this.navigator.getAltitude()); this.rc.camera = this.navigator.getAsCamera(this.globe, this.rc.camera); this.rc.cameraPoint = this.globe.geographicToCartesian(this.rc.camera.latitude, this.rc.camera.longitude, this.rc.camera.altitude, this.rc.cameraPoint); this.rc.renderResourceCache = this.renderResourceCache;