コード例 #1
0
        public static void ZoomToBookmark(IGlobeDisplay globeDisplay, IBookmark3D pBookmark3D, double doubleDuration)
        {
            try
            {
                //创建动画轨迹并添加
                IAnimationTrack pAnimationTrack = CreateZoomOverLocationAnimation(globeDisplay, pBookmark3D);

                //播放轨迹
                IGlobe           globe           = globeDisplay.Globe;
                IAnimationTracks animationTracks = (IAnimationTracks)globe;
                //// Add Track
                //animationTracks.AddTrack(pAnimationTrack);
                // Only enable the track with the parsed name
                for (int i = 0; i <= animationTracks.TrackCount - 1; i++)
                {
                    IAnimationTrack animationTrackTest = (IAnimationTrack)animationTracks.Tracks.get_Element(i);
                    if (animationTrackTest.Name == pAnimationTrack.Name)
                    {
                        animationTrackTest.IsEnabled = true;
                    }
                    else
                    {
                        animationTrackTest.IsEnabled = false;
                    }
                }

                // Play Track
                System.DateTime dateTimeStart = DateTime.Now;
                double          doubleElapsed = 0;
                while (doubleElapsed <= doubleDuration)
                {
                    // Animation Viewer
                    animationTracks.ApplyTracks(globe.GlobeDisplay.ActiveViewer, doubleElapsed, doubleDuration);
                    globe.GlobeDisplay.ActiveViewer.Redraw(true);

                    // Get Elapsed Time
                    System.TimeSpan timeSpanElapsed = DateTime.Now.Subtract(dateTimeStart);
                    doubleElapsed = timeSpanElapsed.TotalSeconds;
                }

                // Display Last Frame (if slow viewer)
                animationTracks.ApplyTracks(globe.GlobeDisplay.ActiveViewer, 1d, 1d);

                #region 根据当前摄像机姿态决定应该为Global模式还是Local模式
                AutoSwitchGlobeCameraOrientationMode(globe);
                #endregion

                globe.GlobeDisplay.ActiveViewer.Redraw(true);

                // Remove Track
                animationTracks.RemoveTrack(pAnimationTrack);
            }
            catch { }
        }
コード例 #2
0
        private void PlayAnimation(double duration, int numCycles)
        {
            IGlobe           globe     = axGlobeControl1.Globe;
            IAnimationTracks tracks    = (IAnimationTracks)globe;
            IViewers3D       viewers3D = globe.GlobeDisplay;

            //exit if document doesn't contain animation..
            string sError;

            if (tracks.TrackCount == 0)
            {
                sError = m_AnimFilePath;
                if (sError == "")
                {
                    sError = "To get a Sample animation file, Developer Kit Samples need to be installed!";
                    System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + sError);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample.");
                }
                return;
            }

            DateTime startTime;
            TimeSpan timeSpan;
            int      j;
            double   elapsedTime;

            for (int i = 1; i <= numCycles; i++)
            {
                startTime = DateTime.Now;
                j         = 0;
                do
                {
                    timeSpan    = (DateTime.Now).Subtract(startTime);
                    elapsedTime = timeSpan.TotalSeconds;
                    if (elapsedTime > duration)
                    {
                        elapsedTime = duration;
                    }
                    tracks.ApplyTracks(null, elapsedTime, duration);
                    viewers3D.RefreshViewers();
                    j = j + 1;
                }while (elapsedTime < duration);
            }
        }
