Esempio n. 1
0
        public void fromXmlFile(string pointer)
        {
            string name = pointer.Replace(gameWindow.templateFolder, "");

            Template newTemp = new Template();

            newTemp.type = Material.FROM_XML;
            newTemp.loaded = false;
            newTemp.name = name;
            newTemp.pointer = pointer;
            newTemp.filePosition = 0;

            register(newTemp);
        }
Esempio n. 2
0
        public void fromXmlFile(string pointer)
        {
            string name = pointer.Replace(gameWindow.templateFolder, "");

            if (!templateNames.ContainsKey(name))
            {
                Template newTemp = new Template();

                newTemp.type = Template.Type.fromXml;
                newTemp.loaded = false;
                newTemp.name = name;
                newTemp.pointer = pointer;
                newTemp.filePosition = 0;

                register(newTemp);
            }
        }
Esempio n. 3
0
 private void register(Template newTemp)
 {
     newTemp.identifier = templates.Count;
     templates.Add(newTemp);
     templateNames.Add(newTemp.name, newTemp.identifier);
 }
Esempio n. 4
0
        private void loadTemplate(Template target)
        {
            XmlTextReader reader = new XmlTextReader(target.pointer);

            target.meshes = new List<string> { };
            target.pmeshes = new List<string> { };
            target.materials = new List<string> { };

            target.isStatic = false;
            target.useType = Template.UseType.Model;

            while (reader.Read())
            {
                // parsing data in template tag
                if (reader.Name == "template")
                {
                    while (reader.MoveToNextAttribute())
                    {
                        if (reader.Name == "name")
                            target.name = reader.Value;

                        if (reader.Name == "type")
                        {
                            switch (reader.Value)
                            {
                                case "animated":
                                    target.useType = Template.UseType.Animated;
                                    break;
                                case "meta":
                                    target.useType = Template.UseType.Meta;
                                    break;
                                default:
                                    target.useType = Template.UseType.Model;
                                    break;
                            }
                        }

                    }

                    gameWindow.log("parsing template: " + target.name);
                    reader.MoveToElement();

                    while (reader.Read())
                    {
                        if (reader.Name == "template")
                            break;

                        if (reader.Name == "static")
                            target.isStatic = true;

                        if (reader.Name == "material" && reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                if (reader.Name == "source")
                                {
                                    target.materials.Add(reader.Value);
                                    gameWindow.log("material: " + reader.Value);
                                }
                            }
                        }

                        if (reader.Name == "mesh" && reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                if (reader.Name == "source")
                                {
                                    target.meshes.Add(reader.Value);
                                    gameWindow.log("mesh: " + reader.Value);
                                }
                            }
                        }

                        if (reader.Name == "pmesh" && reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                if (reader.Name == "source")
                                {
                                    target.pmeshes.Add(reader.Value);
                                    gameWindow.log("phys mesh: " + reader.Value);
                                }
                            }
                        }

                        if (reader.Name == "position" && reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                if (reader.Name == "offset")
                                {
                                    target.positionOffset = GenericMethods.FloatFromString(reader.Value);
                                    gameWindow.log("offset: " + reader.Value);
                                }
                            }
                        }

                        if (reader.Name == "volume" && reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                if (reader.Name == "radius")
                                {
                                    target.volumeRadius = GenericMethods.FloatFromString(reader.Value);
                                    gameWindow.log("radius: " + reader.Value);
                                }
                            }
                        }

                        if (reader.Name == "light" && reader.HasAttributes)
                        {
                            while (reader.MoveToNextAttribute())
                            {
                                target.hasLight = true;

                                if (reader.Name == "color")
                                {
                                    target.lightColor = GenericMethods.VectorFromString(reader.Value);
                                }
                            }
                        }

                        if (reader.Name == "normal")
                        {
                            target.normal = true;
                        }

                        target.loaded = true;
                        templates[target.identifier] = target;
                    }
                }
            }
        }