worldwind搜索功能控件placefinder 完全解析

本文探讨了在尝试将特定功能转换为控件过程中遇到的问题,特别是点击事件未能正常触发及鼠标响应失灵的情况,并深入分析了可能的原因在于设备初始化及WorldWindow中相机位置设置的相关代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

    这几天试着将它改成控件,不过go button

  private void buttonGo_Click(object sender,System.EventArgs e)

 {

 try{

double lat = double.Parse(this.textBoxLatitude.Text);

double lon=double.Parse(this.textBoxLongitude.Text);

double alt =(double)this.numericUpDownAltitude.Value);

m_WorldWindow.GotoLatLonAltitude(lat,lon,alt);

}

}

这个消息无法进入,让人有点郁闷的摸不着头脑.部分的鼠标响应消息也失灵了.奇怪的事.有时候还是可以看到效果.

通过追踪,device 的初始有点问题.

在worldwindow 里面的

 public void GotoLatLonAltitude(double latitude, double longitude, double altitude)
  {
   this.drawArgs.WorldCamera.SetPosition(latitude, longitude,
    this.drawArgs.WorldCamera.Heading.Degrees,altitude,this.drawArgs.WorldCamera.Tilt.Degrees);
  }

此处的drawArgs.worldcamera,好象也有点问题.

  期待完全处理之中

  public virtual 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._bank.Degrees;

   m_Orientation = Quaternion4d.EulerToQuaternion(
    MathEngine.DegreesToRadians(lon),
    MathEngine.DegreesToRadians(lat),
    MathEngine.DegreesToRadians(heading));

   Point3d p = Quaternion4d.QuaternionToEuler(m_Orientation);
   
   _latitude.Radians = p.Y;
   _longitude.Radians = p.X;
   _heading.Radians = p.Z;

   if(!double.IsNaN(tilt))
    Tilt = Angle.FromDegrees(tilt);
   if(!double.IsNaN(_altitude))
    this.Altitude = _altitude;
   this.Bank = Angle.FromDegrees(bank);
  }
   
  Matrix m_absoluteViewMatrix = Matrix.Identity;
  Matrix m_absoluteWorldMatrix = Matrix.Identity;
  Matrix m_absoluteProjectionMatrix = Matrix.Identity;
  
  public Matrix AbsoluteViewMatrix
  {
   get{ return m_absoluteViewMatrix; }
  }
  
  public Matrix AbsoluteWorldMatrix
  {
   get{ return m_absoluteWorldMatrix; }
  }

  public Matrix AbsoluteProjectionMatrix
  {
   get{ return m_absoluteProjectionMatrix; }
  }

  /// <summary>
  /// Calculates latitude/longitude for given screen coordinate.
  /// </summary>
  public virtual void PickingRayIntersection(
   int screenX,
   int screenY,
   out Angle latitude,
   out Angle longitude)
  {
   Vector3 v1 = new Vector3();
   v1.X = screenX;
   v1.Y = screenY;
   v1.Z = viewPort.MinZ;
   v1.Unproject(viewPort, m_absoluteProjectionMatrix, m_absoluteViewMatrix, m_absoluteWorldMatrix);

   Vector3 v2 = new Vector3();
   v2.X = screenX;
   v2.Y = screenY;
   v2.Z = viewPort.MaxZ;
   v2.Unproject(viewPort, m_absoluteProjectionMatrix, m_absoluteViewMatrix, m_absoluteWorldMatrix);

   Point3d p1 = new Point3d(v1.X, v1.Y, v1.Z);
   Point3d p2 = new Point3d(v2.X, v2.Y, v2.Z);

   double a = (p2.X - p1.X) * (p2.X - p1.X) + (p2.Y - p1.Y) * (p2.Y - p1.Y) + (p2.Z - p1.Z) * (p2.Z - p1.Z);
   double b = 2.0*((p2.X - p1.X)*(p1.X) + (p2.Y - p1.Y)*(p1.Y) + (p2.Z - p1.Z)*(p1.Z));
   double c = p1.X*p1.X + p1.Y*p1.Y + p1.Z*p1.Z - _worldRadius * _worldRadius;

   double discriminant = b*b - 4 * a * c;
   if(discriminant <= 0)
   {
    latitude = Angle.NaN;
    longitude = Angle.NaN;
    return;
   }

   // float t0 = ((-1.0f) * b + (float)Math.Sqrt(b*b - 4 * a * c)) / (2*a);
   double t1 = ((-1.0) * b - Math.Sqrt(b*b - 4 * a * c)) / (2*a);

   // Vector3 i0 = new Vector3(p1.X + t0*(p2.X - p1.X), p1.Y + t0*(p2.Y - p1.Y), p1.Z + t0 *(p2.Z - p1.Z));
   Point3d i1 = new Point3d(p1.X + t1*(p2.X - p1.X), p1.Y + t1*(p2.Y - p1.Y), p1.Z + t1 *(p2.Z - p1.Z));

   // Vector3 i0t = MathEngine.CartesianToSpherical(i0.X, i0.Y, i0.Z);
   Point3d i1t = MathEngine.CartesianToSphericalD(i1.X, i1.Y, i1.Z);
   Point3d mousePointer = i1t;

   latitude = Angle.FromRadians(mousePointer.Y);
   longitude = Angle.FromRadians(mousePointer.Z);
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值