skyline6.5 C#二次开发关于动态物体创建问题
发布网友
发布时间:2022-04-28 22:28
我来回答
共1个回答
热心网友
时间:2022-06-24 04:29
public ITerrainDynamicObject61 setTrace(String path,ITerrainDynamicObject61 theDynamicPlane)
{
FileStream fs = new FileStream(path, FileMode.Open);
StreamReader m_streamReader = new StreamReader(fs);
m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);// 从数据流中读取每一行,直到文件的最后一行
string strLine = m_streamReader.ReadLine();
double[] x = new double[3];
int count = 0;
while (strLine != null)
{
string[] split = strLine.Split(new char[] { ',' });
strLine = m_streamReader.ReadLine();
//x[0] = Convert.ToDouble(split[0]) - 1.0817;
//x[1] = Convert.ToDouble(split[1]) - 193.5872;
//x[2] = Convert.ToDouble(split[2]);
x[0] = Convert.ToDouble(split[0]);
x[1] = Convert.ToDouble(split[1]);
x[2] = Convert.ToDouble(split[2]);
//var xPoint = new SGWorld().Creator.CreateRouteWaypoint(x[0], x[1], x[2]);
IRouteWaypoint61 xPoint = te.Creator.CreateRouteWaypoint(x[1], x[0], x[2],1200,0,0,0,0,0,"");
theDynamicPlane.Waypoints.AddWaypoint(xPoint);
}
m_streamReader.Close();
fs.Close();
return theDynamicPlane;
}
//具体调用
string planeName = fileFatherPath + "\\demo\\747.xpc";//三维飞机的路径
string planeTraceName=fileFatherPath+"\\demo\\AAR316-674.txt";//有经度纬度高度的txt文本
string theLabel="飞机展示";
ITerrainDynamicObject61 dynamicPlane=te.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_AIRPLANE, DynamicObjectType.DYNAMIC_3D_MODEL, planeName, 1, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, theLabel);
dynamicPlane = setTrace(planeTraceName, dynamicPlane);
我用skyline6.1这样写的,6.5应该差不多变化不大吧。