地球,请你不要颤抖!----如何解决ArcGIS Globe视角模式切换产生抖动的问题

21 篇文章 0 订阅
15 篇文章 1 订阅
在调用代码让ArcGlobe/GlobeControl视角在Globe/Surface模式间切换时,比如书签漫游,漫游飞行等操作之后,Globe会出现不受控的跳动或抖动的现象,这个问题如何解决?

可根据数学计算得出当前观测点是否在目标点正上方或正下方,如果在,则设置适当设置摄像机和地球模式即可。我把代码用C#写成了静态函数,很方便调用。如果大家还有别的什么更好的方法,请指教。

        //根据当前摄像机姿态决定应该为Global模式还是Local模式,解决调整Camera之后地球抖动问题
        public static void AutoSwitchGlobeCameraOrientationMode(IGlobe pGlobe)
        {
            ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = pGlobe.GlobeDisplay.ActiveViewer;
            ESRI.ArcGIS.Analyst3D.ICamera camera = sceneViewer.Camera;
            ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera;
            double xTarget;
            double yTarget;
            ESRI.ArcGIS.Geometry.IPoint targetCls = (globeCamera as ICamera).Target;
            targetCls.QueryCoords(out xTarget, out yTarget);
            double zTarget = targetCls.Z;
            // Calculate the current azimuth and inclination of the camera.
            //azimuth = Math.Atan2(xTarget, yTarget) * 180 / Math.PI;
            double inclination = (180 / Math.PI) * (Math.Asin(zTarget / Math.Sqrt(xTarget * xTarget + yTarget * yTarget + zTarget * zTarget))) - 10.0;
            if (inclination > 88 | inclination < -88 | double.IsNaN(inclination))
            {
                double targetLatitude;
                double targetLongitude;
                double targetAltitude;
                globeCamera.GetTargetLatLonAlt(out targetLatitude, out targetLongitude, out targetAltitude);
                double observerLatitude;
                double obsLongitude;
                double obsAltitude;
                globeCamera.GetObserverLatLonAlt(out observerLatitude, out obsLongitude, out obsAltitude);
                 Set the GlobeCamera to global navigation mode.
                globeCamera.OrientationMode = ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal;
                globeCamera.NavigationType = ESRI.ArcGIS.GlobeCore.esriGlobeNavigationType.esriGlobeNavigationAttached;
                globeCamera.SetObserverLatLonAlt(targetLatitude, targetLongitude, obsAltitude);
            }            
            else
            {
                globeCamera.OrientationMode = ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal;
                globeCamera.NavigationType = ESRI.ArcGIS.GlobeCore.esriGlobeNavigationType.esriGlobeNavigationFree;
            }
        }


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值