在动画开发中,录制的一个动画可能只有一个Track也可能有多个Track。前面的博文提到动画的实现方式有两种,这里采用基于Camera的动画。这里我做的比较简单,首先来看实现效果图:
下面,我们来看,如何在Globe下实现动画的播放。来看下面的OMD图,从这张图里我们可以看出,Globe包含多个Track(轨迹),Track包含多个KeyFrame(关键帧);动画类型主要有基于Camera的和基于Layer,再有就是前面提到的基于关键帧的三种类型。那么具体如何做呢?我们一步一步来看:
(1)AnimationExtension
IGlobe globe = globecontrol.Globe; IBasicScene2 basicscene = globe as IBasicScene2; IAnimationExtension animationEx = basicscene.AnimationExtension; agAnimationEnv = animationEx.AnimationEnvironment;(2)获取AGAnimationEnvironment 对象后就可以设置播放的参数,比如播放模式,持续时间等参数
//设置动画播放参数 private void SetAnimationEnv () { //获取AGAnimationEnvironment对象 IGlobe globe = globecontrol.Globe; IBasicScene2 basicscene = globe as IBasicScene2; IAnimationExtension animationEx = basicscene.AnimationExtension; agAnimationEnv = animationEx.AnimationEnvironment; agAnimationEnv.AnimationDuration = Convert.ToDouble(textBox_AnimationDuration.Text);//持续时间 agAnimationEnv.PlayType=esriAnimationPlayType.esriAnimationPlayTypeDuration; //播放模式 Set_Animation_PlayMode(); agAnimationEnv.PlayMode = animationPlayMode; } //设置播放模式 private void Set_Animation_PlayMode () { switch (comboBox_PlayMode.Text) { case "正向播放一次": animationPlayMode = esriAnimationPlayMode.esriAnimationPlayOnceForward; break; case "反向播放一次": animationPlayMode = esriAnimationPlayMode.esriAnimationPlayOnceReverse; break; case "正向循环": animationPlayMode = esriAnimationPlayMode.esriAnimationPlayLoopForward; break; case "正反循环": animationPlayMode = esriAnimationPlayMode.esriAnimationPlayLoopReverse; break; default: break; } }
IAGAnimationPlayer agAnimationPlayer new AGAnimationEnvironmentClass();
agAnimationPlayer.PlayAnimation(agAnimationTracks,agAnimationEnv,null);
//选中播放轨迹可见,其余不可见 private void enableSelectedTrack () { string selectedTrackName = agAnimationTrack.Name; IArray tracksArray = agAnimationTracks.AGTracks; int trackCount = tracksArray.Count; if (trackCount>0) { for(int i = 0;i < trackCount;i++) { IAGAnimationTrack track_temp = tracksArray.get_Element(i) as IAGAnimationTrack; if(track_temp.Name==selectedTrackName) { track_temp.IsEnabled = true; } else if (track_temp.Name!=selectedTrackName) { IAGAnimationTrack track2Disabled; agAnimationTracks.FindTrack(track_temp.Name,out track2Disabled); track2Disabled.IsEnabled = false; } } } }
ArcGlobe组件开发之动画——播放动画,布布扣,bubuko.com
原文:http://blog.csdn.net/liushuo_whu/article/details/23215197