protected void applyLimits(LookAt lookAt) { double distanceToExtents = this.wwd.distanceToViewGlobeExtents(); double minRange = 10; double maxRange = distanceToExtents * 2; lookAt.range = WWMath.clamp(lookAt.range, minRange, maxRange); //double minTiltRange = distanceToExtents * 0.1; //double maxTiltRange = distanceToExtents * 0.9; //double tiltAmount = WWMath.clamp((lookAt.range - minTiltRange) / (maxTiltRange - minTiltRange), 0, 1); double maxTilt = 80; lookAt.tilt = WWMath.clamp(lookAt.tilt, 0, maxTilt); }
protected void applyLimits(Camera camera) { double distanceToExtents = this.wwd.distanceToViewGlobeExtents(); double minAltitude = 100; double maxAltitude = distanceToExtents; camera.altitude = WWMath.clamp(camera.altitude, minAltitude, maxAltitude); // Limit the tilt to between nadir and the horizon (roughly) double r = wwd.getGlobe().getRadiusAt(camera.latitude, camera.latitude); double maxTilt = Math.toDegrees(Math.asin(r / (r + camera.altitude))); double minTilt = 0; camera.tilt = WWMath.clamp(camera.tilt, minTilt, maxTilt); } }
/** * Prepares this WorldWindow for drawing and event handling. * * @param configChooser optional argument for choosing an EGL configuration; may be null */ protected void init(EGLConfigChooser configChooser) { // Initialize the WorldWindow's navigator. Location initLocation = Location.fromTimeZone(TimeZone.getDefault()); double initAltitude = this.distanceToViewGlobeExtents() * 1.1; // add 10% to the minimum distance to allow for space around the screen edges this.navigator.setLatitude(initLocation.latitude); this.navigator.setLongitude(initLocation.longitude); this.navigator.setAltitude(initAltitude); // Initialize the WorldWindow's controller. this.worldWindowController.setWorldWindow(this); // Initialize the WorldWindow's render resource cache. int cacheCapacity = RenderResourceCache.recommendedCapacity(this.getContext()); this.renderResourceCache = new RenderResourceCache(cacheCapacity); // Set up to render on demand to an OpenGL ES 2.x context // TODO Investigate and use the EGL chooser submitted by jgiovino this.setEGLConfigChooser(configChooser); this.setEGLContextClientVersion(2); // must be called before setRenderer this.setRenderer(this); this.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // must be called after setRenderer // Log a message with some basic information about the WorldWindow's configuration. Logger.log(Logger.INFO, "WorldWindow initialized"); }