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();
     }
 }
Example #2
0
 public void Execute()
 {
     if (mob == null)
     {
         mob = new SpawnGen(app, parent, respawnTime, numberOfSpawns, templateName);
     }
     parent.Add(mob);
     for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
     {
         app.SelectedObject[i].Node.UnSelect();
     }
     if (mob.Node != null)
     {
         mob.Node.Select();
     }
 }
 public void Execute()
 {
     if (fog == null)
     {
         fog = new Fog(app, parent, color, near, far);
     }
     parent.Add(fog);
     for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
     {
         app.SelectedObject[i].Node.UnSelect();
     }
     if (fog.Node != null)
     {
         fog.Node.Select();
     }
 }
Example #4
0
 public void Execute()
 {
     if (light == null)
     {
         light = new AmbientLight(app, parent, color);
     }
     parent.Add(light);
     for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
     {
         app.SelectedObject[i].Node.UnSelect();
     }
     if (light.Node != null)
     {
         light.Node.Select();
     }
 }
Example #5
0
        public void Execute()
        {
            if (water == null)
            {
                water = new Water(this.height, parent, app);
            }
            parent.Add(water);

            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (water.Node != null)
            {
                water.Node.Select();
            }
        }
        public void Execute()
        {
            if (grass == null)
            {
                grass = new Grass(parent, app, this.Name);
            }
            parent.Add(grass);

            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (grass.Node != null)
            {
                grass.Node.Select();
            }
        }
        public void Execute()
        {
            if (directionalLight == null)
            {
                directionalLight = new DirectionalLight(app, parent, new Vector3(0f, 0f, 0f), diffuse, specular);
            }
            parent.Add(directionalLight);

            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (directionalLight.Node != null)
            {
                directionalLight.Node.Select();
            }
        }
        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;
                    }
                }
            }
        }