private void fromXml(System.Xml.XmlReader r) { // Parse sub-elements while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Color": color = XmlHelperClass.ParseColorAttributes(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } }
public PointCollection(IWorldContainer parent, WorldEditor worldEditor, bool noIntersect, bool displayMarkers, string markerMeshName, string markerMaterialName, MPPointType type, XmlReader r) : this(parent, worldEditor, noIntersect, displayMarkers, markerMeshName, markerMaterialName, type) { // // don't do the intersection test when adding points from xml // this.noIntersect = false; 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) { if (String.Equals(r.Name, "Point")) { Vector3 ptLoc = XmlHelperClass.ParseVectorAttributes(r); int pointNum; AddPoint(ptLoc, out pointNum); } } } this.noIntersect = noIntersect; }
public void FromXml(XmlReader r) { // first parse the attributes for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "Name": this.name = r.Value; break; case "Filename": this.filename = r.Value; break; case "WindSpeed": this.windSpeed = float.Parse(r.Value); break; case "Seed": this.seed = int.Parse(r.Value); break; case "WindDirection": windDirection = XmlHelperClass.ParseVectorAttributes(r); break; } } r.MoveToElement(); //Moves the reader back to the element node. if (!r.IsEmptyElement) { while (r.Read()) { if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "Tree": Tree t = new Tree(r, this, app); Add(t); break; } } } } }
private void fromXml(XmlReader r) { // first parse the attributes for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "Far": this.far = float.Parse(r.Value); break; case "Near": this.near = float.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. // now parse the sub-elements while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Color": color = XmlHelperClass.ParseColorAttributes(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } }
protected void FromXml(XmlReader r) { while (r.Read()) { if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "PointCollection": while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Element) { string elementName = r.Name; switch (elementName) { case "Point": points.Add(XmlHelperClass.ParseVectorAttributes(r)); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } r.MoveToElement(); //Moves the reader back to the element node. break; case "NameValuePairs": this.nameValuePairs = new NameValueObject(r); break; } } } }
private void fromXml(XmlReader r) { // Parse sub-elements parseOrientation(r); while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Direction": this.lightDirection = XmlHelperClass.ParseVectorAttributes(r); break; case "Diffuse": diffuse = XmlHelperClass.ParseColorAttributes(r); break; case "Specular": specular = XmlHelperClass.ParseColorAttributes(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } }
protected void FromXml(XmlReader r) { // first parse the attributes for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "DisplayOcean": displayOcean = (r.Value == "True"); break; case "UseParams": useParams = (r.Value == "True"); break; case "WaveHeight": waveHeight = float.Parse(r.Value); break; case "SeaLevel": seaLevel = float.Parse(r.Value); break; case "BumpScale": bumpScale = float.Parse(r.Value); break; case "BumpSpeedX": bumpSpeedX = float.Parse(r.Value); break; case "BumpSpeedZ": bumpSpeedZ = float.Parse(r.Value); break; case "TextureScaleX": textureScaleX = float.Parse(r.Value); break; case "TextureScaleZ": textureScaleZ = float.Parse(r.Value); break; default: break; } } r.MoveToElement(); //Moves the reader back to the element node. if (!r.IsEmptyElement) { // now parse the sub-elements while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "DeepColor": deepColor = XmlHelperClass.ParseColorAttributes(r); break; case "ShallowColor": shallowColor = XmlHelperClass.ParseColorAttributes(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } } if (!displayOcean) { Axiom.SceneManagers.Multiverse.TerrainManager.Instance.ShowOcean = displayOcean; } }
protected void FromXml(XmlReader r) { // first parse the attributes bool adjustHeightFound = false; for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "Name": this.name = r.Value; break; //case "Sound": // this.soundAssetName = r.Value; // break; case "TerrainOffset": offsetFound = true; terrainOffset = float.Parse(r.Value); break; case "AllowHeightAdjustment": adjustHeightFound = true; if (String.Equals(r.Value.ToLower(), "false")) { allowAdjustHeightOffTerrain = false; } break; case "Azimuth": azimuth = float.Parse(r.Value); break; case "Zenith": zenith = float.Parse(r.Value); break; case "WorldViewSelect": worldViewSelectable = bool.Parse(r.Value); break; } } // this.nameValuePairs = new NameValueObject(); r.Read(); do { if (r.NodeType == XmlNodeType.Whitespace) { continue; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "Position": this.position = XmlHelperClass.ParseVectorAttributes(r); break; case "Orientation": orientation = XmlHelperClass.ParseQuaternion(r); break; case "NameValuePairs": this.nameValuePairs = new NameValueObject(r); break; case "ParticleEffect": ParticleEffect particle = new ParticleEffect(r, this, app); Add(particle); break; case "SpawnGen": SpawnGen mob = new SpawnGen(r, app, this); Add(mob); break; case "Sound": Sound sound = new Sound(r, this, app); Add(sound); break; case "Color": Color = XmlHelperClass.ParseColorAttributes(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } while (r.Read()); if (!adjustHeightFound) { allowAdjustHeightOffTerrain = true; } if (!offsetFound) { terrainOffset = this.Position.y - app.GetTerrainHeight(position.x, position.z); } if (orientation != null && disp != null) { disp.SetOrientation(orientation); foreach (IWorldObject obj in children) { if (obj is ParticleEffect) { (obj as ParticleEffect).Orientation = this.orientation; } } } }
protected void FromXml(XmlReader r) { bool adjustHeightFound = false; bool offsetFound = false; bool pRFound = false; // first parse name and mesh, which are attributes for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "Name": this.name = r.Value; break; case "Mesh": this.meshName = r.Value; break; case "Sound": string filename = r.Value; if (!String.Equals(filename, "")) { ICommandFactory ret = new AddSoundCommandFactory(app, this, r.Value); ICommand com = ret.CreateCommand(); com.Execute(); } break; case "TerrainOffset": terrainOffset = float.Parse(r.Value); offsetFound = true; break; case "AllowHeightAdjustment": if (String.Equals(r.Value.ToLower(), "false")) { allowAdjustHeightOffTerrain = false; } break; case "AcceptObjectPlacement": acceptObjectPlacement = bool.Parse(r.Value); break; case "PerceptionRadius": pRFound = true; perceptionRadius = float.Parse(r.Value); break; case "CastShadows": castShadows = bool.Parse(r.Value); break; case "ReceiveShadows": receiveShadows = bool.Parse(r.Value); break; case "Azimuth": azimuth = float.Parse(r.Value); break; case "Zenith": zenith = float.Parse(r.Value); break; case "WorldViewSelect": worldViewSelectable = bool.Parse(r.Value); break; case "Targetable": targetable = bool.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. // now parse the sub-elements while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Position": location = XmlHelperClass.ParseVectorAttributes(r); break; case "Scale": scale = XmlHelperClass.ParseVectorAttributes(r); break; case "Rotation": Vector3 rotation = XmlHelperClass.ParseVectorAttributes(r); // force rotation to be between -180 and 180 while (rotation.y < -180) { rotation.y += 360; } while (rotation.y > 180) { rotation.y -= 360; } SetDirection(rotation.y, 90f); break; case "Orientation": orientation = XmlHelperClass.ParseQuaternion(r); break; case "SubMeshes": subMeshes = new SubMeshCollection(r); if (!subMeshes.CheckValid(app, meshName)) { app.AddPopupMessage(string.Format("Some submesh names in {0} changed. Submesh display and material parameters for this object were reset.", meshName)); // if the check fails, then reset the subMeshes from the mesh subMeshes = new SubMeshCollection(meshName); } break; case "NameValuePairs": nameValuePairs = new NameValueObject(r); break; case "ParticleEffect": ParticleEffect particle = new ParticleEffect(r, this, app); Add(particle); break; case "PathData": pathData = new PathData(r); locationDirty = pathData.Version != pathData.CodeVersion; break; case "Sound": Sound sound = new Sound(r, this, app); Add(sound); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } if (!adjustHeightFound) { allowAdjustHeightOffTerrain = true; } if (!offsetFound) { terrainOffset = location.y - app.GetTerrainHeight(location.x, location.z); } if (!pRFound && nameValuePairs != null) { valueItem value = nameValuePairs.LookUp("perceptionRadius"); if (value != null && ValidityHelperClass.isFloat(value.value)) { perceptionRadius = float.Parse(value.value); } } return; }
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; } } } }
protected void fromXML(XmlReader r) { bool offsetFound = false; bool adjustHeightFound = false; for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); switch (r.Name) { case "Name": name = r.Value; break; case "AttenuationRange": attenuationRange = float.Parse(r.Value); break; case "AttenuationConstant": attenuationConstant = float.Parse(r.Value); break; case "AttenuationLinear": attenuationLinear = float.Parse(r.Value); break; case "AttenuationQuadratic": attenuationQuadratic = float.Parse(r.Value); break; case "TerrainOffset": offsetFound = true; terrainOffset = float.Parse(r.Value); offsetFound = true; break; case "AllowHeightAdjustment": adjustHeightFound = true; if (String.Equals(r.Value.ToLower(), "false")) { allowAdjustHeightOffTerrain = false; } break; case "WorldViewSelect": worldViewSelectable = bool.Parse(r.Value); break; } } r.MoveToElement(); while (r.Read()) { if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Whitespace) { continue; } switch (r.Name) { case "Position": position = XmlHelperClass.ParseVectorAttributes(r); break; case "Specular": specular = XmlHelperClass.ParseColorAttributes(r); break; case "Diffuse": diffuse = XmlHelperClass.ParseColorAttributes(r); break; } } if (!adjustHeightFound) { allowAdjustHeightOffTerrain = true; } if (!offsetFound) { terrainOffset = position.y - app.GetTerrainHeight(position.x, position.z); } }