zoukankan      html  css  js  c++  java
  • ArcGlobe组件开发之动画4——加载保存动画

    前面的几篇博文提高了3D符号化以及根据路径创建动画方面的内容,先来看下效果图:


    那么创建的动画应该怎么保存呢?通过查找帮助文档以及OMD,可以知道Globe实现了IBasicScene接口和IBasicScene2接口,通过其LoadAnimationSaveAnimation方法就可以加载和保存动画文件。如下图:


    代码如下:

     //加载动画文件 .aga
            private void button_loadAnimation_Click (object sender,EventArgs e)
            {
                try
                {
                    OpenFileDialog openDlgAnimation = new OpenFileDialog();
                    openDlgAnimation.Title = "加载动画文件(.aga)";
                    openDlgAnimation.Filter = "动画文件(*.aga)|*.aga";
                    string strAnimationName = "";
                    DialogResult Dr = openDlgAnimation.ShowDialog();
                    if (Dr==DialogResult.OK)
                    {
                        strAnimationName = openDlgAnimation.FileName;
                        IGlobe globe = m_globeControl.Globe;
                        IBasicScene basicscene = globe as IBasicScene;
                        basicscene.LoadAnimation(strAnimationName);
                    }
                }
                catch (System.Exception ex)
                {
                	MyMessagebox pMyMessagebox=new MyMessagebox(ex.Message);
                    pMyMessagebox.Show();
                }
               
            }
            //保存动画文件
            private void button_SaveAnimation_Click (object sender,EventArgs e)
            {
                IGlobe globe = m_globeControl.Globe;
                int tracksCount = (globe as IAGAnimationTracks).AGTracks.Count;
                if (tracksCount>0)
                {
                    IBasicScene2 basicscene = globe as IBasicScene2;
                    OpenFileDialog openSaveAnimationDlg = new OpenFileDialog();
                    openSaveAnimationDlg.Title = "选择动画存放路径";
                    openSaveAnimationDlg.Filter = "动画文件(*.aga)|*.aga";
                    openSaveAnimationDlg.FileName = "输电线路动画.aga";
                    DialogResult DR = openSaveAnimationDlg.ShowDialog();
                    if (DR==DialogResult.OK)
                    {
                        basicscene.SaveAnimation(openSaveAnimationDlg.FileName);
                    } 
                    else
                    {
                        MyMessagebox pMymessagebox = new MyMessagebox("动画未保存!");
                        pMymessagebox.Show();
                    }
    
                } 
                else
                {
                    MyMessagebox mymessagebox = new MyMessagebox("当前视图不包含动画文件!");
                    mymessagebox.Show();
                }
    
       
    
            }

    下面一片博文将介绍如何在globeControl下播放动画,敬请关注!

  • 相关阅读:
    2017.10.20
    2017.10.14
    2017.10.19
    2017.10.18
    2017.10.17
    软件工程个人作业02
    构建之法读后感03
    构建之法阅读笔记02
    二柱子问题(随机产生四则运算题目)
    课后作业2(构建之法阅读计划)
  • 原文地址:https://www.cnblogs.com/giser-whu/p/3707067.html
Copyright © 2011-2022 走看看