[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         }
RotationYawPitchRoll

  WorldCamera类的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         }
RotationYawPitchRoll

  MomentumCamera类的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         }
RotationYawPitchRoll

  2. 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         }
Pan

  MomentumCamera类的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互操作注册

你可能感兴趣的:(学习)