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

在调用代码让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;
            }
        }


你可能感兴趣的:(C#,数学计算)