public void NodeAnimation1()
{
//读取一个模型文件
geoModel = new GeoModel();
//设置或获取三维位置,该位置为外外接长方体中心点位置(法1设想模型位置提前设置好,法2打开高铁模型,估计高铁外接长方体位置,由代码设置)
//test5
geoModel.Position = new Point3D(116.381155556, 39.989522222, 0);
// geoModel.Position = new Point3D(116.463347222, 39.906958333, 0);
//3Ds/SGM创建三维模型对象
geoModel.FromFile(@"F:\B16_GIS_1Class\test Model\test3\Box001.SGM");
//将模型添加到KML图层中
Scene scene = m_sceneControl.Scene;
Layer3D layer = scene.Layers["test8"];
layerKML = layer as Layer3DKML;
//问题3:三维要素作用:Feature3D是三维要素类,只对KML图层有效。您要在KML图层中添加模型geoModel,就必须用Feature3D。
Feature3D feature = layerKML.Features.Add(geoModel);
//设置添加到KML图层中的模型的节点动画信息
animationModel = feature.Geometry as GeoModel;
ani= animationModel.NodeAnimation;
//设置动画运行周期,单位秒长
ani.Length =5.0;
//设置动画播放模式
ani.PlayMode = PlayMode.Once;
//设置节点动画轨迹 test5
Point3Ds pts = new Point3Ds();
Point3D pt = new Point3D(116.381163889, 39.989769444, 0);
pts.Add(pt);
//坐标和距离换算
pt.X = 116.381163889;
pt.Y = 39.990922222;
pts.Add(pt);
pt.X = 116.381163889;
pt.Y = 39.991591666;
pts.Add(pt);
geoLine = new GeoLine3D(pts);
ani.SetTrack(geoLine);
//启用节点动画
ani.IsEnabled = true;
//添加该句后,每运行一次代码后,模型将在KML图层添加一次。
//layerKML.Features.ToKMLFile(@"F:\B16_GIS_1Class\test Model\test7.kml");
}