Beispiel #1
0
        private void CreateFlybyFromPathAnimation(ESRI.ArcGIS.GlobeCore.IGlobe globe, ESRI.ArcGIS.Geodatabase.IFeature lineFeature, ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls)
        {
            ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay;
            ESRI.ArcGIS.Analyst3D.IScene        scene        = globeDisplay.Scene;

            // Get a handle to the animation extension
            ESRI.ArcGIS.Analyst3D.IBasicScene2        basicScene2        = (ESRI.ArcGIS.Analyst3D.IBasicScene2)scene; // Explicit Cast
            ESRI.ArcGIS.Animation.IAnimationExtension animationExtension = basicScene2.AnimationExtension;

            // Get the geometry of the line feature
            ESRI.ArcGIS.Geometry.IGeometry geometry = lineFeature.Shape;

            // Create AGAnimationUtils and AGImportPathOptions objects
            ESRI.ArcGIS.Animation.IAGAnimationUtils AGAnimationUtilsCls = new ESRI.ArcGIS.Animation.AGAnimationUtilsClass();
            AGImportPathOptionsCls.PathGeometry = geometry;

            AGImportPathOptionsCls.AnimationEnvironment = animationExtension.AnimationEnvironment;
            ESRI.ArcGIS.Animation.IAGAnimationContainer AGAnimationContainer = animationExtension.AnimationTracks.AnimationObjectContainer;

            // Call "CreateFlybyFromPath" method
            AGAnimationUtilsCls.CreateFlybyFromPath(AGAnimationContainer, AGImportPathOptionsCls);
        }
Beispiel #2
0
        /// <summary>
        ///第三个参数是移动的方式,其中1表示移动观察者,2表示移动目标,其他表示两个都移动
        /// </summary>
        /// <param name="_pScene">_pGlobe</param>
        /// <param name="_pPolyline">_pPolyline</param>
        /// <param name="_pType">_pType</param>
        public void CreateAnimationFromPath(IGlobe _pGlobe, IPolyline _pPolyline, int _FlySpeedRating, bool _IsFlyLoop, bool _IsFlyLookdown)//int _pType,, double _pDuration)
        {
            try
            {
                #region //esri写的
                scene = _pGlobe.GlobeDisplay.Scene;
                // 获取动画扩展对象
                //ESRI.ArcGIS.Analyst3D.IBasicScene2 pBasicScene2 = (ESRI.ArcGIS.Analyst3D.IBasicScene2)_pScene; // Explicit Cast
                //ESRI.ArcGIS.Animation.IAnimationExtension pAnimationExtension = pBasicScene2.AnimationExtension;
                //创建两个对象,一个用于导入路径,一个用于播放
                //ESRI.ArcGIS.Animation.IAGAnimationUtils pAGAnimationUtils = new ESRI.ArcGIS.Animation.AGAnimationUtilsClass();
                pAGImportPathOptions = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass();
                // 设置参数
                //参数设置不正确会出错,尤其是类型,对象等信息!
                pAGImportPathOptions.BasicMap        = (ESRI.ArcGIS.Carto.IBasicMap)scene;
                pAGImportPathOptions.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)scene;
                // pAGImportPathOptions.AnimationType = new ESRI.ArcGIS.GlobeCore.AnimationTypeCameraClass();    //在Globe中不能用这个
                pAGImportPathOptions.AnimationType   = new AnimationTypeGlobeCameraClass();
                pAGImportPathOptions.LookaheadFactor = 1;
                pAGImportPathOptions.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative,
                                                                esriPathAngleCalculation.esriAngleAddRelative,
                                                                esriPathAngleCalculation.esriAngleAddRelative);
                //pAGImportPathOptions.AnimatedObject = _pScene.SceneGraph.ActiveViewer.Camera; //在Globe中不能用这个
                pAGImportPathOptions.AnimatedObject = _pGlobe.GlobeDisplay.ActiveViewer.Camera;
                pAGImportPathOptions.PathGeometry   = _pPolyline;
                //俯视飞行
                if (_IsFlyLoop)
                {
                    pAGImportPathOptions.ConversionType = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathObserver;     //观察者移动
                }
                else                                                                                                             //正常飞行
                {
                    pAGImportPathOptions.ConversionType = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathObsAndTarget; //都移动
                }
                //else
                //{
                //    pAGImportPathOptions.ConversionType = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathTarget;
                //}
                pAGImportPathOptions.LookaheadFactor      = 1;
                pAGImportPathOptions.RollFactor           = 0;
                pAGImportPathOptions.AnimationEnvironment = pAnimationExtension.AnimationEnvironment;

                //
                //InitAnimationParameters();

                //持续时间
                double FlyPathLength = FlyPathPolyline.Length;
                double flyDuration   = FlyPathLength * 500 / _FlySpeedRating; //飞行路线长度*300*飞行速度等级/中速等级
                FlyDurationTime = flyDuration;                                //记录飞行时间
                pAnimationExtension.AnimationEnvironment.AnimationDuration = flyDuration;
                pAnimationExtension.AnimationEnvironment.IsIntervalPlay    = false;
                pAnimationExtension.AnimationEnvironment.PlayMode          = esriAnimationPlayMode.esriAnimationPlayOnceForward;
                pAnimationExtension.AnimationEnvironment.PlayTime          = pAnimationExtension.AnimationEnvironment.AnimationDuration;

                //IAGAnimationEnvironment pAGAeviroment = new AGAnimationEnvironmentClass();
                ESRI.ArcGIS.Animation.IAGAnimationContainer AGAnimationContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;

                // 创建飞行路线类似ArcGlobe中的Import,通过ArcGlobe学习ArcGlobe开发!
                pAgAnimationUtils.CreateFlybyFromPath(AGAnimationContainer, pAGImportPathOptions);

                //该接口相当于播放的界面,可以自己做一个界面
                animPlayer = pAgAnimationUtils as IAGAnimationPlayer;
                //animPlayer.PlayAnimation(_pScene as IAGAnimationTracks, pAGAeviroment, null); //开始飞行
                #endregion
            }
            catch
            { }
            #region //用改变观察者和观察点的方式
            //if (this.m_pScene.AreaOfInterest == null)
            //    return;
            //// Explicit Cast
            //IBasicScene2 basicScene2 = (IBasicScene2)_pGlobe;
            //m_pAnimationExtension = basicScene2.AnimationExtension;

            //m_pAgAnimationUtils = new AGAnimationUtilsClass();
            //IAGImportPathOptions agImportPathOptions = new AGImportPathOptionsClass();

            //agImportPathOptions.AnimationEnvironment = m_pAnimationExtension.AnimationEnvironment;
            //IAGAnimationContainer AGAnimationContainer = m_pAnimationExtension.AnimationTracks.AnimationObjectContainer;

            //if (AGAnimationContainer != null)
            //{
            //    m_pAgAnimationUtils.CreateFlybyFromPath(AGAnimationContainer, agImportPathOptions);
            //}
            #endregion
        }