Example #1
0
        /// <summary>
        /// Pan the camera using delta values
        /// </summary>
        /// <param name="lat">Latitude offset</param>
        /// <param name="lon">Longitude offset</param>
        public override void Pan(Angle lat, Angle lon)
        {
            if (World.Settings.cameraHasMomentum)
            {
                this._latitudeMomentum  += lat / 100;
                this._longitudeMomentum += lon / 100;
            }

            if (Angle.IsNaN(lat))
            {
                lat = this._targetLatitude;
            }
            if (Angle.IsNaN(lon))
            {
                lon = this._targetLongitude;
            }
            lat += this._targetLatitude;
            lon += this._targetLongitude;

            if (Math.Abs(lat.Radians) > Math.PI / 2 - 1e-3)
            {
                lat.Radians = Math.Sign(lat.Radians) * (Math.PI / 2 - 1e-3);
            }

            this._targetOrientation = Quaternion4d.EulerToQuaternion(
                lon.Radians,
                lat.Radians, this._targetHeading.Radians);

            Point3d v = Quaternion4d.QuaternionToEuler(this._targetOrientation);

            if (!double.IsNaN(v.Y))
            {
                this._targetLatitude.Radians  = v.Y;
                this._targetLongitude.Radians = v.X;
                this._targetHeading.Radians   = v.Z;

                if (!World.Settings.cameraSmooth)
                {
                    this._latitude     = this._targetLatitude;
                    this._longitude    = this._targetLongitude;
                    this._heading      = this._targetHeading;
                    this.m_Orientation = this._targetOrientation;
                }
            }
        }
Example #2
0
        public override void Update(Device device)
        {
            // Move camera
            this.SlerpToTargetOrientation(World.Settings.cameraSlerpPercentage);
            // Check for terrain collision
            if (this._altitude < this._terrainElevationUnderCamera * World.Settings.VerticalExaggeration + minimumAltitude)
            {
                this._targetAltitude = this._terrainElevationUnderCamera * World.Settings.VerticalExaggeration + minimumAltitude;
                this._altitude       = this._targetAltitude;
                //ComputeTargetDistance( _targetAltitude, _targetTilt );
                this.ComputeTargetTilt(this._targetAltitude, this._distance);
                if (Angle.IsNaN(this._targetTilt))
                {
                    this._targetTilt.Degrees = 0;
                    this.ComputeTargetDistance(this._targetAltitude, this._targetTilt);
                    this._distance = this._targetDistance;
                }

                this._tilt = this._targetTilt;
            }
            // Update camera base
            base.Update(device);
        }
Example #3
0
        /// <summary>
        /// Generates a WW URI and optionally filters it
        /// </summary>
        /// <param name="bEnableFiltering">Forces a reduced string to be generated, enables filtering</param>
        /// <returns>A WW URI, filtered if bEnableFiltering is true</returns>
        public string ToString(bool bEnableFiltering)
        {
            StringBuilder sb = new StringBuilder(Scheme + "://goto/");

            sb.Append("world=");
            sb.Append(this.World);
            sb.Append("&lat=");
            sb.Append(this._latitude.Degrees.ToString("f5", CultureInfo.InvariantCulture));
            sb.Append("&lon=");
            sb.Append(this._longitude.Degrees.ToString("f5", CultureInfo.InvariantCulture));
            if (!Angle.IsNaN(this._viewRange))
            {
                sb.Append("&view=" + this._viewRange.Degrees.ToString("f1", CultureInfo.InvariantCulture));
            }
            else if (!double.IsNaN(this._altitude))
            {
                sb.Append("&alt=" + this._altitude.ToString("f0", CultureInfo.InvariantCulture));
            }
            // TODO: Decide on URI parameter names
            if (!Angle.IsNaN(this._direction) && (Math.Abs(this._direction.Degrees) > 0.1 || !bEnableFiltering))
            {
                sb.Append("&dir=" + this._direction.Degrees.ToString("f1", CultureInfo.InvariantCulture));
            }
            if (!Angle.IsNaN(this._tilt) && (Math.Abs(this._tilt.Degrees) < 89.5 || !bEnableFiltering))
            {
                sb.Append("&tilt=" + this._tilt.Degrees.ToString("f1", CultureInfo.InvariantCulture));
            }
            if (!Angle.IsNaN(this._bank) && (Math.Abs(this._bank.Degrees) > 0.1 || !bEnableFiltering))
            {
                sb.Append("&bank=" + this._bank.Degrees.ToString("f1", CultureInfo.InvariantCulture));
            }
            if (this._layer != null)
            {
                sb.Append("&layer=" + HttpUtility.UrlEncode(this._layer));
            }
            return(sb.ToString());
        }
Example #4
0
        /// <summary>
        /// Pan the camera using delta values
        /// </summary>
        /// <param name="lat">Latitude offset</param>
        /// <param name="lon">Longitude offset</param>
        public virtual void Pan(Angle lat, Angle lon)
        {
            if (Angle.IsNaN(lat))
            {
                lat = this._latitude;                              // should be zero (PM 2007-05)
            }
            if (Angle.IsNaN(lon))
            {
                lon = this._longitude;
            }
            lat += this._latitude;
            lon += this._longitude;

            //	this._orientation = MathEngine.EulerToQuaternion(
            //		lon.Radians,
            //		lat.Radians,
            //		_heading.Radians);

            this.m_Orientation = Quaternion4d.EulerToQuaternion(
                lon.Radians, lat.Radians, this._heading.Radians);

            Point3d p = Quaternion4d.QuaternionToEuler(this.m_Orientation);

            //	Vector3 v = MathEngine.QuaternionToEuler(this._orientation);
            //	if(!double.IsNaN(v.Y))
            //	{
            //		this._latitude.Radians = v.Y;
            //		this._longitude.Radians = v.X;
            //	}

            if (!double.IsNaN(p.Y))
            {
                this._latitude.Radians  = p.Y;
                this._longitude.Radians = p.X;
            }
        }