[WorldWind学习]5.相机对象
生活随笔
收集整理的這篇文章主要介紹了
[WorldWind学习]5.相机对象
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
首先查看WorldWindow的事件:OnMouseUp、OnMouseMove、HandleKeyDown,這幾個方法中多次調用this.drawArgs.WorldCamera的各種屬性實現了場景的控制,包括球的旋轉、場景的放大縮小,上下移動。
1. 接下來查看CameraBase類RotationYawPitchRoll虛函數:
1 public virtual void RotationYawPitchRoll(Angle yaw, Angle pitch, Angle roll) 2 { 3 // this._orientation *= MathEngine.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians); 4 // Vector3 v = MathEngine.QuaternionToEuler(this._orientation); 5 6 // if(!double.IsNaN(v.Y)) 7 // this._latitude.Radians = v.Y; 8 // if(!double.IsNaN(v.X)) 9 // this._longitude.Radians = v.X; 10 // if(Math.Abs(roll.Radians)>Single.Epsilon) 11 // this._heading.Radians = v.Z; 12 13 14 m_Orientation = Quaternion4d.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians) * m_Orientation; 15 16 Point3d p = Quaternion4d.QuaternionToEuler(m_Orientation); 17 if(!double.IsNaN(p.Y)) 18 _latitude.Radians = p.Y; 19 if(!double.IsNaN(p.X)) 20 _longitude.Radians = p.X; 21 if(Math.Abs(roll.Radians) > double.Epsilon) 22 _heading.Radians = p.Z; 23 } RotationYawPitchRollWorldCamera類的RotationYawPitchRoll方法:
1 public override void RotationYawPitchRoll(Angle yaw, Angle pitch, Angle roll) 2 { 3 _targetOrientation = Quaternion4d.EulerToQuaternion(yaw.Radians, pitch.Radians, roll.Radians) * _targetOrientation; 4 5 Point3d v = Quaternion4d.QuaternionToEuler(_targetOrientation); 6 if(!double.IsNaN(v.Y)) 7 this._targetLatitude.Radians = v.Y; 8 if(!double.IsNaN(v.X)) 9 this._targetLongitude.Radians = v.X; 10 if(Math.Abs(roll.Radians)>double.Epsilon) 11 this._targetHeading.Radians = v.Z; 12 } RotationYawPitchRollMomentumCamera類的RotationYawPitchRoll方法:
1 public override void RotationYawPitchRoll(Angle yaw, Angle pitch, Angle roll) 2 { 3 if(World.Settings.cameraHasMomentum) 4 { 5 _latitudeMomentum += pitch/100; 6 _longitudeMomentum += yaw/100; 7 _headingMomentum += roll/100; 8 } 9 10 this._targetOrientation = Quaternion4d.EulerToQuaternion( yaw.Radians, pitch.Radians, roll.Radians ) * _targetOrientation; 11 Point3d v = Quaternion4d.QuaternionToEuler(_targetOrientation); 12 if(!double.IsNaN(v.Y)) 13 { 14 this._targetLatitude.Radians = v.Y; 15 this._targetLongitude.Radians = v.X; 16 if(!World.Settings.cameraTwistLock) 17 _targetHeading.Radians = v.Z; 18 } 19 20 base.RotationYawPitchRoll(yaw,pitch,roll); 21 } RotationYawPitchRoll2. CameraBase類的Pan方法:
1 /// <summary> 2 /// Pan the camera using delta values 3 /// 平移相機,采用經緯度偏移量 4 /// </summary> 5 /// <param name="lat">Latitude offset</param> 6 /// <param name="lon">Longitude offset</param> 7 public virtual void Pan(Angle lat, Angle lon) 8 { 9 if(Angle.IsNaN(lat)) lat = this._latitude; 10 if(Angle.IsNaN(lon)) lon = this._longitude; 11 lat += _latitude; 12 lon += _longitude; 13 14 // this._orientation = MathEngine.EulerToQuaternion( 15 // lon.Radians, 16 // lat.Radians, 17 // _heading.Radians); 18 19 m_Orientation = Quaternion4d.EulerToQuaternion( 20 lon.Radians, lat.Radians, _heading.Radians); 21 22 Point3d p = Quaternion4d.QuaternionToEuler(m_Orientation); 23 24 // Vector3 v = MathEngine.QuaternionToEuler(this._orientation); 25 // if(!double.IsNaN(v.Y)) 26 // { 27 // this._latitude.Radians = v.Y; 28 // this._longitude.Radians = v.X; 29 // } 30 31 if(!double.IsNaN(p.Y)) 32 { 33 _latitude.Radians = p.Y; 34 _longitude.Radians = p.X; 35 } 36 } PanMomentumCamera類的Pan方法:
1 public override void Pan(Angle lat, Angle lon) 2 { 3 if(World.Settings.cameraHasMomentum) 4 { 5 _latitudeMomentum += lat/100; 6 _longitudeMomentum += lon/100; 7 } 8 9 if(Angle.IsNaN(lat)) lat = this._targetLatitude; 10 if(Angle.IsNaN(lon)) lon = this._targetLongitude; 11 lat += _targetLatitude; 12 lon += _targetLongitude; 13 14 if(Math.Abs(lat.Radians)>Math.PI/2-1e-3) 15 { 16 lat.Radians = Math.Sign(lat.Radians)*(Math.PI/2 - 1e-3); 17 } 18 19 this._targetOrientation = Quaternion4d.EulerToQuaternion( 20 lon.Radians, 21 lat.Radians, 22 _targetHeading.Radians); 23 24 Point3d v = Quaternion4d.QuaternionToEuler(this._targetOrientation); 25 if(!double.IsNaN(v.Y)) 26 { 27 _targetLatitude.Radians = v.Y; 28 _targetLongitude.Radians = v.X; 29 _targetHeading.Radians = v.Z; 30 31 if(!World.Settings.cameraSmooth) 32 { 33 _latitude = _targetLatitude; 34 _longitude = _targetLongitude; 35 _heading = _targetHeading; 36 m_Orientation = _targetOrientation; 37 } 38 } 39 } Pan?
錯誤?1?無法注冊程序集“F:\World_Wind_1.4.0_Source\HtmlEditor\bin\Debug\HtmlEditor.dll”- 拒絕訪問。請確保您正在以管理員身份運行應用程序。對注冊表項“HKEY_CLASSES_ROOT\onlyconnect.HtmlDialog”的訪問被拒絕。?HtmlEditor
解決方法:HtmlEditor項目的屬性,取消“生成(Build )”選項卡的為COM互操作注冊
轉載于:https://www.cnblogs.com/yhlx125/archive/2013/04/01/2987075.html
總結
以上是生活随笔為你收集整理的[WorldWind学习]5.相机对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用STATSVN统计公司SVN代码修改
- 下一篇: CutJS – 用于 HTML5 游戏开