public Tree(XmlReader r, Forest parent, WorldEditor worldEditor) { this.app = worldEditor; this.parent = parent; FromXml(r); }
public Tree(string name, string descriptionFilename, float scale, float scalevariance, uint instances, Forest parent, WorldEditor app) { this.app = app; this.name = name; this.parent = parent; this.descriptionFilename = descriptionFilename; this.scale = scale; this.scaleVariance = scalevariance; this.instances = instances; }
public AddTreeCommand(WorldEditor worldEditor, Forest forest, float scale, float scaleVariance, string filename, string name, uint instances) { this.app = worldEditor; this.forest = forest; this.scale = scale; this.scaleVariance = scaleVariance; this.filename = filename; this.name = name; this.instances = instances; }
public void Execute() { if (forest == null) { forest = new Forest(filename, windSpeed, windDirection, seed, bound, app); } bound.Add(forest); for (int i = app.SelectedObject.Count - 1; i >= 0; i--) { app.SelectedObject[i].Node.UnSelect(); } if (forest.Node != null) { forest.Node.Select(); } }
public void AddToTree(WorldTreeNode parentNode) { this.parentNode = parentNode; inTree = true; // create a node for the collection and add it to the parent node = app.MakeTreeNode(this, name); parentNode.Nodes.Add(node); Forest forest = this; CommandMenuBuilder menuBuilder = new CommandMenuBuilder(); menuBuilder.Add("Add Tree", new AddTreeCommandFactory(app, forest), app.DefaultCommandClickHandler); menuBuilder.Add("Copy Description", "", app.copyToClipboardMenuButton_Click); menuBuilder.Add("Help", "Forest", app.HelpClickHandler); menuBuilder.Add("Delete", new DeleteObjectCommandFactory(app, parent, this), app.DefaultCommandClickHandler); node.ContextMenuStrip = menuBuilder.Menu; foreach (IWorldObject tree in treeTypes) { tree.AddToTree(node); } buttonBar = menuBuilder.ButtonBar; }
public void Clone(IWorldContainer copyParent) { Forest clone = new Forest(filename, windSpeed, windDirection, seed, copyParent as Boundary, app); foreach(IWorldObject child in treeTypes) { child.Clone(clone); } copyParent.Add(clone); }
public AddTreeCommandFactory(WorldEditor worldEditor, Forest parent) { app = worldEditor; this.parent = parent; }
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; } } } }
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 "Name": this.name = r.Value; break; case "Priority": this.priority = int.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. while (r.Read()) { if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "PointCollection": if (!r.IsEmptyElement) { this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial,MPPointType.Boundary, r); Add(points); points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler); } break; case "NameValuePairs": this.nameValuePairs = new NameValueObject(r); break; case "Forest": Forest forest = new Forest(r, this, app); Add(forest); break; case "Fog": Fog fog = new Fog(r, this, app); Add(fog); break; case "Water": Water water = new Water(r, this, app); Add(water); break; case "Sound": Sound sound = new Sound(r, (IWorldContainer)this, app); Add(sound); break; case "Grass": Grass grass = new Grass(r, this, app); Add(grass); break; case "SpawnGen": SpawnGen mob = new SpawnGen(r, app, this); Add(mob); break; case "AmbientLight": AmbientLight ambientLight = new AmbientLight(app, this, r); Add(ambientLight); break; case "DirectionalLight": DirectionalLight directionalLight = new DirectionalLight(app, this, r); Add(directionalLight); break; } } } if (points == null) { this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, MPPointType.Boundary); Add(points); points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler); } }
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 "Name": this.name = r.Value; break; case "Priority": this.priority = int.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. while (r.Read()) { if (r.NodeType == XmlNodeType.EndElement) { break; } if (r.NodeType == XmlNodeType.Element) { switch (r.Name) { case "PointCollection": if (!r.IsEmptyElement) { this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, MPPointType.Boundary, r); Add(points); points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler); } break; case "NameValuePairs": this.nameValuePairs = new NameValueObject(r); break; case "Forest": Forest forest = new Forest(r, this, app); Add(forest); break; case "Fog": Fog fog = new Fog(r, this, app); Add(fog); break; case "Water": Water water = new Water(r, this, app); Add(water); break; case "Sound": Sound sound = new Sound(r, (IWorldContainer)this, app); Add(sound); break; case "Grass": Grass grass = new Grass(r, this, app); Add(grass); break; case "SpawnGen": SpawnGen mob = new SpawnGen(r, app, this); Add(mob); break; case "AmbientLight": AmbientLight ambientLight = new AmbientLight(app, this, r); Add(ambientLight); break; case "DirectionalLight": DirectionalLight directionalLight = new DirectionalLight(app, this, r); Add(directionalLight); break; } } } if (points == null) { this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, MPPointType.Boundary); Add(points); points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler); } }