About the Animation in the GlobeControl Sample
[C#]
Animation.cs
using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Analyst3D; using ESRI.ArcGIS.GlobeCore; using System; using System.Windows.Forms; using System.Security.Permissions; using ESRI.ArcGIS; namespace GlobeCntrlAnimation { public class Form1 : System.Windows.Forms.Form { public System.Windows.Forms.Label lblStatus; public System.Windows.Forms.GroupBox FrmAnim; public System.Windows.Forms.Button CmdPlay; public System.Windows.Forms.TextBox txtDuration; public System.Windows.Forms.TextBox TxtFrequency; public System.Windows.Forms.RadioButton OptDuration; public System.Windows.Forms.RadioButton OptIteration; public System.Windows.Forms.Button CmdLoad; public System.Windows.Forms.Label Label1; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.ComponentModel.Container components = null; private ESRI.ArcGIS.Controls.AxToolbarControl axToolbarControl1; private ESRI.ArcGIS.Controls.AxTOCControl axTOCControl1; private ESRI.ArcGIS.Controls.AxGlobeControl axGlobeControl1; private ESRI.ArcGIS.Controls.AxLicenseControl axLicenseControl1; private string m_AnimFilePath; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { //Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown(); if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.lblStatus = new System.Windows.Forms.Label(); this.FrmAnim = new System.Windows.Forms.GroupBox(); this.CmdPlay = new System.Windows.Forms.Button(); this.txtDuration = new System.Windows.Forms.TextBox(); this.TxtFrequency = new System.Windows.Forms.TextBox(); this.OptDuration = new System.Windows.Forms.RadioButton(); this.OptIteration = new System.Windows.Forms.RadioButton(); this.CmdLoad = new System.Windows.Forms.Button(); this.Label1 = new System.Windows.Forms.Label(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl(); this.axTOCControl1 = new ESRI.ArcGIS.Controls.AxTOCControl(); this.axGlobeControl1 = new ESRI.ArcGIS.Controls.AxGlobeControl(); this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl(); this.FrmAnim.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axGlobeControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit(); this.SuspendLayout(); // // lblStatus // this.lblStatus.BackColor = System.Drawing.SystemColors.Control; this.lblStatus.Cursor = System.Windows.Forms.Cursors.Default; this.lblStatus.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.lblStatus.ForeColor = System.Drawing.SystemColors.ControlText; this.lblStatus.Location = new System.Drawing.Point(8, 376); this.lblStatus.Name = "lblStatus"; this.lblStatus.RightToLeft = System.Windows.Forms.RightToLeft.No; this.lblStatus.Size = new System.Drawing.Size(129, 54); this.lblStatus.TabIndex = 13; // // FrmAnim // this.FrmAnim.BackColor = System.Drawing.SystemColors.Control; this.FrmAnim.Controls.Add(this.CmdPlay); this.FrmAnim.Controls.Add(this.txtDuration); this.FrmAnim.Controls.Add(this.TxtFrequency); this.FrmAnim.Controls.Add(this.OptDuration); this.FrmAnim.Controls.Add(this.OptIteration); this.FrmAnim.Controls.Add(this.CmdLoad); this.FrmAnim.Controls.Add(this.Label1); this.FrmAnim.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.FrmAnim.ForeColor = System.Drawing.SystemColors.ControlText; this.FrmAnim.Location = new System.Drawing.Point(144, 376); this.FrmAnim.Name = "FrmAnim"; this.FrmAnim.RightToLeft = System.Windows.Forms.RightToLeft.No; this.FrmAnim.Size = new System.Drawing.Size(461, 55); this.FrmAnim.TabIndex = 12; this.FrmAnim.TabStop = false; // // CmdPlay // this.CmdPlay.BackColor = System.Drawing.SystemColors.Control; this.CmdPlay.Cursor = System.Windows.Forms.Cursors.Default; this.CmdPlay.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.CmdPlay.ForeColor = System.Drawing.SystemColors.ControlText; this.CmdPlay.Location = new System.Drawing.Point(266, 10); this.CmdPlay.Name = "CmdPlay"; this.CmdPlay.RightToLeft = System.Windows.Forms.RightToLeft.No; this.CmdPlay.Size = new System.Drawing.Size(81, 38); this.CmdPlay.TabIndex = 9; this.CmdPlay.Text = "Play Animation"; this.CmdPlay.Click += new System.EventHandler(this.CmdPlay_Click); // // txtDuration // this.txtDuration.AcceptsReturn = true; this.txtDuration.AutoSize = false; this.txtDuration.BackColor = System.Drawing.SystemColors.Window; this.txtDuration.Cursor = System.Windows.Forms.Cursors.IBeam; this.txtDuration.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.txtDuration.ForeColor = System.Drawing.SystemColors.WindowText; this.txtDuration.Location = new System.Drawing.Point(220, 13); this.txtDuration.MaxLength = 0; this.txtDuration.Name = "txtDuration"; this.txtDuration.RightToLeft = System.Windows.Forms.RightToLeft.No; this.txtDuration.Size = new System.Drawing.Size(40, 19); this.txtDuration.TabIndex = 8; this.txtDuration.Text = "10"; // // TxtFrequency // this.TxtFrequency.AcceptsReturn = true; this.TxtFrequency.AutoSize = false; this.TxtFrequency.BackColor = System.Drawing.SystemColors.Window; this.TxtFrequency.Cursor = System.Windows.Forms.Cursors.IBeam; this.TxtFrequency.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TxtFrequency.ForeColor = System.Drawing.SystemColors.WindowText; this.TxtFrequency.Location = new System.Drawing.Point(400, 13); this.TxtFrequency.MaxLength = 0; this.TxtFrequency.Name = "TxtFrequency"; this.TxtFrequency.RightToLeft = System.Windows.Forms.RightToLeft.No; this.TxtFrequency.Size = new System.Drawing.Size(40, 19); this.TxtFrequency.TabIndex = 7; this.TxtFrequency.Text = "2"; // // OptDuration // this.OptDuration.BackColor = System.Drawing.SystemColors.Control; this.OptDuration.Checked = true; this.OptDuration.Cursor = System.Windows.Forms.Cursors.Default; this.OptDuration.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.OptDuration.ForeColor = System.Drawing.SystemColors.ControlText; this.OptDuration.Location = new System.Drawing.Point(122, 8); this.OptDuration.Name = "OptDuration"; this.OptDuration.RightToLeft = System.Windows.Forms.RightToLeft.No; this.OptDuration.Size = new System.Drawing.Size(98, 17); this.OptDuration.TabIndex = 6; this.OptDuration.TabStop = true; this.OptDuration.Text = "Duration (secs)"; this.OptDuration.CheckedChanged += new System.EventHandler(this.OptDuration_CheckedChanged); // // OptIteration // this.OptIteration.BackColor = System.Drawing.SystemColors.Control; this.OptIteration.Cursor = System.Windows.Forms.Cursors.Default; this.OptIteration.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.OptIteration.ForeColor = System.Drawing.SystemColors.ControlText; this.OptIteration.Location = new System.Drawing.Point(122, 22); this.OptIteration.Name = "OptIteration"; this.OptIteration.RightToLeft = System.Windows.Forms.RightToLeft.No; this.OptIteration.Size = new System.Drawing.Size(94, 19); this.OptIteration.TabIndex = 5; this.OptIteration.TabStop = true; this.OptIteration.Text = "No. Iterations"; this.OptIteration.CheckedChanged += new System.EventHandler(this.OptIteration_CheckedChanged); // // CmdLoad // this.CmdLoad.BackColor = System.Drawing.SystemColors.Control; this.CmdLoad.Cursor = System.Windows.Forms.Cursors.Default; this.CmdLoad.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.CmdLoad.ForeColor = System.Drawing.SystemColors.ControlText; this.CmdLoad.Location = new System.Drawing.Point(9, 10); this.CmdLoad.Name = "CmdLoad"; this.CmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No; this.CmdLoad.Size = new System.Drawing.Size(94, 38); this.CmdLoad.TabIndex = 4; this.CmdLoad.Text = "Load Animation File (*.aga)"; this.CmdLoad.Click += new System.EventHandler(this.CmdLoad_Click); // // Label1 // this.Label1.BackColor = System.Drawing.SystemColors.Control; this.Label1.Cursor = System.Windows.Forms.Cursors.Default; this.Label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Label1.ForeColor = System.Drawing.SystemColors.ControlText; this.Label1.Location = new System.Drawing.Point(354, 14); this.Label1.Name = "Label1"; this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No; this.Label1.Size = new System.Drawing.Size(36, 17); this.Label1.TabIndex = 10; this.Label1.Text = "Cycles:"; // // axToolbarControl1 // this.axToolbarControl1.Location = new System.Drawing.Point(8, 8); this.axToolbarControl1.Name = "axToolbarControl1"; this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState"))); this.axToolbarControl1.Size = new System.Drawing.Size(592, 28); this.axToolbarControl1.TabIndex = 14; this.axToolbarControl1.OnItemClick += new ESRI.ArcGIS.Controls.IToolbarControlEvents_Ax_OnItemClickEventHandler(this.axToolbarControl1_OnItemClick); // // axTOCControl1 // this.axTOCControl1.Location = new System.Drawing.Point(8, 40); this.axTOCControl1.Name = "axTOCControl1"; this.axTOCControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axTOCControl1.OcxState"))); this.axTOCControl1.Size = new System.Drawing.Size(136, 328); this.axTOCControl1.TabIndex = 15; // // axGlobeControl1 // this.axGlobeControl1.Location = new System.Drawing.Point(144, 40); this.axGlobeControl1.Name = "axGlobeControl1"; this.axGlobeControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axGlobeControl1.OcxState"))); this.axGlobeControl1.Size = new System.Drawing.Size(456, 328); this.axGlobeControl1.TabIndex = 16; // // axLicenseControl1 // this.axLicenseControl1.Enabled = true; this.axLicenseControl1.Location = new System.Drawing.Point(384, 56); this.axLicenseControl1.Name = "axLicenseControl1"; this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState"))); this.axLicenseControl1.Size = new System.Drawing.Size(32, 32); this.axLicenseControl1.TabIndex = 17; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(608, 438); this.Controls.Add(this.axLicenseControl1); this.Controls.Add(this.axGlobeControl1); this.Controls.Add(this.axTOCControl1); this.Controls.Add(this.axToolbarControl1); this.Controls.Add(this.lblStatus); this.Controls.Add(this.FrmAnim); this.Name = "Form1"; this.Text = "GlobeControlAnimation"; this.Load += new System.EventHandler(this.Form1_Load); this.FrmAnim.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axTOCControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axGlobeControl1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit(); this.ResumeLayout(false); } #endregion [STAThread] static void Main() { if (!RuntimeManager.Bind(ProductCode.Engine)) { if (!RuntimeManager.Bind(ProductCode.Desktop)) { MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down."); return; } } Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { //check and load if the animation file is present... m_AnimFilePath = @"..\..\..\..\..\Data\ArcGlobeAnimation\AnimationSample.aga"; if (System.IO.File.Exists(m_AnimFilePath)) { //Load the sample animation file into the animation file into the doc... IGlobe globe = axGlobeControl1.Globe; IBasicScene basicScene = (IBasicScene) globe; basicScene.LoadAnimation(m_AnimFilePath); } else { //Disable Animation Player controls... OptDuration.Enabled = false; OptIteration.Enabled = false; txtDuration.Enabled = false; TxtFrequency.Enabled = false; TxtFrequency.Enabled = false; CmdPlay.Enabled = false; } Icon = null; } private void OptIteration_CheckedChanged(object sender, System.EventArgs e) { if (OptIteration.Checked == true) { //Set Default cycle and iteration.. txtDuration.Text = "500"; TxtFrequency.Text = "2"; } } private void OptDuration_CheckedChanged(object sender, System.EventArgs e) { if (OptDuration.Checked == true) { //Set Default cycle and iteration.. txtDuration.Text = "10"; TxtFrequency.Text = "2"; } } private void CmdPlay_Click(object sender, System.EventArgs e) { if (OptDuration.Checked == true) { double duration = Convert.ToInt32(txtDuration.Text); int numCycle = Convert.ToInt32(TxtFrequency.Text); //play the animation via duration PlayAnimation(duration, numCycle); } else { int iteration = Convert.ToInt32(txtDuration.Text); int cycles = Convert.ToInt32(TxtFrequency.Text); //play animation via iteration... PlayAnimationFast(cycles, iteration); } } private void CmdLoad_Click(object sender, System.EventArgs e) { openFileDialog1.Title = "Open ArcGlobe Animation File"; openFileDialog1.Filter = "ArcGlobe Animation Files (*.aga)|*.aga"; //set ArcGlobeAnimaton path folder as default path... if (m_AnimFilePath != "") { openFileDialog1.InitialDirectory = m_AnimFilePath; } else { openFileDialog1.InitialDirectory = Application.StartupPath; } openFileDialog1.ShowDialog(); //if the user selected an animation file string animFilePath = openFileDialog1.FileName; if (animFilePath == "") return; //sAnimFilePath IGlobe globe = axGlobeControl1.Globe; IBasicScene basicScene = (IBasicScene) globe; basicScene.LoadAnimation(animFilePath); //if loading of the animation succeeded, enable player controls... //Enable Animation Player controls... OptDuration.Enabled = true; OptIteration.Enabled = true; txtDuration.Enabled = true; TxtFrequency.Enabled = true; TxtFrequency.Enabled = true; CmdPlay.Enabled = true; } private int Greatest(ref int[] array) { //Function to find the largest count of keyframes (in any one of the Animation tracks) int max=0; int length = array.Length; for (int i=0; i<length; i++) { if (max == 0) { max = array[i]; } else if (array[i] > max) { max = array[i]; } } return max; } private void PlayAnimation(double duration, int numCycles) { IGlobe globe = axGlobeControl1.Globe; IAnimationTracks tracks = (IAnimationTracks) globe; IViewers3D viewers3D = globe.GlobeDisplay; //exit if document doesn't contain animation.. string sError; if (tracks.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; } DateTime startTime; TimeSpan timeSpan; int j; double elapsedTime; for (int i=1; i<=numCycles; i++) { startTime = DateTime.Now; j = 0; do { timeSpan = (DateTime.Now).Subtract(startTime); elapsedTime = timeSpan.TotalSeconds; if (elapsedTime > duration) elapsedTime = duration; tracks.ApplyTracks(null, elapsedTime, duration); viewers3D.RefreshViewers(); j = j + 1; } while (elapsedTime < duration); } } 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(); } } } private string routin_ReadRegistry(string sKey) { //Open the subkey for reading Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sKey,true); if (rk == null) return ""; // Get the data from a specified item in the key. return (string) rk.GetValue("InstallDir"); } private void axToolbarControl1_OnItemClick(object sender, ESRI.ArcGIS.Controls.IToolbarControlEvents_OnItemClickEvent e) { //Display help when fly tool and walk tools are selected... //check if key intercept is enabled,if not enable it. if (axGlobeControl1.KeyIntercept != 1) axGlobeControl1.KeyIntercept = 1; UID uID = axToolbarControl1.GetItem(e.index).UID; //uid for fly tool={2C327C42-8CA9-4FC3-8C7B-F6290680FABB} //uid for walk tool={56C3BDD4-C51A-4574-8954-D3E1F5F54E57} if (uID.Value.ToString() == "{2C327C42-8CA9-4FC3-8C7B-F6290680FABB}") { //fly... lblStatus.Text = "Use arrow up or arrow left keys to decelerate and arrow up or arrow left keys to accelerate."; } else if (uID.Value.ToString() == "{56C3BDD4-C51A-4574-8954-D3E1F5F54E57}") { //walk... lblStatus.Text = "Use arrow up or down keys to change elevation and the arrow left or right keys to fine-tune travel speed."; } else { lblStatus.Text = ""; } } } }
[Visual Basic .NET]
Animation.vb
Option Strict Off Option Explicit On Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Analyst3D Imports ESRI.ArcGIS.GlobeCore Imports System.Security.Permissions Imports ESRI.ArcGIS Friend Class frmGlbCntrl Inherits System.Windows.Forms.Form <STAThread()> _ Shared Sub Main() 'Load runtime If Not RuntimeManager.Bind(ProductCode.Engine) Then If Not RuntimeManager.Bind(ProductCode.Desktop) Then MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.") System.Environment.Exit(1) ' Force exit or other indication in the application End If End If Application.Run(New frmGlbCntrl()) End Sub #Region "Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) 'Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown() If Disposing Then If Not components Is Nothing Then components.Dispose() End If End If MyBase.Dispose(Disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer Public WithEvents CmdPlay As System.Windows.Forms.Button Public WithEvents txtDuration As System.Windows.Forms.TextBox Public WithEvents TxtFrequency As System.Windows.Forms.TextBox Public WithEvents OptDuration As System.Windows.Forms.RadioButton Public WithEvents OptIteration As System.Windows.Forms.RadioButton Public WithEvents CmdLoad As System.Windows.Forms.Button Public WithEvents Label1 As System.Windows.Forms.Label Public WithEvents FrmAnim As System.Windows.Forms.GroupBox Public WithEvents lblStatus As System.Windows.Forms.Label 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog Friend WithEvents AxLicenseControl2 As ESRI.ArcGIS.Controls.AxLicenseControl Friend WithEvents AxToolbarControl1 As ESRI.ArcGIS.Controls.AxToolbarControl Friend WithEvents AxGlobeControl1 As ESRI.ArcGIS.Controls.AxGlobeControl Friend WithEvents AxTOCControl1 As ESRI.ArcGIS.Controls.AxTOCControl <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmGlbCntrl)) Me.FrmAnim = New System.Windows.Forms.GroupBox Me.CmdPlay = New System.Windows.Forms.Button Me.txtDuration = New System.Windows.Forms.TextBox Me.TxtFrequency = New System.Windows.Forms.TextBox Me.OptDuration = New System.Windows.Forms.RadioButton Me.OptIteration = New System.Windows.Forms.RadioButton Me.CmdLoad = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.lblStatus = New System.Windows.Forms.Label Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.AxGlobeControl1 = New ESRI.ArcGIS.Controls.AxGlobeControl Me.AxLicenseControl2 = New ESRI.ArcGIS.Controls.AxLicenseControl Me.AxTOCControl1 = New ESRI.ArcGIS.Controls.AxTOCControl Me.AxToolbarControl1 = New ESRI.ArcGIS.Controls.AxToolbarControl Me.FrmAnim.SuspendLayout() CType(Me.AxGlobeControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxLicenseControl2, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxTOCControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'FrmAnim ' Me.FrmAnim.BackColor = System.Drawing.SystemColors.Control Me.FrmAnim.Controls.Add(Me.CmdPlay) Me.FrmAnim.Controls.Add(Me.txtDuration) Me.FrmAnim.Controls.Add(Me.TxtFrequency) Me.FrmAnim.Controls.Add(Me.OptDuration) Me.FrmAnim.Controls.Add(Me.OptIteration) Me.FrmAnim.Controls.Add(Me.CmdLoad) Me.FrmAnim.Controls.Add(Me.Label1) Me.FrmAnim.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.FrmAnim.ForeColor = System.Drawing.SystemColors.ControlText Me.FrmAnim.Location = New System.Drawing.Point(143, 433) Me.FrmAnim.Name = "FrmAnim" Me.FrmAnim.RightToLeft = System.Windows.Forms.RightToLeft.No Me.FrmAnim.Size = New System.Drawing.Size(461, 55) Me.FrmAnim.TabIndex = 3 Me.FrmAnim.TabStop = False ' 'CmdPlay ' Me.CmdPlay.BackColor = System.Drawing.SystemColors.Control Me.CmdPlay.Cursor = System.Windows.Forms.Cursors.Default Me.CmdPlay.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.CmdPlay.ForeColor = System.Drawing.SystemColors.ControlText Me.CmdPlay.Location = New System.Drawing.Point(266, 10) Me.CmdPlay.Name = "CmdPlay" Me.CmdPlay.RightToLeft = System.Windows.Forms.RightToLeft.No Me.CmdPlay.Size = New System.Drawing.Size(81, 38) Me.CmdPlay.TabIndex = 9 Me.CmdPlay.Text = "Play Animation" ' 'txtDuration ' Me.txtDuration.AcceptsReturn = True Me.txtDuration.AutoSize = False Me.txtDuration.BackColor = System.Drawing.SystemColors.Window Me.txtDuration.Cursor = System.Windows.Forms.Cursors.IBeam Me.txtDuration.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtDuration.ForeColor = System.Drawing.SystemColors.WindowText Me.txtDuration.Location = New System.Drawing.Point(220, 13) Me.txtDuration.MaxLength = 0 Me.txtDuration.Name = "txtDuration" Me.txtDuration.RightToLeft = System.Windows.Forms.RightToLeft.No Me.txtDuration.Size = New System.Drawing.Size(40, 19) Me.txtDuration.TabIndex = 8 Me.txtDuration.Text = "10" ' 'TxtFrequency ' Me.TxtFrequency.AcceptsReturn = True Me.TxtFrequency.AutoSize = False Me.TxtFrequency.BackColor = System.Drawing.SystemColors.Window Me.TxtFrequency.Cursor = System.Windows.Forms.Cursors.IBeam Me.TxtFrequency.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TxtFrequency.ForeColor = System.Drawing.SystemColors.WindowText Me.TxtFrequency.Location = New System.Drawing.Point(400, 13) Me.TxtFrequency.MaxLength = 0 Me.TxtFrequency.Name = "TxtFrequency" Me.TxtFrequency.RightToLeft = System.Windows.Forms.RightToLeft.No Me.TxtFrequency.Size = New System.Drawing.Size(40, 19) Me.TxtFrequency.TabIndex = 7 Me.TxtFrequency.Text = "2" ' 'OptDuration ' Me.OptDuration.BackColor = System.Drawing.SystemColors.Control Me.OptDuration.Checked = True Me.OptDuration.Cursor = System.Windows.Forms.Cursors.Default Me.OptDuration.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.OptDuration.ForeColor = System.Drawing.SystemColors.ControlText Me.OptDuration.Location = New System.Drawing.Point(122, 8) Me.OptDuration.Name = "OptDuration" Me.OptDuration.RightToLeft = System.Windows.Forms.RightToLeft.No Me.OptDuration.Size = New System.Drawing.Size(98, 17) Me.OptDuration.TabIndex = 6 Me.OptDuration.TabStop = True Me.OptDuration.Text = "Duration (secs)" ' 'OptIteration ' Me.OptIteration.BackColor = System.Drawing.SystemColors.Control Me.OptIteration.Cursor = System.Windows.Forms.Cursors.Default Me.OptIteration.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.OptIteration.ForeColor = System.Drawing.SystemColors.ControlText Me.OptIteration.Location = New System.Drawing.Point(122, 22) Me.OptIteration.Name = "OptIteration" Me.OptIteration.RightToLeft = System.Windows.Forms.RightToLeft.No Me.OptIteration.Size = New System.Drawing.Size(94, 19) Me.OptIteration.TabIndex = 5 Me.OptIteration.TabStop = True Me.OptIteration.Text = "No. Iterations" ' 'CmdLoad ' Me.CmdLoad.BackColor = System.Drawing.SystemColors.Control Me.CmdLoad.Cursor = System.Windows.Forms.Cursors.Default Me.CmdLoad.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.CmdLoad.ForeColor = System.Drawing.SystemColors.ControlText Me.CmdLoad.Location = New System.Drawing.Point(9, 10) Me.CmdLoad.Name = "CmdLoad" Me.CmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No Me.CmdLoad.Size = New System.Drawing.Size(94, 38) Me.CmdLoad.TabIndex = 4 Me.CmdLoad.Text = "Load Animation File (*.aga)" ' 'Label1 ' Me.Label1.BackColor = System.Drawing.SystemColors.Control Me.Label1.Cursor = System.Windows.Forms.Cursors.Default Me.Label1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText Me.Label1.Location = New System.Drawing.Point(354, 14) Me.Label1.Name = "Label1" Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label1.Size = New System.Drawing.Size(36, 17) Me.Label1.TabIndex = 10 Me.Label1.Text = "Cycles:" ' 'lblStatus ' Me.lblStatus.BackColor = System.Drawing.SystemColors.Control Me.lblStatus.Cursor = System.Windows.Forms.Cursors.Default Me.lblStatus.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblStatus.ForeColor = System.Drawing.SystemColors.ControlText Me.lblStatus.Location = New System.Drawing.Point(6, 439) Me.lblStatus.Name = "lblStatus" Me.lblStatus.RightToLeft = System.Windows.Forms.RightToLeft.No Me.lblStatus.Size = New System.Drawing.Size(129, 54) Me.lblStatus.TabIndex = 11 ' 'AxGlobeControl1 ' Me.AxGlobeControl1.Location = New System.Drawing.Point(144, 40) Me.AxGlobeControl1.Name = "AxGlobeControl1" Me.AxGlobeControl1.OcxState = CType(resources.GetObject("AxGlobeControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxGlobeControl1.Size = New System.Drawing.Size(456, 392) Me.AxGlobeControl1.TabIndex = 12 ' 'AxLicenseControl2 ' Me.AxLicenseControl2.Enabled = True Me.AxLicenseControl2.Location = New System.Drawing.Point(152, 368) Me.AxLicenseControl2.Name = "AxLicenseControl2" Me.AxLicenseControl2.OcxState = CType(resources.GetObject("AxLicenseControl2.OcxState"), System.Windows.Forms.AxHost.State) Me.AxLicenseControl2.Size = New System.Drawing.Size(200, 50) Me.AxLicenseControl2.TabIndex = 13 ' 'AxTOCControl1 ' Me.AxTOCControl1.Location = New System.Drawing.Point(8, 40) Me.AxTOCControl1.Name = "AxTOCControl1" Me.AxTOCControl1.OcxState = CType(resources.GetObject("AxTOCControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxTOCControl1.Size = New System.Drawing.Size(136, 392) Me.AxTOCControl1.TabIndex = 14 ' 'AxToolbarControl1 ' Me.AxToolbarControl1.Location = New System.Drawing.Point(8, 8) Me.AxToolbarControl1.Name = "AxToolbarControl1" Me.AxToolbarControl1.OcxState = CType(resources.GetObject("AxToolbarControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxToolbarControl1.Size = New System.Drawing.Size(592, 28) Me.AxToolbarControl1.TabIndex = 15 ' 'frmGlbCntrl ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.Control Me.ClientSize = New System.Drawing.Size(609, 494) Me.Controls.Add(Me.AxToolbarControl1) Me.Controls.Add(Me.AxTOCControl1) Me.Controls.Add(Me.AxLicenseControl2) Me.Controls.Add(Me.AxGlobeControl1) Me.Controls.Add(Me.FrmAnim) Me.Controls.Add(Me.lblStatus) Me.Cursor = System.Windows.Forms.Cursors.Default Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Location = New System.Drawing.Point(4, 23) Me.MaximizeBox = False Me.Name = "frmGlbCntrl" Me.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Text = "GlobeControlAnimation" Me.FrmAnim.ResumeLayout(False) CType(Me.AxGlobeControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxLicenseControl2, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxTOCControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Private m_sAnimFilePath As String Private Sub CmdLoad_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdLoad.Click OpenFileDialog1.Title = "Open ArcGlobe Animation File" OpenFileDialog1.Filter = "ArcGlobe Animation Files (*.aga)|*.aga" 'set ArcGlobeAnimaton path folder as default path... If Not m_sAnimFilePath = "" Then OpenFileDialog1.InitialDirectory = m_sAnimFilePath Else OpenFileDialog1.InitialDirectory = Application.StartupPath End If OpenFileDialog1.ShowDialog() 'if the user selected an animation file Dim sAnimFilePath As String sAnimFilePath = OpenFileDialog1.FileName If sAnimFilePath = "" Then Exit Sub 'sAnimFilePath Dim pBasicScene As IBasicScene Dim pGlobe As IGlobe pGlobe = AxGlobeControl1.Globe pBasicScene = pglobe pBasicScene.LoadAnimation(sAnimFilePath) 'if loading of the animation succeeded, enable player controls... 'Enable Animation Player controls... OptDuration.Enabled = True OptIteration.Enabled = True txtDuration.Enabled = True TxtFrequency.Enabled = True TxtFrequency.Enabled = True CmdPlay.Enabled = True End Sub Private Sub frmGlbCntrl_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load Dim pBasicScene As IBasicScene Dim pGlobe As IGlobe 'check and load if the animation file is present... m_sAnimFilePath = "..\..\..\..\..\Data\ArcGlobeAnimation\AnimationSample.aga" If System.IO.File.Exists(m_sAnimFilePath) Then 'Load the sample animation file into the animation file into the doc... pGlobe = AxGlobeControl1.Globe pBasicScene = pGlobe pBasicScene.LoadAnimation(m_sAnimFilePath) Else 'Disable Animation Player controls... OptDuration.Enabled = False OptIteration.Enabled = False txtDuration.Enabled = False TxtFrequency.Enabled = False TxtFrequency.Enabled = False CmdPlay.Enabled = False End If Icon = Nothing End Sub Private Sub CmdPlay_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CmdPlay.Click Dim duration As Double, numCycle As Integer Dim iteration As Integer, cycles As Integer 'allows to handle when non integer character is entered in txtDuration.Text or TxtFrequency.Text On Error Resume Next If OptDuration.Checked Then duration = CInt(txtDuration.Text) numCycle = CInt(TxtFrequency.Text) 'play the animation via duration PlayAnimation(duration, numCycle) Else iteration = CInt(txtDuration.Text) cycles = CInt(TxtFrequency.Text) 'play animation via iteration... PlayAnimationFast(cycles, iteration) End If End Sub Private Sub PlayAnimation(ByRef duration As Double, ByRef numCycles As Integer) Dim pGlobe As IGlobe Dim pTracks As IAnimationTracks Dim viewers3D As IViewers3D pGlobe = AxGlobeControl1.Globe pTracks = pGlobe viewers3D = pGlobe.GlobeDisplay 'exit if document doesn't contain animation.. Dim sError As String If pTracks.TrackCount = 0 Then sError = m_sAnimFilePath If sError = "" Then 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." & Chr(13) & sError) Else System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." & Chr(13) & "Load " & m_sAnimFilePath & "\AnimationSample.aga for sample.") End If Exit Sub End If Dim startTime As DateTime, timeSpan As TimeSpan Dim elapsedTime As Integer, i As Integer, j As Integer For i = 1 To numCycles Step 1 startTime = DateTime.Now j = 0 Do timeSpan = DateTime.Now().Subtract(startTime) elapsedTime = timeSpan.TotalSeconds If (elapsedTime > duration) Then elapsedTime = duration End If pTracks.ApplyTracks(Nothing, elapsedTime, duration) viewers3D.RefreshViewers() j = j + 1 Loop While elapsedTime < duration Next i End Sub Private Sub PlayAnimationFast(Optional ByVal cycles As Integer = 0, Optional ByVal iteration As Integer = 0) Dim pGlobe As IGlobe Dim pGlobeDisplay As IGlobeDisplay Dim pScene As Scene Dim pSceneTracks As IAnimationTracks pGlobe = AxGlobeControl1.Globe pGlobeDisplay = pGlobe.GlobeDisplay pScene = pGlobeDisplay.Scene pSceneTracks = pScene Dim pCollection As Collection Dim pTrackCamArray As IArray Dim pTrackGlbArray As IArray Dim pTrackLyrArray As IArray pCollection = New Collection pTrackCamArray = New Array pTrackGlbArray = New Array pTrackLyrArray = New Array Dim sError As String If pSceneTracks.TrackCount = 0 Then sError = m_sAnimFilePath If sError = "" Then 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." & Chr(13) & sError) Else System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." & Chr(13) & "Load " & m_sAnimFilePath & "\AnimationSample.aga for sample.") End If Exit Sub End If Dim i As Integer, count() As Integer, k As Object Dim pTrack As IAnimationTrack Dim pTrackLayer As IAnimationTrack Dim pTrackGlobe As IAnimationTrack = Nothing Dim pAnimType As IAnimationType Dim pAnimLayer As IAnimationType Dim pAnimGlobeCam As IAnimationType = Nothing Dim pKFGlbCam As IKeyframe Dim pKFGlbLayer As IKeyframe 'get each track from the scene and store tracks of the same kind in an Array For i = 0 To pSceneTracks.TrackCount - 1 pTrack = pSceneTracks.Tracks.Element(i) ReDim Preserve count(i) k = i pAnimType = pTrack.AnimationType If pAnimType.CLSID.Value = "{7CCBA704-3933-4D7A-8E89-4DFEE88AA937}" Then 'GlobeLayer pTrackLayer = New AnimationTrackClass pTrackLayer = pTrack pTrackLayer.AnimationType = pAnimType pKFGlbLayer = New GlobeLayerKeyframeClass pAnimLayer = pAnimType 'Store the keyframe count of each track in an array count(i) = pTrackLayer.KeyframeCount pTrackLyrArray.Add(pTrackLayer) ElseIf pAnimType.CLSID.Value = "{D4565495-E2F9-4D89-A8A7-D0B69FD7A424}" Then 'Globe Camera type pTrackGlobe = New AnimationTrackClass pTrackGlobe = pTrack pTrackGlobe.AnimationType = pAnimType pKFGlbCam = New GlobeCameraKeyframeClass pAnimGlobeCam = pAnimType 'Store the keyframe count of each track in an array count(i) = pTrackGlobe.KeyframeCount pTrackGlbArray.Add(pTrackGlobe) Else System.Windows.Forms.MessageBox.Show("Animation Type " & pAnimType.Name & " Not Supported. Check if the animation File is Valid!") Exit Sub End If Next Dim larger As Integer larger = Greatest(count) ' if nothing gets passed by the argument it takes the max no of keyframes If IsNothing(iteration) Then iteration = larger Dim start As Integer, j As Integer, t As Integer Dim keyFrameCount As Integer, keyFrameCameraCount As Integer, keyFrameLayerCount As Integer Dim time As Double Dim pTrackCamera As IAnimationTrack Dim pAnimCam As IAnimationType = Nothing Dim pKFBkmark As IKeyframe For i = 1 To cycles 'Total number of cycles For start = 0 To iteration ' no of iterations... For j = 0 To pTrackCamArray.Count - 1 pTrackCamera = pTrackCamArray.Element(j) If Not pTrackCamera Is Nothing Then If time >= pTrackCamera.BeginTime Then keyFrameCameraCount = pTrackGlobe.KeyframeCount pKFBkmark = pTrackCamera.Keyframe(keyFrameCameraCount - keyFrameCameraCount) 'reset object pAnimCam.ResetObject(pScene, pKFBkmark) ' interpolate by using track pTrackCamera.InterpolateObjectProperties(pScene, time) keyFrameCameraCount = keyFrameCameraCount - 1 End If End If Next For k = 0 To pTrackGlbArray.Count - 1 pTrackGlobe = pTrackGlbArray.Element(k) If Not pTrackGlobe Is Nothing Then If time >= pTrackGlobe.BeginTime Then keyFrameCount = pTrackGlobe.KeyframeCount pKFGlbCam = pTrackGlobe.Keyframe(pTrackGlobe.KeyframeCount - keyFrameCount) 'reset object pAnimGlobeCam.ResetObject(pScene, pKFGlbCam) ' interpolate by using track pTrackGlobe.InterpolateObjectProperties(pScene, time) keyFrameCount = keyFrameCount - 1 End If End If Next For t = 0 To pTrackLyrArray.Count - 1 pTrackLayer = pTrackLyrArray.Element(t) If Not pTrackLayer Is Nothing Then If time >= pTrackLayer.BeginTime Then keyFrameLayerCount = pTrackLayer.KeyframeCount pKFGlbLayer = pTrackLayer.Keyframe(pTrackLayer.KeyframeCount - keyFrameLayerCount) 'interpolate by using track pTrackLayer.InterpolateObjectProperties(pScene, time) keyFrameLayerCount = keyFrameLayerCount - 1 End If End If Next 'reset interpolation Point time = start / iteration 'refresh the globeviewer(s) pGlobeDisplay.RefreshViewers() Next start Next End Sub Private Function Greatest(ByRef pArray() As Integer) As Integer ' Function to find the largest count of keyframes (in any one of the Animation tracks) Dim iLength As Integer, i As Integer, iMax As Integer iLength = UBound(pArray) ReDim Preserve pArray(iLength) For i = 0 To iLength - 1 If IsNothing(iMax) Then iMax = pArray(i) ElseIf pArray(i) > iMax Then iMax = pArray(i) End If Next Greatest = iMax End Function Private Sub OptDuration_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptDuration.CheckedChanged If eventSender.Checked Then txtDuration.Text = CStr(10) 'set default values TxtFrequency.Text = CStr(2) 'set Default values End If End Sub Private Sub OptIteration_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptIteration.CheckedChanged If eventSender.Checked Then 'Set Default cycle and iteration.. txtDuration.Text = CStr(500) TxtFrequency.Text = CStr(2) End If End Sub Private Function routin_ReadRegistry(ByRef sKey As String) As String 'Open the subkey for reading 'Dim rk As Microsoft.Win32.RegistryKey 'rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sKey, True) 'If rk Is Nothing Then routin_ReadRegistry = "" 'Get the data from a specified item in the key. Dim installationFolder As String = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path 'routin_ReadRegistry = rk.GetValue("InstallDir") routin_ReadRegistry = installationFolder End Function Private Sub AxToolbarControl1_OnItemClick(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.IToolbarControlEvents_OnItemClickEvent) Handles AxToolbarControl1.OnItemClick 'Display help when fly tool and walk tools are selected... 'check if key intercept is enabled,if not enable it. If Not AxGlobeControl1.KeyIntercept = 1 Then AxGlobeControl1.KeyIntercept = 1 Dim puid As UID puid = AxToolbarControl1.GetItem(e.index).UID 'uid for fly tool={2C327C42-8CA9-4FC3-8C7B-F6290680FABB} 'uid for walk tool={56C3BDD4-C51A-4574-8954-D3E1F5F54E57} If puid.Value = "{2C327C42-8CA9-4FC3-8C7B-F6290680FABB}" Then 'fly... lblStatus.Text = "Use arrow up or arrow left keys to decelerate and arrow up or arrow left keys to accelerate." 'Fly tool ElseIf puid.Value = "{56C3BDD4-C51A-4574-8954-D3E1F5F54E57}" Then 'walk... lblStatus.Text = "Use arrow up or down keys to change elevation and the arrow left or right keys to fine-tune travel speed." Else lblStatus.Text = "" End If End Sub End Class