Ejemplo n.º 1
0
        public void InitAnimationByAgaFile(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath, bool _NotFlyByPolyline, int _FlySpeedRating)
        {
            try
            {
                IsFlyByPolyline = _NotFlyByPolyline;
                string FlyFilePath = FlyFoldPath + "\\" + _FlyPathName + ".aga";
                if (!File.Exists(FlyFilePath))    //如果此文件不存在
                {
                    return;
                }
                pAgAnimationUtils = new AGAnimationUtilsClass();
                IBasicScene2 basicScene2 = (IBasicScene2)scene; // Explicit Cast
                pAnimationExtension = basicScene2.AnimationExtension;
                //飞行时长设置
                switch (_FlySpeedRating)
                {
                case 1:
                    FlyDurationTime = 40;
                    break;

                case 2:
                    FlyDurationTime = 30;
                    break;

                case 3:
                    FlyDurationTime = 20;
                    break;

                case 4:
                    FlyDurationTime = 15;
                    break;

                case 5:
                    FlyDurationTime = 10;
                    break;

                default:
                    FlyDurationTime = 20;
                    break;
                }
                pAnimationExtension.AnimationEnvironment.AnimationDuration = FlyDurationTime;

                IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;
                pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内;
                animPlayer = (IAGAnimationPlayer)pAgAnimationUtils;
            }
            catch { }
        }
Ejemplo n.º 2
0
        //按预订的路径飞行
        public bool InitAnimationPlay(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath,
                                      int _FlySpeedRating, bool _IsFlyLoop, bool _IsFlyLookdown)
        {
            bool IsFoundPolyline = true;    //是否能找到对应的Polyline

            try
            {
                scene = _axGlobeControl.GlobeDisplay.Scene;
                globe = _axGlobeControl.Globe;
                IBasicScene2 basicScene = (IBasicScene2)globe;
                pAgAnimationUtils = new AGAnimationUtilsClass();
                //按路径飞行
                ILayer layer = getLayerByName(scene, ANIMATIONPATH_LayerName);
                if (layer == null)
                {
                    IsFoundPolyline = false;
                    return(IsFoundPolyline);
                }
                FlyPathPolyline = getPolylineFromLayer(layer, _FlyPathName);
                if (FlyPathPolyline == null)
                {
                    IsFoundPolyline = false;
                    return(IsFoundPolyline);
                }
                //启用三维线
                IZAware flyPathZAware = (IZAware)FlyPathPolyline;
                flyPathZAware.ZAware = true;

                pAnimationExtension = basicScene.AnimationExtension;
                CreateAnimationFromPath(globe, FlyPathPolyline, FlySpeedRating, IsFlyLoop, IsFlyLookdown);

                //配置飞行
                //InitAnimationParameters();

                //IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;
                //pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内;
                animPlayer = (IAGAnimationPlayer)pAgAnimationUtils;
            }
            catch
            { }
            return(IsFoundPolyline);
        }
Ejemplo n.º 3
0
        public static void FlyByPath(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath, GISFunction.SceneBookmark pSceneBookmark)
        {
            try
            {
                string FlyFilePath = FlyFoldPath + "\\" + _FlyPathName + ".aga";
                if (!File.Exists(FlyFilePath))    //如果此文件不存在
                {
                    return;
                }
                IGlobe       globe      = _axGlobeControl.Globe;
                IBasicScene2 basicScene = (IBasicScene2)globe;
                basicScene.LoadAnimation(FlyFilePath);

                double duration  = 10;
                int    numCycles = 1; //循环次数

                PlayAnimationTrack(duration, numCycles, FlyFilePath, globe, pSceneBookmark);
            }
            catch
            { }
        }
