private void PlayAnimationFast(int cycles, int iteration)
		{
			IGlobe globe = axGlobeControl1.Globe;
			IGlobeDisplay globeDisplay = globe.GlobeDisplay;
			Scene scene = (Scene) globeDisplay.Scene;
			IAnimationTracks sceneTracks = (IAnimationTracks) scene;

			IArray trackCamArray = new ArrayClass();
			IArray trackGlbArray = new ArrayClass();
			IArray trackLyrArray = new ArrayClass();

			string sError;
			if (sceneTracks.TrackCount == 0)
			{
				sError = m_AnimFilePath;
				if (sError == "")
				{
					sError = "To get a Sample animation file, Developer Kit Samples need to be installed!";
					System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A  + sError);
				}
				else
				{
					System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A  + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample.");
				}
				return;
			}
			
			IAnimationTrack track;
			IAnimationTrack trackLayer;
			IAnimationTrack trackGlobe = null;
			IAnimationType animType;
			IAnimationType animLayer;
			IAnimationType animGlobeCam = null;
			IKeyframe kFGlbCam;
			IKeyframe kFGlbLayer;
			int k;
			int[] count = new int[1000];

			//get each track from the scene and store tracks of the same kind in an Array
			for (int i=0; i<=sceneTracks.TrackCount-1;i++)
			{
				track = (IAnimationTrack) sceneTracks.Tracks.get_Element(i);
				k = i;
				animType = track.AnimationType;

				if (animType.CLSID.Value.ToString() == "{7CCBA704-3933-4D7A-8E89-4DFEE88AA937}")
				{
					//GlobeLayer
					trackLayer = new AnimationTrackClass();
					trackLayer = track;
					trackLayer.AnimationType = animType;
					kFGlbLayer = new GlobeLayerKeyframeClass();
					animLayer = animType;
					//Store the keyframe count of each track in an array
					count[i] = trackLayer.KeyframeCount;
					trackLyrArray.Add(trackLayer);
				}
				else if (animType.CLSID.Value.ToString() == "{D4565495-E2F9-4D89-A8A7-D0B69FD7A424}")
				{
					//Globe Camera type
					trackGlobe = new AnimationTrackClass();
					trackGlobe = track;
					trackGlobe.AnimationType = animType;
					kFGlbCam = new GlobeCameraKeyframeClass();
					animGlobeCam = animType;
					//Store the keyframe count of each track in an array
					count[i] = trackGlobe.KeyframeCount;
					trackGlbArray.Add(trackGlobe);
				}
				else
				{
					System.Windows.Forms.MessageBox.Show("Animation Type " + animType.Name + " Not Supported. Check if the animation File is Valid!");
					return;
				}
			}

			int larger = Greatest(ref count);
			//if nothing gets passed by the argument it takes the max no of keyframes
			if (iteration == 0) iteration = larger;

			IAnimationTrack trackCamera;
			IAnimationType animCam = null;
			IKeyframe kFBkmark;
			double time = 0;
			int keyFrameLayerCount; int keyFrameCameraCount; int keyFrameCount;

			for (int i=1; i<=cycles; i++) //no of cycles...
			{
				for (int start=0; start<=iteration; start++) //no of iterations...
				{
					for (int j=0; j<=trackCamArray.Count-1; j++)
					{
						trackCamera = (IAnimationTrack) trackCamArray.get_Element(j);
						if (trackCamera != null)
						{
							if (time >= trackCamera.BeginTime)
							{
								keyFrameCameraCount = trackGlobe.KeyframeCount;
								kFBkmark = trackCamera.get_Keyframe(keyFrameCameraCount - keyFrameCameraCount);
								//reset object
								animCam.ResetObject(scene, kFBkmark);
								//interpolate by using track
								trackCamera.InterpolateObjectProperties(scene, time);
								keyFrameCameraCount = keyFrameCameraCount - 1;
							}
						}
					}

					for (k=0; k<=trackGlbArray.Count-1;k++)
					{
						trackGlobe = (IAnimationTrack) trackGlbArray.get_Element(k);
						if (trackGlobe != null)
						{
							if (time >= trackGlobe.BeginTime)
							{
								keyFrameCount = trackGlobe.KeyframeCount;
								kFGlbCam = trackGlobe.get_Keyframe(trackGlobe.KeyframeCount - keyFrameCount);
								//reset object
								animGlobeCam.ResetObject(scene, kFGlbCam);
								//interpolate by using track
								trackGlobe.InterpolateObjectProperties(scene, time);
								keyFrameCount = keyFrameCount - 1;
							}
						}
					}

					for (int t=0; t<=trackLyrArray.Count-1; t++)
					{
						trackLayer = (IAnimationTrack) trackLyrArray.get_Element(t);
						if (trackLayer != null)
						{
							if (time >= trackLayer.BeginTime)
							{
								keyFrameLayerCount = trackLayer.KeyframeCount;
								kFGlbLayer = trackLayer.get_Keyframe(trackLayer.KeyframeCount - keyFrameLayerCount);
								//interpolate by using track
								trackLayer.InterpolateObjectProperties(scene, time);
								keyFrameLayerCount = keyFrameLayerCount - 1;
							}
						}
					}

					//reset interpolation Point
					time = start / iteration;
					//refresh the globeviewer(s)
					globeDisplay.RefreshViewers();
				}
			}
		}
