public AddObjectParticleEffectCommand(StaticObject parent, WorldEditor app, string particleEffectName, float positionScale, float velocityScale, string attachmentPointName, Quaternion orientation) { this.app = app; this.parent = parent; this.particleEffectName = particleEffectName; this.positionScale = positionScale; this.velocityScale = velocityScale; this.attachmentPointName = attachmentPointName; this.orientation = orientation; }
private bool DragCallback(bool accept, Vector3 loc) { placing = false; dragObject.Dispose(); if (accept) { location = loc; Vector3 scaleVec = new Vector3(scale, scale, scale); Vector3 rotVec = new Vector3(0, rotation, 0); staticObject = new StaticObject(name, parent, app, meshName, location, scaleVec, rotVec); parent.Add(staticObject); for (int i = app.SelectedObject.Count - 1; i >= 0; i--) { app.SelectedObject[i].Node.UnSelect(); } if (staticObject.Node != null) { staticObject.Node.Select(); } } else { cancelled = true; } return true; }
public void Execute() { if (!cancelled) { Vector3 scaleVec = new Vector3(scale, scale, scale); Vector3 rotVec = new Vector3(0, rotation, 0); if (placing) { // we need to place the object (which is handled asynchronously) before we can create it dragObject = new DisplayObject(name, app, "Drag", app.Scene, meshName, location, scaleVec, rotVec, null); if (placeMultiple) { new MultiPointPlacementHelper(app, ObjectValidate, dragObject, ObjectPlacementComplete); cancelled = true; } else { new DragHelper(app, new DragComplete(DragCallback), dragObject, false); } } else { // object has already been placed, so create it now // only create it if it doesn't exist already if (staticObject == null) { staticObject = new StaticObject(name, parent, app, meshName, location, scaleVec, rotVec); } parent.Add(staticObject); for (int i = app.SelectedObject.Count - 1; i >= 0; i--) { if (app.SelectedObject[i] != null && app.SelectedObject[i].Node != null) { app.SelectedObject[i].Node.UnSelect(); } } if (staticObject.Node != null) { staticObject.Node.Select(); } } } }
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); } }
public AddObjectParticleEffectCommandFactory(WorldEditor worldEditor, StaticObject parentObject) { app = worldEditor; parent = parentObject; }
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 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 DirectionAndObject(CameraDirection dir, StaticObject obj) { this.dir = dir; this.obj = obj; }
public GenerateModelPathsCommand(IWorldObject modelObj) { this.modelObj = (StaticObject)modelObj; }
public void Clone(IWorldContainer copyParent) { StaticObject clone = new StaticObject(name, copyParent, app, meshName, Position, scale, rotation); clone.ReceiveShadows = receiveShadows; clone.CastShadows = castShadows; clone.AllowAdjustHeightOffTerrain = allowAdjustHeightOffTerrain; clone.SubMeshes = new SubMeshCollection(this.SubMeshes); clone.NameValue = new NameValueObject(this.NameValue); clone.TerrainOffset = terrainOffset; foreach (IWorldObject child in children) { child.Clone(clone); } copyParent.Add(clone); }