private SetCameraCommand set(WorldWindow wwd, Camera camera) { this.wwd = wwd; this.camera.set(camera); return this; }
protected void positionView(WorldWindow wwd) { Position mtRainier = new Position(46.852886, -121.760374, 4392.0); Position eye = new Position(46.912, -121.527, 2000.0); // Compute heading and distance from peak to eye Globe globe = wwd.getGlobe(); double heading = eye.greatCircleAzimuth(mtRainier); double distanceRadians = mtRainier.greatCircleDistance(eye); double distance = distanceRadians * globe.getRadiusAt(mtRainier.latitude, mtRainier.longitude); // Compute camera settings double altitude = eye.altitude - mtRainier.altitude; double range = Math.sqrt(altitude * altitude + distance * distance); double tilt = Math.toDegrees(Math.atan(distance / eye.altitude)); // Apply the new view Camera camera = new Camera(); camera.set(eye.latitude, eye.longitude, eye.altitude, WorldWind.ABSOLUTE, heading, tilt, 0.0 /*roll*/); wwd.getNavigator().setAsCamera(globe, camera); } }
/** * 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(); } }
/** * Creates a new WorldWindow object with a custom WorldWindowController. */ @Override public WorldWindow createWorldWindow() { // Let the super class (BasicGlobeFragment) do the creation WorldWindow wwd = super.createWorldWindow(); // Override the default "look at" gesture behavior with a camera centric gesture controller wwd.setWorldWindowController(new CameraController()); // Create a camera position above KOXR airport, Oxnard, CA Camera camera = new Camera(); camera.set(34.2, -119.2, 10000, WorldWind.ABSOLUTE, 90, // Looking east 70, // Lookup up from nadir 0); // No roll // Apply the new camera position Globe globe = wwd.getGlobe(); wwd.getNavigator().setAsCamera(globe, camera); return wwd; }
/** * Restores the Navigator's camera state from a SharedPreferences object. */ protected void restoreNavigatorState() { WorldWindow wwd = this.getWorldWindow(); if (wwd != null) { SharedPreferences preferences = this.getPreferences(MODE_PRIVATE); // We only want to restore preferences from the same session. if (preferences.getLong(SESSION_TIMESTAMP, -1) != getSessionTimestamp()) { return; } // Read the camera data float lat = preferences.getFloat(CAMERA_LATITUDE, Float.MAX_VALUE); float lon = preferences.getFloat(CAMERA_LONGITUDE, Float.MAX_VALUE); float alt = preferences.getFloat(CAMERA_ALTITUDE, Float.MAX_VALUE); float heading = preferences.getFloat(CAMERA_HEADING, Float.MAX_VALUE); float tilt = preferences.getFloat(CAMERA_TILT, Float.MAX_VALUE); float roll = preferences.getFloat(CAMERA_ROLL, Float.MAX_VALUE); @WorldWind.AltitudeMode int altMode = preferences.getInt(CAMERA_ALTITUDE_MODE, WorldWind.ABSOLUTE); if (lat == Float.MAX_VALUE || lon == Float.MAX_VALUE || alt == Float.MAX_VALUE || heading == Float.MAX_VALUE || tilt == Float.MAX_VALUE || roll == Float.MAX_VALUE) { return; } // Restore the camera state. Camera camera = new Camera(lat, lon, alt, altMode, heading, tilt, roll); wwd.getNavigator().setAsCamera(wwd.getGlobe(), camera); } }
public AnimateCameraCommand(WorldWindow wwd, Camera end, int steps) { this.wwd = wwd; this.endCamera.set(end); this.endPos.set(end.latitude, end.longitude, end.altitude); this.steps = steps; }
Camera cam = new Camera(arc.latitude, arc.longitude, 10e3, WorldWind.ABSOLUTE, 0, 0, 0); exec.execute(new AnimateCameraCommand(wwd, cam, 100)); cam = new Camera(arc.latitude, arc.longitude, 10e3, WorldWind.ABSOLUTE, azimuth, 70, 0); exec.execute(new SleepCommand(500)); exec.execute(new AnimateCameraCommand(wwd, cam, 50)); azimuth = midLoc.greatCircleAzimuth(gsfc); exec.execute(new SleepCommand(500)); cam = new Camera(midLoc.latitude, midLoc.longitude, 1000e3, WorldWind.ABSOLUTE, azimuth, 0, 0); exec.execute(new AnimateCameraCommand(wwd, cam, 100)); cam = new Camera(gsfc.latitude, gsfc.longitude, 10e3, WorldWind.ABSOLUTE, azimuth, 70, 0); exec.execute(new AnimateCameraCommand(wwd, cam, 100)); cam = new Camera(gsfc.latitude, gsfc.longitude, 10e3, WorldWind.ABSOLUTE, azimuth, 90, 0); exec.execute(new SleepCommand(500)); exec.execute(new AnimateCameraCommand(wwd, cam, 50)); cam = new Camera(midLoc.latitude, midLoc.longitude, 1000e3, WorldWind.ABSOLUTE, azimuth, 60, 0); exec.execute(new AnimateCameraCommand(wwd, cam, 100)); cam = new Camera(esrin.latitude, esrin.longitude, 100e3, WorldWind.ABSOLUTE, azimuth, 30, 0); exec.execute(new AnimateCameraCommand(wwd, cam, 100)); cam = new Camera(esrin.latitude, esrin.longitude, 2000e3, WorldWind.ABSOLUTE, 0, 0, 0); exec.execute(new SleepCommand(500)); exec.execute(new AnimateCameraCommand(wwd, cam, 100));
@Override protected void gestureDidBegin() { if (this.activeGestures++ == 0) { this.wwd.getNavigator().getAsCamera(this.wwd.getGlobe(), this.beginCamera); this.camera.set(this.beginCamera); } }
public void reset() { this.globe = null; this.terrainTessellator = null; this.terrain = null; this.layers = null; this.currentLayer = null; this.verticalExaggeration = 1; this.fieldOfView = 0; this.horizonDistance = 0; this.camera.set(0, 0, 0, WorldWind.ABSOLUTE /*lat, lon, alt*/, 0, 0, 0 /*heading, tilt, roll*/); this.cameraPoint.set(0, 0, 0); this.viewport.setEmpty(); this.projection.setToIdentity(); this.modelview.setToIdentity(); this.modelviewProjection.setToIdentity(); this.frustum.setToUnitFrustum(); this.renderResourceCache = null; this.resources = null; this.drawableQueue = null; this.drawableTerrain = null; this.pickedObjects = null; this.pickViewport = null; this.pickPoint = null; this.pickRay = null; this.pickMode = false; this.pickedObjectId = 0; this.redrawRequested = false; this.pixelSizeFactor = 0; this.userProperties.clear(); }