Ejemplo n.º 1
0
        /**
         * Set the value of the field being animated based on the given interpolant.
         * @param interpolant A value between 0 and 1.
         */
        public void set(double interpolant)
        {
            const int    MAX_SMOOTHING = 1;
            const double ZOOM_START    = 0.0;
            const double ZOOM_STOP     = 1.0;

            if (interpolant >= 1.0)
            {
                this.stop();
            }
            double zoomInterpolant;

            if (this.UseMidZoom)
            {
                double value;
                zoomInterpolant = this.zoomInterpolant(interpolant, ZOOM_START, ZOOM_STOP, MAX_SMOOTHING);
                if (interpolant <= .5)
                {
                    value = nextDouble(zoomInterpolant, this.Begin, this.End);
                }
                else
                {
                    value = nextDouble(zoomInterpolant, this.End, this.trueEndZoom);
                }
                this.propertyAccessor.setDouble(value);
            }
            else
            {
                zoomInterpolant = AnimationSupport.basicInterpolant(interpolant, ZOOM_START, ZOOM_STOP, MAX_SMOOTHING);
                base.set(zoomInterpolant);
            }
        }
Ejemplo n.º 2
0
            protected Position nextPosition(double interpolant)
            {
                const int MAX_SMOOTHING = 1;

                double CENTER_START      = this.useMidZoom ? 0.2 : 0.0;
                double CENTER_STOP       = this.useMidZoom ? 0.8 : 0.8;
                double latLonInterpolant = AnimationSupport.basicInterpolant(interpolant, CENTER_START, CENTER_STOP,
                                                                             MAX_SMOOTHING);

                // Invoke the standard next position functionality.
                Position pos = base.nextPosition(latLonInterpolant);

                // Check the altitude mode. If the altitude mode depends on the surface elevation we will reevaluate the
                // end position altitude. When the animation starts we may not have accurate elevation data available for
                // the end position, so recalculating the elevation as we go ensures that the animation will end at the
                // correct altitude.
                double endElevation         = 0.0;
                bool   overrideEndElevation = false;

                if (this.altitudeMode == WorldWind.CLAMP_TO_GROUND)
                {
                    overrideEndElevation = true;
                    endElevation         = this.globe.getElevation(getEnd().getLatitude(), getEnd().getLongitude());
                }
                else if (this.altitudeMode == WorldWind.RELATIVE_TO_GROUND)
                {
                    overrideEndElevation = true;
                    endElevation         = this.globe.getElevation(getEnd().getLatitude(), getEnd().getLongitude())
                                           + getEnd().getAltitude();
                }

                if (overrideEndElevation)
                {
                    LatLon ll = pos; // Use interpolated lat/lon.
                    double e1 = getBegin().getElevation();
                    pos = new Position(ll, (1 - latLonInterpolant) * e1 + latLonInterpolant * endElevation);
                }

                return(pos);
            }