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();
     }
 }
 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();
     }
 }
예제 #3
0
        public void Clone(IWorldContainer copyParent)
        {
            Fog clone = new Fog(app, copyParent as Boundary, cx, near, far);

            copyParent.Add(clone);
        }
예제 #4
0
 public void Clone(IWorldContainer copyParent)
 {
     Fog clone = new Fog(app, copyParent as Boundary, cx, near, far);
     copyParent.Add(clone);
 }
        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;
                    }
                }
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }