public Grass(Boundary parent, WorldEditor app, String name)
 {
     this.parent = parent;
     this.app = app;
     this.name = name;
     this.plantList = new List<IWorldObject>();
 }
        public void Execute()
        {
            if (region == null)
            {
                region = new Boundary(parent, app, name, priority);
            }
            parent.Add(region);
            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (region.Node != null)
            {
                region.Node.Select();
            }

            if (placing)
            {
                dragMarker = new DisplayObject("RegionDrag", app, "Dragging", app.Scene, app.Config.RegionPointMeshName, Vector3.Zero, Vector3.UnitScale, Vector3.Zero, null);
                dragMarker.MaterialName = app.Config.RegionPointMaterial;
                dragMarker.ScaleWithCameraDistance = true;
                new MultiPointPlacementHelper(app, dragMarker, new MultiPointValidate(PointValidate), new MultiPointComplete(PointPlacementComplete));

                placing = false;
            }
        }
 public AddSpawnGenToRegionCommand(WorldEditor appin, Boundary parentapp, int respawnTimein, uint numberOfSpawnsin, string templateNamein)
 {
     this.app = appin;
     this.parent = parentapp;
     this.respawnTime = respawnTimein;
     this.numberOfSpawns = numberOfSpawnsin;
     this.templateName = templateNamein;
 }
 public AddFogCommand(WorldEditor app, Boundary parent, ColorEx color, float nearin, float farin)
 {
     this.app = app;
     this.parent = parent;
     this.color = color;
     this.near = nearin;
     this.far = farin;
 }
        public Grass(XmlReader r, Boundary parent, WorldEditor app)
        {
            this.parent = parent;
            this.app = app;
            this.plantList = new List<IWorldObject>();

            FromXml(r);
        }
Example #6
0
        public Fog(XmlReader r, Boundary parent, WorldEditor app)
        {
            this.app = app;
            this.parentNode = null;
            this.parent = parent;

            FromXml(r);
        }
        public Forest(XmlReader r, Boundary parent, WorldEditor worldEditor)
        {
            this.parent = parent;
            this.app = worldEditor;
            this.treeTypes = new List<IWorldObject>();

            FromXml(r);
        }
 public AddForestCommand(WorldEditor worldEditor, Boundary boundin, int seedin, float windSpeedin, Vector3 windDirectionin, string filenamein)
 {
     this.app = worldEditor;
     this.bound = boundin;
     this.seed = seedin;
     this.windSpeed = windSpeedin;
     this.windDirection = windDirectionin;
     this.filename = filenamein;
 }
 public DirectionalLight(WorldEditor worldEditor, Boundary parent, Vector3 lightDir, ColorEx diff, ColorEx spec)
 {
     this.app = worldEditor;
     this.parent = parent;
     this.lightDirection = lightDir;
     this.diffuse = diff;
     this.specular = spec;
     this.name = String.Format("{0}-{1}", this.parent.Name, "DirectionalLight");
 }
 public AddDirectionalLightCommand(WorldEditor worldEditor, IWorldContainer parentObject, String objectName, string meshName, ColorEx specular, ColorEx diffuse)
 {
     this.app = worldEditor;
     this.parent =  (Boundary) parentObject;
     this.name = objectName;
     this.meshName = meshName;
     this.specular = specular;
     this.diffuse = diffuse;
     this.scene = app.Scene;
 }
 public Forest(string filename, float windspeed, Vector3 winddirection, int seed, Boundary parent, WorldEditor app)
 {
     this.parent = parent;
     this.app = app;
     this.name = "Forest";
     this.filename = filename;
     this.windSpeed = windspeed;
     this.windDirection = winddirection;
     this.treeTypes = new List<IWorldObject>();
     this.seed = seed;
 }
        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;
                    }
                }
            }
        }
Example #13
0
 public AddGrassCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject, Boundary bound)
 {
     app        = worldEditor;
     parent     = parentObject;
     this.bound = bound;
 }
 // ColorEx cx;
 public AddFogCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject, Boundary bound)
 {
     this.app = worldEditor;
     this.parentObject = parentObject;
     this.parent = bound;
 }
Example #15
0
 public AddSpawnGenToRegionCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject)
 {
     this.app    = worldEditor;
     this.parent = (Boundary)parentObject;
 }
 public AddWaterCommand(WorldEditor worldEditor, Boundary boundin, float heightin)
 {
     this.app = worldEditor;
     this.parent = boundin;
     this.height = heightin;
 }
 public AddGrassCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject, Boundary bound)
 {
     app = worldEditor;
         parent = parentObject;
         this.bound = bound;
 }
        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 AddSpawnGenToRegionCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject)
 {
     this.app = worldEditor;
     this.parent = (Boundary)parentObject;
 }
 public Forest(string filename, float windspeed, Vector3 winddirection, int seed, Boundary parent, WorldEditor app)
 {
     this.parent        = parent;
     this.app           = app;
     this.name          = "Forest";
     this.filename      = filename;
     this.windSpeed     = windspeed;
     this.windDirection = winddirection;
     this.treeTypes     = new List <IWorldObject>();
     this.seed          = seed;
 }
 public void Clone(IWorldContainer copyParent)
 {
     Boundary clone = new Boundary(app, copyParent, name, priority);
     foreach (IWorldObject child in children)
     {
         child.Clone(clone);
     }
     copyParent.Add(clone);
 }
Example #22
0
 public AddAmbientLightCommand(WorldEditor app, Boundary parent, ColorEx color)
 {
     this.app    = app;
     this.parent = parent;
     this.color  = color;
 }
 public DirectionalLight(WorldEditor worldEditor, Boundary parent, XmlReader r)
 {
     this.app = worldEditor;
     this.parent = parent;
     fromXml(r);
 }
Example #24
0
 public AddDirectionalLightCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject)
 {
     this.app    = worldEditor;
     this.parent = (Boundary)parentObject;
 }
 public AddAmbientLightCommand(WorldEditor app, Boundary parent, ColorEx color)
 {
     this.app = app;
     this.parent = parent;
     this.color = color;
 }
 public AddDirectionalLightCommandFactory(WorldEditor worldEditor, IWorldContainer parentObject)
 {
     this.app = worldEditor;
     this.parent = (Boundary)parentObject;
 }
 public AddGrassCommand(WorldEditor worldEditor, Boundary boundin, string name)
 {
     this.app = worldEditor;
     this.parent = boundin;
     this.Name = name;
 }
 // ColorEx cx;
 public AddAmbientLightCommandFactory(WorldEditor worldEditor, Boundary bound)
 {
     this.app = worldEditor;
     this.parent = bound;
 }
Example #29
-1
 public Fog(WorldEditor app, Boundary parent, ColorEx color, float nearin, float farin)
 {
     this.app = app;
     this.parentNode = null;
     this.parent = parent;
     this.cx = color;
     this.near = nearin;
     this.far = farin;
 }