// bool redo = false; public UnloadCollectionCommand(WorldEditor worldEditor, WorldObjectCollection collection) { app = worldEditor; topCollection = collection; collections.Add(collection); searchForUnLoadCollections(collection); // redo = false; }
public void ToXml(XmlWriter w, bool backup) { if (!backup) { ToXml(w); } if (loaded) { int pathEnd = ((IObjectCollectionParent)parent).WorldFilePath.LastIndexOf('\\'); string pathName = ((IObjectCollectionParent)parent).WorldFilePath.Substring(0, pathEnd); w.WriteStartElement("WorldObjectCollection"); w.WriteAttributeString("Version", app.Config.XmlSaveFileVersion.ToString()); foreach (IWorldObject obj in objectList) { if (String.Equals(obj.ObjectType, "Collection")) { WorldObjectCollection worldCollection = (WorldObjectCollection)obj; worldCollection.Path = pathName; // write the XML into the top level world file w.WriteStartElement("WorldCollection"); if (worldCollection.Filename == "") { int startIndex = pathEnd + 1; int subStringLength = WorldFilePath.LastIndexOf(".mwc") - startIndex; worldCollection.Filename = String.Format("{0}-{1}.mwc", WorldFilePath.Substring(startIndex, subStringLength), worldCollection.Name); } w.WriteAttributeString("Name", worldCollection.Name); string filename = worldCollection.Filename.Insert((worldCollection.Filename.LastIndexOf(".")), "~"); w.WriteAttributeString("Filename", filename); w.WriteEndElement(); // create a file for the collection if (worldCollection.Loaded) { try { XmlWriter childWriter = XmlWriter.Create(String.Format("{0}\\{1}", pathName, filename), app.XMLWriterSettings); worldCollection.ToXml(childWriter, backup); childWriter.Close(); } catch (Exception e) { LogManager.Instance.Write(e.ToString()); MessageBox.Show(String.Format("Unable to open the file for writing. Use file menu \"Save As\" to save to another location. Error: {0}", e.Message), "Error Saving File", MessageBoxButtons.OK); } } } else { obj.ToXml(w); } } w.WriteEndElement(); } }
public void Clone(IWorldContainer copyParent) { WorldObjectCollection clone = new WorldObjectCollection(name, copyParent, app); foreach (IWorldObject child in objectList) { child.Clone(clone); } copyParent.Add(clone); }
private void searchForUnLoadCollections(WorldObjectCollection col) { foreach (WorldObjectCollection collection in col.CollectionList) { if (collection.Loaded) { collections.Add(collection); searchForUnLoadCollections(collection); } } }
public void Add(String text, WorldObjectCollection obj, EventHandler clickHandler) { ToolStripButton button = new ToolStripButton(text); button.Tag = obj; button.Click += clickHandler; currentMenu.Items.Add(button); ToolStripButton button2 = new ToolStripButton(); button2.Tag = obj; button2.Click += clickHandler; button2.ToolTipText = text; currentButtonBar.Add(button2); button2.Alignment = ToolStripItemAlignment.Right; addImage(button2); }
public void Execute() { if (worldCollection == null) { worldCollection = new WorldObjectCollection(name, parent, app); } parent.Add(worldCollection); //for (int i = app.SelectedNodes.Count; i = app.SelectedNodes.Count; i++) //{ // app.SelectedNodes[0].UnSelect(); //} //app.SelectedObject = new List<IWorldObject>(); //worldCollection.Node.Select(); List<IWorldObject> list = new List<IWorldObject>(); list.Add(worldCollection as IWorldObject); app.SelectedObject = list; }
public void Execute() { if (worldCollection == null) { worldCollection = new WorldObjectCollection(name, parent, app); } parent.Add(worldCollection); //for (int i = app.SelectedNodes.Count; i = app.SelectedNodes.Count; i++) //{ // app.SelectedNodes[0].UnSelect(); //} //app.SelectedObject = new List<IWorldObject>(); //worldCollection.Node.Select(); List <IWorldObject> list = new List <IWorldObject>(); list.Add(worldCollection as IWorldObject); app.SelectedObject = list; }
public void toolStripCollectionTree_DropDownOpening(object sender, EventArgs e) { ToolStripItem menuItem = (ToolStripItem)sender; ToolStripDropDownButton parent = (ToolStripDropDownButton)sender; WorldObjectCollection collection = (WorldObjectCollection)menuItem.Tag; if (app.SelectedObject.Count >= 1 && app.SelectedObject.Count != 0) { foreach (WorldObjectCollection coll in collection.CollectionList) { if (app.SelectedObject[0] is WorldObjectCollection && ReferenceEquals(((IObjectChangeCollection)(app.SelectedObject[0])).Parent, coll) || ReferenceEquals(app.SelectedObject[0], coll)) { continue; } if (coll.CollectionList.Count != 0) { ToolStripDropDownButton but = new ToolStripDropDownButton(); but.Tag = coll; but.Text = coll.Name; but.DropDownOpening += new System.EventHandler(this.toolStripCollectionTree_DropDownOpening); but.MouseEnter += new System.EventHandler(this.toolStripButton_Enter); but.Click += new System.EventHandler(app.CollectionButton_clicked); but.DropDownClosed += new System.EventHandler(this.collectionDropDown_closed);; parent.DropDownItems.Add(but as ToolStripItem); } else { ToolStripButton but = new ToolStripButton(coll.Name); but.Tag = coll; but.Click += new System.EventHandler(app.CollectionButton_clicked); parent.DropDownItems.Add(but); } } } else { return; } }
private bool checkChildren(WorldObjectCollection obj) { bool ret = true; foreach (WorldObjectCollection coll in obj.CollectionList) { if (ReferenceEquals(coll.Parent, app.SelectedObject[0])) { ret = false; } else { if (!(coll.Parent is WorldRoot)) { ret = checkChildren(coll.Parent as WorldObjectCollection); } } if (!ret) { return(ret); } } return(ret); }
protected void FromXml(XmlReader r, bool loadall) { string colfilename = ""; string baseName = WorldFilePath.Substring(0, WorldFilePath.LastIndexOf('\\')); do { r.Read(); } while ((r.NodeType != XmlNodeType.Element) || !(String.Equals(r.Name, "WorldObjectCollection"))); while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Whitespace) { continue; } if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "Road": RoadObject road = new RoadObject(r, this, app); Add(road); break; case "StaticObject": StaticObject obj = new StaticObject(this, app, r); Add(obj); break; case "Waypoint": Waypoint wp = new Waypoint(r, this, app); Add(wp); break; case "Boundary": Boundary b = new Boundary(r, this, app); Add(b); break; case "PointLight": PointLight pl = new PointLight(app, this, app.Scene, r); Add(pl); break; case "TerrainDecal": TerrainDecal d = new TerrainDecal(app, this, r); Add(d); break; case "WorldCollection": string collectionName = null; colfilename = ""; for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); switch (r.Name) { case "Name": collectionName = r.Value; break; case "Filename": colfilename = r.Value; break; } } baseName = this.Path; if (!loadall) { if (colfilename != "") { if (colfilename.EndsWith("~.mwc")) { string autofilepath = String.Format("{0}\\{1}", baseName, colfilename); string normalfilepath = String.Format("{0}\\{1}", baseName, colfilename.Remove(colfilename.LastIndexOf("~"), 1)); if ((File.Exists(autofilepath) && File.Exists(normalfilepath) && (new FileInfo(autofilepath)).LastWriteTime < (new FileInfo(normalfilepath).LastWriteTime)) || (!File.Exists(autofilepath) && File.Exists(normalfilepath))) { colfilename = colfilename.Remove(filename.LastIndexOf("~"), 1); } } XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}", baseName, colfilename), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName, false); while (colfilename.Contains("~")) { colfilename = colfilename.Remove(colfilename.LastIndexOf("~"),1); } coll.Filename = colfilename; Add(coll); childReader.Close(); } else { XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}.mwc", baseName, collectionName), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName, false); coll.Filename = collectionName + ".mwc"; Add(coll); childReader.Close(); } } else { if (colfilename != "") { if (colfilename.EndsWith("~.mwc")) { string autofilepath = String.Format("{0}\\{1}", baseName, colfilename); string normalfilepath = String.Format("{0}\\{1}", baseName, colfilename.Remove(filename.LastIndexOf("~"), 1)); if ((File.Exists(autofilepath) && File.Exists(normalfilepath) && (new FileInfo(autofilepath)).LastWriteTime < (new FileInfo(normalfilepath).LastWriteTime)) || (!File.Exists(autofilepath) && File.Exists(normalfilepath))) { colfilename = colfilename.Remove(colfilename.LastIndexOf("~"), 1); } } XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}", baseName, colfilename), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName); while (colfilename.Contains("~")) { colfilename = colfilename.Remove(colfilename.LastIndexOf("~"), 1); } coll.Filename = colfilename; Add(coll); childReader.Close(); } else { XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}.mwc", baseName, collectionName), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName); coll.Filename = collectionName + ".mwc"; Add(coll); childReader.Close(); } } r.MoveToElement(); break; } } } while(filename.Contains("~")) { filename = filename.Remove(filename.IndexOf("~"), 1); } }
private bool checkChildren(WorldObjectCollection obj) { bool ret = true; foreach(WorldObjectCollection coll in obj.CollectionList) { if (ReferenceEquals(coll.Parent, app.SelectedObject[0])) { ret = false; } else { if (!(coll.Parent is WorldRoot)) { ret = checkChildren(coll.Parent as WorldObjectCollection); } } if (!ret) { return ret; } } return ret; }
protected void FromXml(XmlReader r, bool loadall) { string colfilename = ""; string baseName = WorldFilePath.Substring(0, WorldFilePath.LastIndexOf('\\')); do { r.Read(); } while ((r.NodeType != XmlNodeType.Element) || !(String.Equals(r.Name, "WorldObjectCollection"))); while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Whitespace) { continue; } if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "Road": RoadObject road = new RoadObject(r, this, app); Add(road); break; case "StaticObject": StaticObject obj = new StaticObject(this, app, r); Add(obj); break; case "Waypoint": Waypoint wp = new Waypoint(r, this, app); Add(wp); break; case "Boundary": Boundary b = new Boundary(r, this, app); Add(b); break; case "PointLight": PointLight pl = new PointLight(app, this, app.Scene, r); Add(pl); break; case "TerrainDecal": TerrainDecal d = new TerrainDecal(app, this, r); Add(d); break; case "WorldCollection": string collectionName = null; colfilename = ""; for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); switch (r.Name) { case "Name": collectionName = r.Value; break; case "Filename": colfilename = r.Value; break; } } baseName = this.Path; if (!loadall) { if (colfilename != "") { if (colfilename.EndsWith("~.mwc")) { string autofilepath = String.Format("{0}\\{1}", baseName, colfilename); string normalfilepath = String.Format("{0}\\{1}", baseName, colfilename.Remove(colfilename.LastIndexOf("~"), 1)); if ((File.Exists(autofilepath) && File.Exists(normalfilepath) && (new FileInfo(autofilepath)).LastWriteTime < (new FileInfo(normalfilepath).LastWriteTime)) || (!File.Exists(autofilepath) && File.Exists(normalfilepath))) { colfilename = colfilename.Remove(filename.LastIndexOf("~"), 1); } } XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}", baseName, colfilename), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName, false); while (colfilename.Contains("~")) { colfilename = colfilename.Remove(colfilename.LastIndexOf("~"), 1); } coll.Filename = colfilename; Add(coll); childReader.Close(); } else { XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}.mwc", baseName, collectionName), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName, false); coll.Filename = collectionName + ".mwc"; Add(coll); childReader.Close(); } } else { if (colfilename != "") { if (colfilename.EndsWith("~.mwc")) { string autofilepath = String.Format("{0}\\{1}", baseName, colfilename); string normalfilepath = String.Format("{0}\\{1}", baseName, colfilename.Remove(filename.LastIndexOf("~"), 1)); if ((File.Exists(autofilepath) && File.Exists(normalfilepath) && (new FileInfo(autofilepath)).LastWriteTime < (new FileInfo(normalfilepath).LastWriteTime)) || (!File.Exists(autofilepath) && File.Exists(normalfilepath))) { colfilename = colfilename.Remove(colfilename.LastIndexOf("~"), 1); } } XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}", baseName, colfilename), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName); while (colfilename.Contains("~")) { colfilename = colfilename.Remove(colfilename.LastIndexOf("~"), 1); } coll.Filename = colfilename; Add(coll); childReader.Close(); } else { XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}.mwc", baseName, collectionName), app.XMLReaderSettings); WorldObjectCollection coll = new WorldObjectCollection(childReader, collectionName, this, app, baseName); coll.Filename = collectionName + ".mwc"; Add(coll); childReader.Close(); } } r.MoveToElement(); break; } } } while (filename.Contains("~")) { filename = filename.Remove(filename.IndexOf("~"), 1); } }
protected void FromXml(XmlReader r, bool loadCollections) { string filename = ""; string baseName = worldFilePath.Substring(0, worldFilePath.LastIndexOf('\\')); bool loadColl = loadCollections; for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); switch (r.Name) { case "Name": name = r.Value; break; } } r.MoveToElement(); while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Whitespace) { continue; } if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "CameraPosition": cameraPosition = XmlHelperClass.ParseVectorAttributes(r); break; case "CameraOrientation": cameraOrientation = XmlHelperClass.ParseQuaternion(r); break; case "Terrain": worldTerrain = new WorldTerrain(app, r); break; case "TerrainDisplay": worldTerrain.DisplayParamsFromXml(r); break; case "Ocean": ocean = new Ocean(this, app, r); break; case "Skybox": skybox = new Skybox(this, app, r); break; case "GlobalFog": fog = new GlobalFog(this, app, r); break; case "GlobalAmbientLight": ambientLight = new GlobalAmbientLight(this, app, app.Scene, r); break; case "GlobalDirectionalLight": directionalLight = new GlobalDirectionalLight(this, app, r); break; case "PathObjectTypes": pathObjectTypes = new PathObjectTypeContainer(app, this, r); break; case "WorldCollection": string collectionName = null; filename = ""; for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); switch (r.Name) { case "Name": collectionName = r.Value; break; case "Filename": filename = r.Value; break; } } string filepath = String.Format("{0}\\{1}", baseName, filename); if (filename != "") { if (filename.EndsWith("~.mwc")) { string autofilepath = String.Format("{0}\\{1}", baseName, filename); string normalfilepath = String.Format("{0}\\{1}", baseName, filename.Remove(filename.LastIndexOf("~"), 1)); if ((File.Exists(autofilepath) && File.Exists(normalfilepath) && (new FileInfo(autofilepath)).LastWriteTime < (new FileInfo(normalfilepath).LastWriteTime)) || (!File.Exists(autofilepath) && File.Exists(normalfilepath))) { filename = filename.Remove(filename.LastIndexOf("~"), 1); filepath = normalfilepath; } else { filepath = autofilepath; } } XmlReader childReader = XmlReader.Create(filepath, app.XMLReaderSettings); WorldObjectCollection collection = new WorldObjectCollection(childReader, collectionName, this, app, baseName, loadColl); collection.Filename = filename; while (collection.Filename.Contains("~")) { collection.Filename = collection.Filename.Remove(collection.Filename.LastIndexOf("~"), 1); } Add(collection); childReader.Close(); } else { XmlReader childReader = XmlReader.Create(String.Format("{0}\\{1}.mwc", baseName, collectionName), app.XMLReaderSettings); WorldObjectCollection collection = new WorldObjectCollection(childReader, collectionName, this, app, baseName, loadColl); collection.Filename = filename; Add(collection); while (collection.Filename.Contains("~")) { collection.Filename = collection.Filename.Remove(collection.Filename.LastIndexOf("~"), 1); } childReader.Close(); } r.MoveToElement(); break; } } } }
/// <summary> /// Load world files from the old world editor /// </summary> /// <param name="filename"></param> /// <param name="r"></param> /// <returns></returns> protected WorldRoot LoadOldWorld(string filename, XmlReader r) { XmlDocument doc = new XmlDocument(); doc.Load(r); string baseName = filename.Substring(filename.LastIndexOf('\\') + 1); string worldName = baseName.Substring(0, baseName.LastIndexOf('.')); WorldRoot root = new WorldRoot(worldName, worldTreeView, this); saveWorldButton.Enabled = true; saveWorldToolStripMenuItem.Enabled = true; saveWorldAsMenuItem.Enabled = true; WorldObjectCollection collection = new WorldObjectCollection(worldName, root, this); root.Add(collection); foreach (XmlNode childNode in doc.FirstChild.ChildNodes) { switch (childNode.Name) { case "Terrain": LoadOldTerrain(childNode, root); break; case "Skybox": LoadOldSkybox(childNode, root); break; case "Objects": LoadOldObjects(childNode, collection); break; } } setWorldDefaults(); setRecentFiles(filename); return root; }
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 LoadOldObjects(XmlNode node, WorldObjectCollection collection) { foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "StaticObject": LoadOldStaticObject(childNode, collection); break; case "Boundary": LoadOldBoundary(childNode, collection); break; case "Waypoint": LoadOldWaypoint(childNode, collection); break; case "Road": LoadOldRoad(childNode, collection); break; default: string name = childNode.Name; break; } } }
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; } } } }
public LoadCollectionCommandFactory(WorldEditor worldEditor, WorldObjectCollection col) { app = worldEditor; collection = col; }
public UnloadCollectionCommandFactory(WorldEditor worldEditor, WorldObjectCollection col) { app = worldEditor; topCollection = col; }
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") { } } }
public LoadCollectionCommand(WorldEditor worldEditor, WorldObjectCollection col) { app = worldEditor; collection = col; }