Esempio n. 1
0
        protected void processNode(XmlElement XMLNode)
        {
            Node node = new Node();
            node.Name = getAttrib(XMLNode, "name");

            // Process other attributes
            XmlElement element;

            // Process position (?)
            element = (XmlElement) XMLNode.SelectSingleNode("position");
            if (element != null) {
                node.Position = parseVector3(element);
            }

            // Process quaternion (?)
            element = (XmlElement) XMLNode.SelectSingleNode("quaternion");
            if (element != null) {
                node.Orientation = parseQuaternion(element);
            }

            // Process rotation (?)
            element = (XmlElement) XMLNode.SelectSingleNode("rotation");
            if (element != null) {
                node.Orientation = parseRotation(element);
            }

            // Process scale (?)
            element = (XmlElement) XMLNode.SelectSingleNode("scale");
            if (element != null) {
                node.Dimensions = parseVector3(element);
            }

            // Process entity (*)
            element = (XmlElement) XMLNode.SelectSingleNode("entity");
            if (element != null) {
                processEntity(element, node);
            }

            // Process childnodes
            element = (XmlElement) XMLNode.SelectSingleNode("node");
            while (element != null) {
                processNode(element);
                MessageBox.Show("Node with child node found! It will be parsed, but it will probably look wrong ingame! "
                    + "Make sure none of your entity nodes (the ones with the grey icons) have any parent nodes!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
                element = (XmlElement) element.NextSibling;
            }

            Nodes.Add(node);

            #if VERBOSE
            Console.WriteLine("Successfully processed node \"" + node.Name + "\"");
            #endif
        }
Esempio n. 2
0
        protected void processEntity(XmlElement XMLNode, Node node)
        {
            // Process attributes

            // Create the entity
            Entity ent = new Entity();
            ent.Mesh = getAttrib(XMLNode, "meshFile");
            ent.Name = getAttrib(XMLNode, "name");
            ent.CastShadows = getAttribBool(XMLNode, "castShadows", false);
            ent.ReceiveShadows = getAttribBool(XMLNode, "receiveShadows", true);
            ent.Static = getAttribBool(XMLNode, "static", true);
            //ent.RenderingDistance = getAttribReal(XMLNode, "renderingDistance", 0);
            //ent.Visible = getAttribBool(XMLNode, "visible", true);

            try {
                XmlElement element;
                // Process subentities (?)
                element = (XmlElement) XMLNode.SelectSingleNode("subentities");
                if (element != null) {
                    element = (XmlElement) element.FirstChild;
                    while (element != null) {
                        ent.Material = getAttrib(element, "materialName");
                        element = (XmlElement) element.NextSibling;
                    }
                }
            }
            catch (Exception e) {
                MessageBox.Show("Error loading entity \"" + ent.Name + "\"! " + e.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            node.Entity = ent;
            ent.Owner = node;
            #if VERBOSE
            Console.WriteLine("Successfully processed entity \"" + ent.Name + "\"");
            #endif
        }