コード例 #3
0
        private static void PlayAnimationTrack(double duration, int numCycles, string FlyFilePath, IGlobe globe, GISFunction.SceneBookmark pSceneBookmark)
        {
            try
            {
                IAnimationTracks tracks    = (IAnimationTracks)globe;
                IViewers3D       viewers3D = globe.GlobeDisplay;

                //exit if document doesn't contain animation..
                string sError;
                if (tracks.TrackCount == 0)
                {
                    sError = FlyFilePath;
                    if (sError == "")
                    {
                        sError = "飞行路径文件可能丢失,请确保程序的完整性";
                        System.Windows.Forms.MessageBox.Show(sError, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("加载飞行文件失败,请尝试重新安装程序。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    return;
                }

                DateTime startTime;
                TimeSpan timeSpan;
                int      j;
                double   elapsedTime;

                for (int i = 1; i <= numCycles; i++)
                {
                    startTime = DateTime.Now;
                    j         = 0;
                    do
                    {
                        timeSpan    = (DateTime.Now).Subtract(startTime);
                        elapsedTime = timeSpan.TotalSeconds;
                        if (elapsedTime > duration)
                        {
                            elapsedTime = duration;
                        }
                        tracks.ApplyTracks(null, elapsedTime, duration);
                        viewers3D.RefreshViewers();
                        j = j + 1;
                    }while (elapsedTime < duration);
                }
                //if(FlyFilePath.Length>4)
                //{

                //    int index = FlyFilePath.IndexOf("飞行");
                //    int indexFlyPath = FlyFilePath.IndexOf("FlyPath");
                //    if (index > 0&&indexFlyPath>0)
                //    {
                //        string cityName = FlyFilePath.Substring(indexFlyPath + 8, index - indexFlyPath-8);
                //        pSceneBookmark.ZoomToScene(cityName);
                //    }
                //}
            }
            catch
            { }
        }
コード例 #4
0
        public static void ZoomToPointAnimation(AxGlobeControl axGlobeControl, double MapX, double MapY)
        {
            try
            {
                IPoint point = new PointClass();
                point.PutCoords(MapX, MapY);    //设置点击的点坐标

                //动画缩放到
                IAnimationTrack animaTrack = CreateZoomOverLocationAnimation(axGlobeControl.GlobeDisplay, MapX, MapY, 1000);
                animaTrack.IsEnabled = true;

                IAnimationTracks pTracks = axGlobeControl.Globe as IAnimationTracks;
                //for (int i = 0; i < pTracks.TrackCount; i++)
                //{
                //    IAnimationTrack pTrack = pTracks.Tracks.get_Element(i) as
                //    IAnimationTrack;
                //    pTrack.IsEnabled = true;//设置为true 才可以播放这条轨迹
                //}
                DateTime startTime = DateTime.Now;
                TimeSpan timeSpan;
                double   elapsedTime;
                double   duration = 7;
                bool     play     = true;
                do
                {
                    timeSpan    = (DateTime.Now).Subtract(startTime);
                    elapsedTime = timeSpan.TotalSeconds;
                    if (elapsedTime > duration)
                    {
                        play        = false;
                        elapsedTime = duration;
                    }
                    pTracks.ApplyTracks(axGlobeControl.Globe.GlobeDisplay.ActiveViewer, elapsedTime, duration);
                    axGlobeControl.Globe.GlobeDisplay.RefreshViewers();
                } while (play);


                #region //无动画方式
                //point = CommonBaseTool.BaseGISTools.getGeoPoint(MapX, MapY);        //转换坐标

                //IPoint ptObserver = new PointClass();
                //IPoint ptTarget = new PointClass();

                ////Observer点
                //IClone pClone1 = point as IClone;
                //ptObserver = pClone1.Clone() as IPoint;
                //ptObserver.Y = ptObserver.Y - 0.08;
                //ptObserver.Z = 15.45;
                ////Target点
                //IClone pClone2 = point as IClone;
                //ptTarget = pClone2.Clone() as IPoint;
                //ptTarget.Z = -0.01;

                //axGlobeControl.GlobeCamera.SetObserverLatLonAlt(ptObserver.Y, ptObserver.X, ptObserver.Z);
                //axGlobeControl.GlobeCamera.SetTargetLatLonAlt(ptTarget.Y, ptTarget.X, ptTarget.Z);
                #endregion

                //刷新
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }