SGM格式三维模型沿运动轨迹运动后场景出现2个模型,一个是原始模型,一个是从原始模型分离并沿运动轨迹运动的模型。我想实现的效果是设置运动轨迹后仅有原始模型沿运动轨迹运动。
//节点动画开始运动 //设置或获取三维位置,该位置为外外接长方体中心点位置 geoModel.Position = new Point3D(116.381155556, 39.989522222, 0); //3Ds/SGM创建三维模型对象 //问题1:使用节点动画类对读取的模型有什么特殊的要求(模型格式SGM、3DS)? geoModel.FromFile(@"F:\B16_GIS_1Class\test Model\test3\Box001.SGM"); //将模型添加到KML图层中 Scene scene = m_sceneControl.Scene; //具体步骤:在超图桌面软件新建一个KML图层文件(test5),然后在KML图层添加三维模型。 Layer3D layer = scene.Layers["test5"]; Layer3DKML layerKML = layer as Layer3DKML; //问题3:三维要素作用:Feature3D是三维要素类,只对KML图层有效。您要在KML图层中添加模型geoModel,就必须用Feature3D。 Feature3D feature = layerKML.Features.Add(geoModel); //设置添加到KML图层中的模型的节点动画信息 GeoModel animationModel = feature.Geometry as GeoModel; ani = animationModel.NodeAnimation; //设置动画运行周期,单位秒长 ani.Length = 15.0; //设置动画播放模式 ani.PlayMode = PlayMode.Loop; //设置节点动画轨迹 //POINT1:116.381163889,39.989769444 //POINT2:116.381163889,39.990922222 //POINT3:116.381163889,39.991591666 Point3Ds pts = new Point3Ds(); Point3D pt = new Point3D(116.381155556, 39.98925, 0); pts.Add(pt); pt.X = 116.381155556; pt.Y = 39.990922222; pts.Add(pt); pt.X = 116.381155556; pt.Y = 39.991591666; pts.Add(pt); GeoLine3D geoLine = new GeoLine3D(pts); ani.SetTrack(geoLine); //启用节点动画 ani.IsEnabled = true; layerKML.Features.ToKMLFile(@"F:\B16_GIS_1Class\test Model\test5.kml");