public WorldRoot(String worldName, MultiSelectTreeView tree, WorldEditor worldEditor) { instance = this; name = worldName; treeView = tree; app = worldEditor; worldTerrain = new WorldTerrain(app); ocean = new Ocean(this, app); skybox = new Skybox(this, app); fog = new GlobalFog(this, app); ambientLight = new GlobalAmbientLight(this, app); directionalLight = new GlobalDirectionalLight(this, app); worldCollections = new List <WorldObjectCollection>(); pathObjectTypes = new PathObjectTypeContainer(this, app); }
public WorldRoot(XmlReader r, String worldFilename, MultiSelectTreeView tree, WorldEditor worldEditor, bool loadCollections) { instance = this; treeView = tree; app = worldEditor; worldFilePath = worldFilename; this.loadCollections = loadCollections; worldCollections = new List <WorldObjectCollection>(); if (loadCollections) { FromXml(r); } else { FromXml(r, loadCollections); } // if the XML doesn't have ocean in it, then add it here if (ocean == null) { ocean = new Ocean(this, app); } if (skybox == null) { skybox = new Skybox(this, app); } if (fog == null) { fog = new GlobalFog(this, app); } if (ambientLight == null) { ambientLight = new GlobalAmbientLight(this, app); } if (directionalLight == null) { directionalLight = new GlobalDirectionalLight(this, app); } if (pathObjectTypes == null) { pathObjectTypes = new PathObjectTypeContainer(this, app); } }
public WorldRoot(XmlReader r, String worldFilename, MultiSelectTreeView tree, WorldEditor worldEditor, bool loadCollections) { instance = this; treeView = tree; app = worldEditor; worldFilePath = worldFilename; this.loadCollections = loadCollections; worldCollections = new List<WorldObjectCollection>(); if (loadCollections) { FromXml(r); } else { FromXml(r, loadCollections); } // if the XML doesn't have ocean in it, then add it here if (ocean == null) { ocean = new Ocean(this, app); } if (skybox == null) { skybox = new Skybox(this, app); } if (fog == null) { fog = new GlobalFog(this, app); } if (ambientLight == null) { ambientLight = new GlobalAmbientLight(this, app); } if (directionalLight == null) { directionalLight = new GlobalDirectionalLight(this, app); } if (pathObjectTypes == null) { pathObjectTypes = new PathObjectTypeContainer(this, app); } }
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; } } } }
public WorldRoot(String worldName, MultiSelectTreeView tree, WorldEditor worldEditor) { instance = this; name = worldName; treeView = tree; app = worldEditor; worldTerrain = new WorldTerrain(app); ocean = new Ocean(this, app); skybox = new Skybox(this, app); fog = new GlobalFog(this, app); ambientLight = new GlobalAmbientLight(this, app); directionalLight = new GlobalDirectionalLight(this, app); worldCollections = new List<WorldObjectCollection>(); pathObjectTypes = new PathObjectTypeContainer(this, app); }