public ModelFeatureList(string name, string dataSource, World CurrentWorld)
: base(name)
{
try
{
int count = 0;
isSelectable = true;
this.ParentList = new RenderableObjectList(name);
XmlDocument docNav = new XmlDocument();
string path = dataSource;
docNav.Load(dataSource);
XmlNode root = docNav["ModelInfomations"];
for (int i = 0; i < root.ChildNodes.Count; i++)//
{
XmlElement elemenent = (XmlElement)root.ChildNodes[i];
string Name = ((XmlElement)root.ChildNodes[i].SelectSingleNode("Name")).InnerText;
//string modelUrl = path.Substring(0, path.LastIndexOf('\\') + 1);
string Url = ((XmlElement)root.ChildNodes[i].SelectSingleNode("ModelUrl")).InnerText;
if (Url.IndexOf("http") == -1)//过滤掉没有.x的.xpc模型
{
float x = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("X")).InnerText);// +c / 8000f;
float y = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Y")).InnerText);// +c / 8000f;
float alt = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Alt")).InnerText);
float yaw = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Yaw")).InnerText);
float roll = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Roll")).InnerText);
float pitch = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Pitch")).InnerText);
float scale = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Scale")).InnerText);
double maxVisiableDis = 200000;// float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("MaxVisibilityDistance")).InnerText);
double minVisiableDis = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("MinVisibilityDistance")).InnerText);
double defaultDis = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("DefaultViewDistance")).InnerText);
string message = ((XmlElement)root.ChildNodes[i].SelectSingleNode("Message")).InnerText;
string toolTipText = ((XmlElement)root.ChildNodes[i].SelectSingleNode("ToolTipText")).InnerText;
string ClientData = "<?xml version=\"1.0\" encoding=\"utf-16\"?><Feature FeatureClassName=\"模型\"><FieldsData><OBJECTID t=\"0,50\">14085727000100</OBJECTID><TYDM t=\"0,8\">31002051</TYDM><TYBH t=\"0,14\">14085727000100</TYBH><MXH t=\"0,16\">1#冷却塔</MXH><DW t=\"0,20\">地名</DW><MXB t=\"0,10\">站库</MXB><MXX t=\"0,10\"></MXX><MXCZ t=\"0,20\"></MXCZ><MXZT t=\"0,10\">站库</MXZT><YQXS t=\"0,10\"></YQXS><CYFS t=\"0,10\"></CYFS><QK t=\"0,20\"></QK><YTFQ t=\"0,20\">滴西</YTFQ><CW t=\"0,15\"></CW><CWDM t=\"0,10\"></CWDM><GMRotation t=\"2,19,5\">-0.39373799999999998</GMRotation></FieldsData></Feature>"; //Name = "1haojing";
//path = "http://10.72.27.57/building/cyyc/data20070822/data0822_model.xml";
m_Layer = new ModelFeatureT(Name, CurrentWorld, path, y, x, alt, scale, yaw, pitch, roll, toolTipText, message, maxVisiableDis, minVisiableDis, defaultDis, ClientData);
//m_Layer.Latitude = x;
//m_Layer.Longitude = y;
//this.ParentList.Add(m_Layer);
m_Layer.ParentList = this;
m_Layer.IsOn = true;
m_Layer.RenderPriority = RenderPriority.Custom;
this.m_children.Add(m_Layer);
count++;
}
else
{
if (path.Contains("building"))
continue;
double x = double.Parse(root.ChildNodes[i]["X"].InnerText);
double y = double.Parse(root.ChildNodes[i]["Y"].InnerText);
double alt = double.Parse(root.ChildNodes[i]["Alt"].InnerText);
float yaw = float.Parse(root.ChildNodes[i]["Yaw"].InnerText);
float roll = float.Parse(root.ChildNodes[i]["Roll"].InnerText);
float pitch = float.Parse(root.ChildNodes[i]["Pitch"].InnerText);
float scale = float.Parse(root.ChildNodes[i]["Scale"].InnerText);
double maxVisiableDis = 200000;
double minVisiableDis = float.Parse(root.ChildNodes[i]["MinVisibilityDistance"].InnerText);
double defaultDis = float.Parse(root.ChildNodes[i]["DefaultViewDistance"].InnerText);
string message = root.ChildNodes[i]["Message"].InnerText;
string toolTipText = root.ChildNodes[i]["ToolTipText"].InnerText;
string ClientData = "<?xml version=\"1.0\" encoding=\"utf-16\"?><Feature FeatureClassName=\"模型\"><FieldsData><OBJECTID t=\"0,50\">14085727000100</OBJECTID><TYDM t=\"0,8\">31002051</TYDM><TYBH t=\"0,14\">14085727000100</TYBH><MXH t=\"0,16\">1#冷却塔</MXH><DW t=\"0,20\">地名</DW><MXB t=\"0,10\">站库</MXB><MXX t=\"0,10\"></MXX><MXCZ t=\"0,20\"></MXCZ><MXZT t=\"0,10\">站库</MXZT><YQXS t=\"0,10\"></YQXS><CYFS t=\"0,10\"></CYFS><QK t=\"0,20\"></QK><YTFQ t=\"0,20\">滴西</YTFQ><CW t=\"0,15\"></CW><CWDM t=\"0,10\"></CWDM><GMRotation t=\"2,19,5\">-0.39373799999999998</GMRotation></FieldsData></Feature>"; string Firststr = path.Substring(0, path.IndexOf("xml")) + "xAndPic";
string Xpath = Firststr + Url.Substring(Url.ToLower().IndexOf("sdp3dearthfly") + 13, Url.LastIndexOf("/") - Url.ToLower().IndexOf("sdp3dearthfly") - 13) + "/";
if (Name.Contains("ford") || Name.Contains("car-shelby") || Name.Contains("launcher") || Name.Contains("nissan"))
continue;
m_Layer = new ModelFeatureT(Name, CurrentWorld, Xpath, y, x, alt, scale, yaw, pitch, roll, toolTipText, message, maxVisiableDis, minVisiableDis, defaultDis, ClientData);
m_Layer.ParentList = this;
//this.ParentList.Add(m_Layer);
m_Layer.IsOn = true;
//m_Layer.Latitude = x;
//m_Layer.Longitude = y;
m_Layer.RenderPriority = RenderPriority.Custom;
this.m_children.Add(m_Layer);
count++;
}
} }
catch { }
}
: base(name)
{
try
{
int count = 0;
isSelectable = true;
this.ParentList = new RenderableObjectList(name);
XmlDocument docNav = new XmlDocument();
string path = dataSource;
docNav.Load(dataSource);
XmlNode root = docNav["ModelInfomations"];
for (int i = 0; i < root.ChildNodes.Count; i++)//
{
XmlElement elemenent = (XmlElement)root.ChildNodes[i];
string Name = ((XmlElement)root.ChildNodes[i].SelectSingleNode("Name")).InnerText;
//string modelUrl = path.Substring(0, path.LastIndexOf('\\') + 1);
string Url = ((XmlElement)root.ChildNodes[i].SelectSingleNode("ModelUrl")).InnerText;
if (Url.IndexOf("http") == -1)//过滤掉没有.x的.xpc模型
{
float x = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("X")).InnerText);// +c / 8000f;
float y = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Y")).InnerText);// +c / 8000f;
float alt = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Alt")).InnerText);
float yaw = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Yaw")).InnerText);
float roll = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Roll")).InnerText);
float pitch = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Pitch")).InnerText);
float scale = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("Scale")).InnerText);
double maxVisiableDis = 200000;// float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("MaxVisibilityDistance")).InnerText);
double minVisiableDis = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("MinVisibilityDistance")).InnerText);
double defaultDis = float.Parse(((XmlElement)root.ChildNodes[i].SelectSingleNode("DefaultViewDistance")).InnerText);
string message = ((XmlElement)root.ChildNodes[i].SelectSingleNode("Message")).InnerText;
string toolTipText = ((XmlElement)root.ChildNodes[i].SelectSingleNode("ToolTipText")).InnerText;
string ClientData = "<?xml version=\"1.0\" encoding=\"utf-16\"?><Feature FeatureClassName=\"模型\"><FieldsData><OBJECTID t=\"0,50\">14085727000100</OBJECTID><TYDM t=\"0,8\">31002051</TYDM><TYBH t=\"0,14\">14085727000100</TYBH><MXH t=\"0,16\">1#冷却塔</MXH><DW t=\"0,20\">地名</DW><MXB t=\"0,10\">站库</MXB><MXX t=\"0,10\"></MXX><MXCZ t=\"0,20\"></MXCZ><MXZT t=\"0,10\">站库</MXZT><YQXS t=\"0,10\"></YQXS><CYFS t=\"0,10\"></CYFS><QK t=\"0,20\"></QK><YTFQ t=\"0,20\">滴西</YTFQ><CW t=\"0,15\"></CW><CWDM t=\"0,10\"></CWDM><GMRotation t=\"2,19,5\">-0.39373799999999998</GMRotation></FieldsData></Feature>"; //Name = "1haojing";
//path = "http://10.72.27.57/building/cyyc/data20070822/data0822_model.xml";
m_Layer = new ModelFeatureT(Name, CurrentWorld, path, y, x, alt, scale, yaw, pitch, roll, toolTipText, message, maxVisiableDis, minVisiableDis, defaultDis, ClientData);
//m_Layer.Latitude = x;
//m_Layer.Longitude = y;
//this.ParentList.Add(m_Layer);
m_Layer.ParentList = this;
m_Layer.IsOn = true;
m_Layer.RenderPriority = RenderPriority.Custom;
this.m_children.Add(m_Layer);
count++;
}
else
{
if (path.Contains("building"))
continue;
double x = double.Parse(root.ChildNodes[i]["X"].InnerText);
double y = double.Parse(root.ChildNodes[i]["Y"].InnerText);
double alt = double.Parse(root.ChildNodes[i]["Alt"].InnerText);
float yaw = float.Parse(root.ChildNodes[i]["Yaw"].InnerText);
float roll = float.Parse(root.ChildNodes[i]["Roll"].InnerText);
float pitch = float.Parse(root.ChildNodes[i]["Pitch"].InnerText);
float scale = float.Parse(root.ChildNodes[i]["Scale"].InnerText);
double maxVisiableDis = 200000;
double minVisiableDis = float.Parse(root.ChildNodes[i]["MinVisibilityDistance"].InnerText);
double defaultDis = float.Parse(root.ChildNodes[i]["DefaultViewDistance"].InnerText);
string message = root.ChildNodes[i]["Message"].InnerText;
string toolTipText = root.ChildNodes[i]["ToolTipText"].InnerText;
string ClientData = "<?xml version=\"1.0\" encoding=\"utf-16\"?><Feature FeatureClassName=\"模型\"><FieldsData><OBJECTID t=\"0,50\">14085727000100</OBJECTID><TYDM t=\"0,8\">31002051</TYDM><TYBH t=\"0,14\">14085727000100</TYBH><MXH t=\"0,16\">1#冷却塔</MXH><DW t=\"0,20\">地名</DW><MXB t=\"0,10\">站库</MXB><MXX t=\"0,10\"></MXX><MXCZ t=\"0,20\"></MXCZ><MXZT t=\"0,10\">站库</MXZT><YQXS t=\"0,10\"></YQXS><CYFS t=\"0,10\"></CYFS><QK t=\"0,20\"></QK><YTFQ t=\"0,20\">滴西</YTFQ><CW t=\"0,15\"></CW><CWDM t=\"0,10\"></CWDM><GMRotation t=\"2,19,5\">-0.39373799999999998</GMRotation></FieldsData></Feature>"; string Firststr = path.Substring(0, path.IndexOf("xml")) + "xAndPic";
string Xpath = Firststr + Url.Substring(Url.ToLower().IndexOf("sdp3dearthfly") + 13, Url.LastIndexOf("/") - Url.ToLower().IndexOf("sdp3dearthfly") - 13) + "/";
if (Name.Contains("ford") || Name.Contains("car-shelby") || Name.Contains("launcher") || Name.Contains("nissan"))
continue;
m_Layer = new ModelFeatureT(Name, CurrentWorld, Xpath, y, x, alt, scale, yaw, pitch, roll, toolTipText, message, maxVisiableDis, minVisiableDis, defaultDis, ClientData);
m_Layer.ParentList = this;
//this.ParentList.Add(m_Layer);
m_Layer.IsOn = true;
//m_Layer.Latitude = x;
//m_Layer.Longitude = y;
m_Layer.RenderPriority = RenderPriority.Custom;
this.m_children.Add(m_Layer);
count++;
}
} }
catch { }
}
主要是操作XML
至于那些对象是干什么用的那就不知道了