protected void LoadOldWaypoint(XmlNode node, WorldObjectCollection collection) { string name = null; Vector3 pos = Vector3.Zero; // get everything but submeshes first foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "Name": name = childNode.InnerText; break; case "Position": pos = GetVectorAttributes(childNode); break; default: break; } } Waypoint waypoint = new Waypoint(name, collection, this, pos, Vector3.Zero); collection.Add(waypoint); }
protected void LoadOldRoad(XmlNode node, WorldObjectCollection collection) { string name = null; int halfWidth = 1; XmlNode pointsNode = null; // get the name foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "Name": name = childNode.InnerText; break; case "Points": pointsNode = childNode; break; case "HalfWidth": halfWidth = int.Parse(childNode.InnerText); break; default: break; } } // if the road has no points, just call it bogus and return if (pointsNode == null) { return; } // create and add the road to the world RoadObject road = new RoadObject(name, collection, this, halfWidth); collection.Add(road); // set up the points foreach (XmlNode pointNode in pointsNode.ChildNodes) { if (pointNode.Name == "Point") { XmlNode locNode = pointNode.SelectSingleNode("Position"); Vector3 pointPos = GetVectorAttributes(locNode); int pointnum; road.Points.AddPoint(pointPos, out pointnum); } } }
protected void LoadOldStaticObject(XmlNode node, WorldObjectCollection collection) { string name = null; string mesh = null; Vector3 pos = Vector3.Zero; Vector3 scale = Vector3.Zero; Vector3 rot = Vector3.Zero; // get everything but submeshes first foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "Name": name = childNode.InnerText; break; case "Mesh": mesh = childNode.InnerText; break; case "Position": pos = GetVectorAttributes(childNode); break; case "Scale": scale = GetVectorAttributes(childNode); break; case "Rotation": rot = GetVectorAttributes(childNode); // force rot.y into the range of -180 to 180 while (rot.y > 180) { rot.y -= 360; } while (rot.y < -180) { rot.y += 360; } break; default: break; } } // create the object StaticObject obj = new StaticObject(name, collection, this, mesh, pos, scale, rot); collection.Add(obj); // process submeshes foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "SubMesh") { } } }
protected void LoadOldBoundary(XmlNode node, WorldObjectCollection collection) { string name = null; XmlNode pointsNode = null; XmlNode semanticsNode = null; // int priority; // get the name foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "Name": name = childNode.InnerText; break; case "Points": pointsNode = childNode; break; case "Attributes": semanticsNode = childNode; break; default: break; } } // if the boundary has no points, just call it bogus and return if (pointsNode == null) { return; } // create and add the boundary to the world Boundary boundary = new Boundary(collection, this, name, 100); collection.Add(boundary); // set up the points foreach (XmlNode pointNode in pointsNode.ChildNodes) { if (pointNode.Name == "Point") { XmlNode locNode = pointNode.SelectSingleNode("Position"); Vector3 pointPos = GetVectorAttributes(locNode); int pointNum; boundary.Points.AddPoint(pointPos, out pointNum); } } if (semanticsNode != null) { // handle boundary semantics foreach (XmlNode semanticNode in semanticsNode.ChildNodes) { switch (semanticNode.Name) { case "WaterAttribute": XmlNode heightNode = semanticNode.SelectSingleNode("Height"); float height = float.Parse(heightNode.InnerText); Water water = new Water(height, boundary, this); boundary.Add(water); break; case "ForestAttribute": XmlNode seedNode = semanticNode.SelectSingleNode("Seed"); int seed = int.Parse(seedNode.InnerText); XmlNode speedWindNode = semanticNode.SelectSingleNode("SpeedWindFile"); string speedWindFile = speedWindNode.InnerText; XmlNode windSpeedNode = semanticNode.SelectSingleNode("WindSpeed"); float windSpeed = float.Parse(windSpeedNode.InnerText); XmlNode windDirNode = semanticNode.SelectSingleNode("WindDirection"); Vector3 windDir = GetVectorAttributes(windDirNode); // Add the forest object Forest forest = new Forest(speedWindFile, windSpeed, windDir, seed, boundary, this); boundary.Add(forest); XmlNode treeTypesNode = semanticNode.SelectSingleNode("TreeTypes"); if (treeTypesNode != null) { foreach (XmlNode treeTypeNode in treeTypesNode.ChildNodes) { XmlNode treeNameNode = treeTypeNode.SelectSingleNode("TreeName"); string treeName = treeNameNode.InnerText; XmlNode treeFilenameNode = treeTypeNode.SelectSingleNode("TreeDescriptionFilename"); string treeFilename = treeFilenameNode.InnerText; XmlNode scaleNode = treeTypeNode.SelectSingleNode("Scale"); float scale = float.Parse(scaleNode.InnerText); XmlNode scaleVarianceNode = treeTypeNode.SelectSingleNode("ScaleVariance"); float scaleVariance = float.Parse(scaleVarianceNode.InnerText); XmlNode instancesNode = treeTypeNode.SelectSingleNode("Instances"); uint instances = uint.Parse(instancesNode.InnerText); Tree tree = new Tree(treeName, treeFilename, scale, scaleVariance, instances, forest, this); forest.Add(tree); } } break; case "Fog": XmlNode redNode = semanticNode.SelectSingleNode("ColorRed"); int red = int.Parse(redNode.InnerText); XmlNode greenNode = semanticNode.SelectSingleNode("ColorGreen"); int green = int.Parse(greenNode.InnerText); XmlNode blueNode = semanticNode.SelectSingleNode("ColorBlue"); int blue = int.Parse(blueNode.InnerText); XmlNode nearNode = semanticNode.SelectSingleNode("Near"); float near = float.Parse(nearNode.InnerText); XmlNode farNode = semanticNode.SelectSingleNode("Far"); float far = int.Parse(farNode.InnerText); ColorEx fogColor = new ColorEx(((float)red) / 255f, ((float)green) / 255f, ((float)blue) / 255f); Fog fog = new Fog(this, boundary, fogColor, near, far); boundary.Add(fog); break; case "Sound": break; default: break; } } } }