//如果kml中已经保存运动轨迹,可以选择已保存好的运动轨迹 private void cb_Track_SelectedIndexChanged(object sender, EventArgs e) { if (cb_Track.SelectedIndex == 0) { return; } this.m_sceneControl.Scene.TrackingLayer.Clear(); String trackName = this.cb_Track.SelectedItem as String; Feature3Ds features = m_layerKML.Features; Feature3D[] feature3Ds = features.FindFeature(trackName, Feature3DSearchOption.AllFeatures); if (feature3Ds.Length > 0) { Feature3D feature3D = feature3Ds[0]; GeoPlacemark geoPlacemark = feature3D.Geometry as GeoPlacemark; m_geoLine3D = geoPlacemark.Geometry as GeoLine3D; if (m_geoLine3D != null && m_geoLine3D.PartCount > 0) { if (m_nodeAnimation != null) { m_nodeAnimation.SetTrack(m_geoLine3D); m_nodeAnimation.TimePostition = 0; } this.btn_AddToKML.Enabled = false; } } }
//指定模型,并设置其节点动画属性 private void cb_Model_SelectedIndexChanged(object sender, EventArgs e) { //如果之前的模型正在运动,则停止运动 if (m_nodeAnimation != null && m_nodeAnimation.IsEnabled == true) { m_nodeAnimation.IsEnabled = false; } //获取当前模型,并设置节点动画 String featureName = this.cb_Model.SelectedItem as String; Feature3Ds features = m_layerKML.Features; Feature3D[] feature3Ds = features.FindFeature(featureName, Feature3DSearchOption.AllFeatures); if (feature3Ds.Length > 0) { Feature3D feature3D = feature3Ds[0]; GeoPlacemark geoPlacemark = feature3D.Geometry as GeoPlacemark; m_geoModel = geoPlacemark.Geometry as GeoModel; if (m_geoModel != null) { m_nodeAnimation = m_geoModel.NodeAnimation; //位置变更事件 m_nodeAnimation.TimePositionChanged -= new TimePositionChangedEventHandler(m_nodeAnimationTimePositionChanged); m_nodeAnimation.TimePositionChanged += new TimePositionChangedEventHandler(m_nodeAnimationTimePositionChanged); if (m_geoLine3D != null && m_geoLine3D.PartCount > 0) { m_nodeAnimation.SetTrack(m_geoLine3D); m_nodeAnimation.TimePostition = 0; } } } }