コード例 #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 { }
        }