Esempio n. 2
0
        private void PlayAnimationFast(int cycles, int iteration)
        {
            IGlobe           globe        = axGlobeControl1.Globe;
            IGlobeDisplay    globeDisplay = globe.GlobeDisplay;
            Scene            scene        = (Scene)globeDisplay.Scene;
            IAnimationTracks sceneTracks  = (IAnimationTracks)scene;

            IArray trackCamArray = new ArrayClass();
            IArray trackGlbArray = new ArrayClass();
            IArray trackLyrArray = new ArrayClass();

            string sError;

            if (sceneTracks.TrackCount == 0)
            {
                sError = m_AnimFilePath;
                if (sError == "")
                {
                    sError = "To get a Sample animation file, Developer Kit Samples need to be installed!";
                    System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + sError);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample.");
                }
                return;
            }

            IAnimationTrack track;
            IAnimationTrack trackLayer;
            IAnimationTrack trackGlobe = null;
            IAnimationType  animType;
            IAnimationType  animLayer;
            IAnimationType  animGlobeCam = null;
            IKeyframe       kFGlbCam;
            IKeyframe       kFGlbLayer;
            int             k;

            int[] count = new int[1000];

            //get each track from the scene and store tracks of the same kind in an Array
            for (int i = 0; i <= sceneTracks.TrackCount - 1; i++)
            {
                track    = (IAnimationTrack)sceneTracks.Tracks.get_Element(i);
                k        = i;
                animType = track.AnimationType;

                if (animType.CLSID.Value.ToString() == "{7CCBA704-3933-4D7A-8E89-4DFEE88AA937}")
                {
                    //GlobeLayer
                    trackLayer = new AnimationTrackClass();
                    trackLayer = track;
                    trackLayer.AnimationType = animType;
                    kFGlbLayer = new GlobeLayerKeyframeClass();
                    animLayer  = animType;
                    //Store the keyframe count of each track in an array
                    count[i] = trackLayer.KeyframeCount;
                    trackLyrArray.Add(trackLayer);
                }
                else if (animType.CLSID.Value.ToString() == "{D4565495-E2F9-4D89-A8A7-D0B69FD7A424}")
                {
                    //Globe Camera type
                    trackGlobe = new AnimationTrackClass();
                    trackGlobe = track;
                    trackGlobe.AnimationType = animType;
                    kFGlbCam     = new GlobeCameraKeyframeClass();
                    animGlobeCam = animType;
                    //Store the keyframe count of each track in an array
                    count[i] = trackGlobe.KeyframeCount;
                    trackGlbArray.Add(trackGlobe);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Animation Type " + animType.Name + " Not Supported. Check if the animation File is Valid!");
                    return;
                }
            }

            int larger = Greatest(ref count);

            //if nothing gets passed by the argument it takes the max no of keyframes
            if (iteration == 0)
            {
                iteration = larger;
            }

            IAnimationTrack trackCamera;
            IAnimationType  animCam = null;
            IKeyframe       kFBkmark;
            double          time = 0;
            int             keyFrameLayerCount; int keyFrameCameraCount; int keyFrameCount;

            for (int i = 1; i <= cycles; i++)                    //no of cycles...
            {
                for (int start = 0; start <= iteration; start++) //no of iterations...
                {
                    for (int j = 0; j <= trackCamArray.Count - 1; j++)
                    {
                        trackCamera = (IAnimationTrack)trackCamArray.get_Element(j);
                        if (trackCamera != null)
                        {
                            if (time >= trackCamera.BeginTime)
                            {
                                keyFrameCameraCount = trackGlobe.KeyframeCount;
                                kFBkmark            = trackCamera.get_Keyframe(keyFrameCameraCount - keyFrameCameraCount);
                                //reset object
                                animCam.ResetObject(scene, kFBkmark);
                                //interpolate by using track
                                trackCamera.InterpolateObjectProperties(scene, time);
                                keyFrameCameraCount = keyFrameCameraCount - 1;
                            }
                        }
                    }

                    for (k = 0; k <= trackGlbArray.Count - 1; k++)
                    {
                        trackGlobe = (IAnimationTrack)trackGlbArray.get_Element(k);
                        if (trackGlobe != null)
                        {
                            if (time >= trackGlobe.BeginTime)
                            {
                                keyFrameCount = trackGlobe.KeyframeCount;
                                kFGlbCam      = trackGlobe.get_Keyframe(trackGlobe.KeyframeCount - keyFrameCount);
                                //reset object
                                animGlobeCam.ResetObject(scene, kFGlbCam);
                                //interpolate by using track
                                trackGlobe.InterpolateObjectProperties(scene, time);
                                keyFrameCount = keyFrameCount - 1;
                            }
                        }
                    }

                    for (int t = 0; t <= trackLyrArray.Count - 1; t++)
                    {
                        trackLayer = (IAnimationTrack)trackLyrArray.get_Element(t);
                        if (trackLayer != null)
                        {
                            if (time >= trackLayer.BeginTime)
                            {
                                keyFrameLayerCount = trackLayer.KeyframeCount;
                                kFGlbLayer         = trackLayer.get_Keyframe(trackLayer.KeyframeCount - keyFrameLayerCount);
                                //interpolate by using track
                                trackLayer.InterpolateObjectProperties(scene, time);
                                keyFrameLayerCount = keyFrameLayerCount - 1;
                            }
                        }
                    }

                    //reset interpolation Point
                    time = start / iteration;
                    //refresh the globeviewer(s)
                    globeDisplay.RefreshViewers();
                }
            }
        }