示例#1
0
 OrbitViewMoveToZoomAnimator(BasicOrbitView orbitView, Double end, double smoothing,
                             PropertyAccessor.DoubleAccessor propertyAccessor, bool endCenterOnSurface)
     : base(end, smoothing, propertyAccessor)
 {
     this.orbitView          = orbitView;
     this.endCenterOnSurface = endCenterOnSurface;
 }
 public OrbitViewCenterAnimator(BasicOrbitView orbitView, Position startPosition, Position endPosition,
                                double smoothing, PropertyAccessor.PositionAccessor propertyAccessor, bool endCenterOnSurface)
     : base(startPosition, endPosition, smoothing, propertyAccessor)
 {
     this.endCenterOnSurface = endCenterOnSurface;
     this.orbitView          = orbitView;
 }
        public OrbitViewEyePointAnimator(Globe globe, BasicOrbitView view, Vec4 eyePoint, double smoothing)
        {
            if (globe == null)
            {
                var msg = Logging.getMessage("nullValue.GlobeIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (view == null)
            {
                var msg = Logging.getMessage("nullValue.ViewIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (eyePoint == null)
            {
                var msg = Logging.getMessage("nullValue.PointIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            this.globe     = globe;
            this.view      = view;
            this.eyePoint  = eyePoint;
            this.smoothing = smoothing;
            HasNext        = true;
        }
示例#4
0
        public Position computeCenterPositionToResolveCollision(BasicOrbitView orbitView, double nearDistance,
                                                                DrawContext dc)
        {
            if (orbitView == null)
            {
                String message = Logging.getMessage("nullValue.OrbitViewIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            if (nearDistance < 0)
            {
                String message = Logging.getMessage("generic.ArgumentOutOfRange", nearDistance);
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            Globe globe = dc.getGlobe();

            if (globe == null)
            {
                String message = Logging.getMessage("nullValue.DrawingContextGlobeIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            Position newCenter = null;

            for (int i = 0; i < this.numIterations; i++)
            {
                Matrix modelviewInv = getModelviewInverse(globe,
                                                          newCenter != null ? newCenter : orbitView.getCenterPosition(),
                                                          orbitView.getHeading(), orbitView.getPitch(), orbitView.getRoll(), orbitView.getZoom());
                if (modelviewInv != null)
                {
                    double heightAboveSurface = computeViewHeightAboveSurface(dc, modelviewInv,
                                                                              orbitView.getFieldOfView(), orbitView.getViewport(), nearDistance);
                    double adjustedHeight = heightAboveSurface - this.collisionThreshold;
                    if (adjustedHeight < 0)
                    {
                        newCenter = new Position(
                            newCenter != null ? newCenter : orbitView.getCenterPosition(),
                            (newCenter != null ? newCenter.getElevation() : orbitView.getCenterPosition().getElevation())
                            - adjustedHeight);
                    }
                }
            }

            return(newCenter);
        }
示例#5
0
 public FlyToOrbitViewAnimator(OrbitView orbitView, Interpolator interpolator, int altitudeMode,
                               PositionAnimator centerAnimator, DoubleAnimator zoomAnimator,
                               AngleAnimator headingAnimator, AngleAnimator pitchAnimator, AngleAnimator rollAnimator) :
     base(interpolator, centerAnimator, zoomAnimator, headingAnimator, pitchAnimator, rollAnimator)
 {
     this.orbitView       = (BasicOrbitView)orbitView;
     this.centerAnimator  = centerAnimator;
     this.zoomAnimator    = (ViewElevationAnimator)zoomAnimator;
     this.headingAnimator = headingAnimator;
     this.pitchAnimator   = pitchAnimator;
     this.rollAnimator    = rollAnimator;
     if (interpolator == null)
     {
         this.interpolator = new ScheduledInterpolator(10000);
     }
     this.altitudeMode = altitudeMode;
 }
        public static void setEyePoint(Globe globe, BasicOrbitView view, Vec4 newEyePoint)
        {
            if (globe == null)
            {
                var msg = Logging.getMessage("nullValue.GlobeIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (view == null)
            {
                var msg = Logging.getMessage("nullValue.ViewIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            if (newEyePoint == null)
            {
                var msg = Logging.getMessage("nullValue.PointIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            // Translate the view's modelview matrix to the specified new eye point, and compute the new center point by
            // assuming that the view's zoom distance does not change.
            var translation = view.getModelviewMatrix().extractEyePoint().subtract3(newEyePoint);
            var modelview   = view.getModelviewMatrix().multiply(Matrix.fromTranslation(translation));
            var eyePoint    = modelview.extractEyePoint();
            var forward     = modelview.extractForwardVector();
            var centerPoint = eyePoint.add3(forward.multiply3(view.getZoom()));

            // Set the view's properties from the new modelview matrix.
            var parameters = modelview.extractViewingParameters(centerPoint, view.getRoll(), globe);

            view.setCenterPosition((Position)parameters.getValue(AVKey.ORIGIN));
            view.setHeading((Angle)parameters.getValue(AVKey.HEADING));
            view.setPitch((Angle)parameters.getValue(AVKey.TILT));
            view.setRoll((Angle)parameters.getValue(AVKey.ROLL));
            view.setZoom((double)parameters.getValue(AVKey.RANGE));
            view.setViewOutOfFocus(true);
        }
示例#7
0
        public Angle computePitchToResolveCollision(BasicOrbitView orbitView, double nearDistance, DrawContext dc)
        {
            if (orbitView == null)
            {
                String message = Logging.getMessage("nullValue.OrbitViewIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            if (nearDistance < 0)
            {
                String message = Logging.getMessage("generic.ArgumentOutOfRange", nearDistance);
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            if (dc == null)
            {
                String message = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }
            Globe globe = dc.getGlobe();

            if (globe == null)
            {
                String message = Logging.getMessage("nullValue.DrawingContextGlobeIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            Angle newPitch = null;

            for (int i = 0; i < this.numIterations; i++)
            {
                Matrix modelviewInv = getModelviewInverse(globe,
                                                          orbitView.getCenterPosition(), orbitView.getHeading(),
                                                          newPitch != null ? newPitch : orbitView.getPitch(), orbitView.getRoll(),
                                                          orbitView.getZoom());
                if (modelviewInv != null)
                {
                    double heightAboveSurface = computeViewHeightAboveSurface(dc, modelviewInv,
                                                                              orbitView.getFieldOfView(), orbitView.getViewport(), nearDistance);
                    double adjustedHeight = heightAboveSurface - this.collisionThreshold;
                    if (adjustedHeight < 0)
                    {
                        Vec4 eyePoint    = getEyePoint(modelviewInv);
                        Vec4 centerPoint = globe.computePointFromPosition(orbitView.getCenterPosition());
                        if (eyePoint != null && centerPoint != null)
                        {
                            Position eyePos = globe.computePositionFromPoint(eyePoint);
                            // Compute the eye point required to resolve the collision.
                            Vec4 newEyePoint = globe.computePointFromPosition(eyePos.getLatitude(), eyePos.getLongitude(),
                                                                              eyePos.getElevation() - adjustedHeight);
                            // Compute the pitch that corresponds with the elevation of the eye point
                            // (but not necessarily the latitude and longitude).
                            Vec4   normalAtCenter    = globe.computeSurfaceNormalAtPoint(centerPoint);
                            Vec4   newEye_sub_center = newEyePoint.subtract3(centerPoint).normalize3();
                            double dot = normalAtCenter.dot3(newEye_sub_center);
                            if (dot >= -1 || dot <= 1)
                            {
                                double angle = Math.Acos(dot);
                                newPitch = Angle.fromRadians(angle);
                            }
                        }
                    }
                }
            }

            return(newPitch);
        }