public virtual void RotationYawPitchRoll(Angle yaw, Angle pitch, Angle roll) { // this._orientation *= MathEngine.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians); // Vector3 v = MathEngine.QuaternionToEuler(this._orientation); // if(!double.IsNaN(v.Y)) // this._latitude.Radians = v.Y; // if(!double.IsNaN(v.X)) // this._longitude.Radians = v.X; // if(Math.Abs(roll.Radians)>Single.Epsilon) // this._heading.Radians = v.Z; this.m_Orientation = Quaternion4d.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians) * this.m_Orientation; Point3d p = Quaternion4d.QuaternionToEuler(this.m_Orientation); if (!double.IsNaN(p.Y)) { this._latitude.Radians = p.Y; } if (!double.IsNaN(p.X)) { this._longitude.Radians = p.X; } if (Math.Abs(roll.Radians) > double.Epsilon) { this._heading.Radians = p.Z; } }
/// <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; } } }
public override void RotationYawPitchRoll(Angle yaw, Angle pitch, Angle roll) { this._targetOrientation = Quaternion4d.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians) * this._targetOrientation; Point3d v = Quaternion4d.QuaternionToEuler(this._targetOrientation); if (!double.IsNaN(v.Y)) { this._targetLatitude.Radians = v.Y; } if (!double.IsNaN(v.X)) { this._targetLongitude.Radians = v.X; } if (Math.Abs(roll.Radians) > double.Epsilon) { this._targetHeading.Radians = v.Z; } }
public override void SetPosition(double lat, double lon, double heading, double _altitude, double tilt, double bank) { if (double.IsNaN(lat)) { lat = this._latitude.Degrees; } if (double.IsNaN(lon)) { lon = this._longitude.Degrees; } if (double.IsNaN(heading)) { heading = this._heading.Degrees; } if (double.IsNaN(bank)) { bank = this._targetBank.Degrees; } this._targetOrientation = Quaternion4d.EulerToQuaternion( MathEngine.DegreesToRadians(lon), MathEngine.DegreesToRadians(lat), MathEngine.DegreesToRadians(heading)); Point3d v = Quaternion4d.QuaternionToEuler(this._targetOrientation); this._targetLatitude.Radians = v.Y; this._targetLongitude.Radians = v.X; this._targetHeading.Radians = v.Z; if (!double.IsNaN(tilt)) { this.Tilt = Angle.FromDegrees(tilt); } if (!double.IsNaN(_altitude)) { this.Altitude = _altitude; } this.Bank = Angle.FromDegrees(bank); }
/// <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; } }
public override void RotationYawPitchRoll(Angle yaw, Angle pitch, Angle roll) { if (World.Settings.cameraHasMomentum) { this._latitudeMomentum += pitch / 100; this._longitudeMomentum += yaw / 100; this._headingMomentum += roll / 100; } this._targetOrientation = Quaternion4d.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians) * this._targetOrientation; Point3d v = Quaternion4d.QuaternionToEuler(this._targetOrientation); if (!double.IsNaN(v.Y)) { this._targetLatitude.Radians = v.Y; this._targetLongitude.Radians = v.X; if (!World.Settings.cameraTwistLock) { this._targetHeading.Radians = v.Z; } } base.RotationYawPitchRoll(yaw, pitch, roll); }
public virtual void Update(Device device) { this.viewPort = device.Viewport; Point3d p = Quaternion4d.QuaternionToEuler(this.m_Orientation); if (!double.IsNaN(p.Y)) { this._latitude.Radians = p.Y; } if (!double.IsNaN(p.X)) { this._longitude.Radians = p.X; } if (!double.IsNaN(p.Z)) { this._heading.Radians = p.Z; } // Compute matrices this.ComputeProjectionMatrix(this.viewPort); this.ComputeViewMatrix(); device.SetTransform(TransformState.Projection, this.m_ProjectionMatrix); device.SetTransform(TransformState.View, this.m_ViewMatrix); device.SetTransform(TransformState.World, this.m_WorldMatrix); this.ViewFrustum.Update( Matrix.Multiply(this.m_absoluteWorldMatrix, Matrix.Multiply(this.m_absoluteViewMatrix, this.m_absoluteProjectionMatrix))); // Old view range (used in quadtile logic) double factor = (this._altitude) / this._worldRadius; if (factor > 1) { this.viewRange = Angle.FromRadians(Math.PI); } else { this.viewRange = Angle.FromRadians(Math.Abs(Math.Asin((this._altitude) / this._worldRadius)) * 2); } // True view range if (factor < 1) { this.trueViewRange = Angle.FromRadians(Math.Abs(Math.Asin((this._distance + this._headZoom) / this._worldRadius)) * 2); } else { this.trueViewRange = Angle.FromRadians(Math.PI); } World.Settings.cameraAltitudeMeters = this.Altitude; World.Settings.cameraLatitude = this._latitude; World.Settings.cameraLongitude = this._longitude; World.Settings.cameraHeading = this._heading; World.Settings.cameraTilt = this._tilt; World.Settings.cameraSwivel = this._swivel; if (World.Settings.cameraHeadTracking != this._headTracking) { this._headTracking = World.Settings.cameraHeadTracking; if (!this._headTracking) { this._headTilt = Angle.Zero; this._headSwivel = Angle.Zero; this._headZoom = 0.0; World.Settings.cameraHeadTilt = this._headTilt; World.Settings.cameraHeadSwivel = this._headSwivel; World.Settings.cameraHeadZoom = this._headZoom; } } if (this._headTracking) { World.Settings.cameraHeadTilt = this._headTilt; World.Settings.cameraHeadSwivel = this._headSwivel; World.Settings.cameraHeadZoom = this._headZoom; } }