public void Clone(IWorldContainer copyParent) { TerrainDecal clone = new TerrainDecal(app, copyParent, name, position, size, imageName, priority); clone.Rotation = rotation; copyParent.Add(clone); }
public DragDecalCommand(WorldEditor worldEditor, IWorldContainer parent, TerrainDecal tDecal) { this.app = worldEditor; this.parent = parent; this.decal = tDecal; this.placing = true; oldPosition = new Vector2(decal.Position.x,decal.Position.z); }
public DragDecalCommand(WorldEditor worldEditor, IWorldContainer parent, TerrainDecal tDecal) { this.app = worldEditor; this.parent = parent; this.decal = tDecal; this.placing = true; oldPosition = new Vector2(decal.Position.x, decal.Position.z); }
/// <summary> /// Use this constructor when you want to drag a TerrainDecal and have the drag stopped on a left button mouse down. Creates its own decal and disposes it. /// Usually used to place new decals. /// </summary> /// <param name="worldEditor"></param> /// <param name="parent"></param> /// <param name="name"></param> /// <param name="position"></param> /// <param name="size"></param> /// <param name="callback"></param> public DragHelper(WorldEditor worldEditor, IWorldContainer parent, string name, string fname, Vector2 size, DragComplete callback) { this.app = worldEditor; this.imageName = fname; this.size = size; this.name = name; stopOnUp = false; disposeDragObject = true; decal = new TerrainDecal(app, parent, name, new Vector2(0f, 0f), size, imageName, 1); decal.AddToScene(); dragCallback = callback; but = app.MouseSelectButton; app.InterceptMouse(new MouseMoveIntercepter(DecalDragMove), new MouseButtonIntercepter(DecalDragButtonDown), new MouseButtonIntercepter(DecalDragButtonUp), new MouseCaptureLost(DragCaptureLost), true); }
public void Execute() { if (placing) { new DragHelper(app, parent, name, filename, size, new DragComplete(DragCallback)); } else { decal = new TerrainDecal(app, parent, name, new Vector2(location.x, location.z), size, filename, priority); parent.Add(decal); for (int i = app.SelectedObject.Count - 1; i >= 0; i--) { app.SelectedObject[i].Node.UnSelect(); } decal.Node.Select(); } }
private bool DragCallback(bool accept, Vector3 loc) { if (accept) { this.location = loc; decal = new TerrainDecal(app, parent, name, new Vector2(location.x, location.z), size, filename, priority); parent.Add(decal); for (int i = app.SelectedObject.Count - 1; i >= 0; i--) { app.SelectedObject[i].Node.UnSelect(); } if (decal.Node != null) { decal.Node.Select(); } placing = false; } else { cancelled = true; } return(true); }
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 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 DragCallback(bool accept, Vector3 loc) { if (accept) { this.location = loc; decal = new TerrainDecal(app, parent, name, new Vector2(location.x, location.z), size, filename, priority); parent.Add(decal); for (int i = app.SelectedObject.Count - 1; i >= 0; i--) { app.SelectedObject[i].Node.UnSelect(); } if (decal.Node != null) { decal.Node.Select(); } placing = false; } else { cancelled = true; } return true; }
public DragDecalCommandFactory(WorldEditor worldEditor, IWorldContainer parent, TerrainDecal tDecal) { this.app = worldEditor; this.parent = parent; this.decal = tDecal; }