Ejemplo n.º 4
0
        ///<summary> 由路径来创建一个Camera动画.这条路径有图层提供一条三维线要素</summary>
        ///
        ///<param name="globe">IGlobe接口</param>
        ///<param name="layer">一个包含PolyLine的ILayer接口</param>
        ///<param name="featureID">包含路径的要素ID.Example: 123</param>
        ///
        ///<remarks></remarks>
        public void CreateAnimationFromPath(string path, string SaveFilePath)
        {
            IGlobe        pGlobe       = axGlobeControl1.Globe;
            IGlobeDisplay globeDisplay = pGlobe.GlobeDisplay;
            IScene        scene        = globeDisplay.Scene;

            // 获取动画扩展
            IBasicScene2        basicScene2        = scene as IBasicScene2;
            IAnimationExtension animationExtension = basicScene2.AnimationExtension;

            //获取路径

            //读取shp文件

            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();


            string pFolder   = System.IO.Path.GetDirectoryName(path);
            string pFileName = System.IO.Path.GetFileName(path);

            //2打开shapeFile工作空间
            IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(pFolder, 0);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;

            //3、打开要素类
            IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pFileName);

            //4、创建要素图层
            IFeatureLayer pFLayer = new FeatureLayerClass();

            //5、关联图层和要素类
            pFLayer.FeatureClass = pFeatureClass;
            pFLayer.Name         = pFeatureClass.AliasName;
            int b = pFeatureClass.ObjectClassID;

            ILayer        pLayer       = pFLayer;
            IFeatureLayer featureLayer = pLayer as IFeatureLayer;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            //int pFeatureID = pFeatureClass.FeatureClassID;
            int       pFeatureID = 0;
            IFeature  feature    = featureClass.GetFeature(pFeatureID);
            IGeometry geometry   = feature.Shape;

            //创建AGAnimationUtils和AGImportPathOptions对象
            ESRI.ArcGIS.Animation.IAGAnimationUtils    agAnimationUtils    = new AGAnimationUtilsClass();
            ESRI.ArcGIS.Animation.IAGImportPathOptions agImportPathOptions = new AGImportPathOptionsClass();

            // 设置AGImportPathOptions的属性
            agImportPathOptions.BasicMap        = (IBasicMap)pGlobe;
            agImportPathOptions.AnimationTracks = (IAGAnimationTracks)pGlobe;
            agImportPathOptions.AnimationType   = new AnimationTypeGlobeCameraClass();
            agImportPathOptions.AnimatedObject  = pGlobe.GlobeDisplay.ActiveViewer.Camera; //动画对象
            agImportPathOptions.PathGeometry    = geometry;                                //动画轨迹
            agImportPathOptions.ConversionType  = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathObsAndTarget;
            agImportPathOptions.LookaheadFactor = 0.05;
            agImportPathOptions.RollFactor      = 0;

            agImportPathOptions.AnimationEnvironment = animationExtension.AnimationEnvironment;
            IAGAnimationContainer AGAnimationContainer = animationExtension.AnimationTracks.AnimationObjectContainer;

            //创建
            agAnimationUtils.CreateFlybyFromPath(AGAnimationContainer, agImportPathOptions);

            //播放

            //获取AGAnimationEnvironment对象
            IBasicScene2            basicscene  = pGlobe as IBasicScene2;
            IAnimationExtension     animationEx = basicscene.AnimationExtension;
            IAGAnimationEnvironment agAnimationEnv;

            agAnimationEnv = animationEx.AnimationEnvironment;
            agAnimationEnv.AnimationDuration = Convert.ToDouble("30");                              //持续时间
            agAnimationEnv.PlayType          = esriAnimationPlayType.esriAnimationPlayTypeDuration; //播放模式

            agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayOnceForward;

            agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayOnceReverse;
            //agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayLoopForward;
            //agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayLoopReverse;


            IAGAnimationPlayer agAnimationPlayer = agAnimationUtils as IAGAnimationPlayer;

            agAnimationPlayer.PlayAnimation(pGlobe as IAGAnimationTracks, agAnimationEnv, null);



            //保存


            if (System.IO.File.Exists(SaveFilePath))
            {
                System.IO.File.Delete(SaveFilePath);
                agAnimationUtils.SaveAnimationFile(AGAnimationContainer, SaveFilePath, esriArcGISVersion.esriArcGISVersion10);
            }
        }