Esempio n. 1
0
        public static void Copy(IrrData data, IrrNodeAnimatedMesh node)
        {
            foreach (IrrData child in data.Children)
            {
                if (string.IsNullOrEmpty(child.Attr.Name))
                    continue;

                switch (child.Attr.Name.ToLower())
                {
                    case "automaticculling":
                        node.AutomaticCulling = CullingType.Box;
                        break;
                    case "debugdatavisible":
                        node.DebugDataVisible = (int)child.Attr.Value;
                        break;
                    case "isdebugobject":
                        node.IsDebugObject = (bool)child.Attr.Value;
                        break;
                    case "mesh":
                        node.Mesh = child.Attr.Value as string;
                        break;
                    case "looping":
                        node.Looping = (bool)child.Attr.Value;
                        break;
                    case "readonlymaterials":
                        node.ReadOnlyMaterials = (bool)child.Attr.Value;
                        break;
                    case "framespersecond":
                        node.FramesPerSecond = (float)child.Attr.Value;
                        break;
                }
            }

            IrrNode.Copy(data, node);
        }
Esempio n. 2
0
        public static IrrScene Get(IrrData data)
        {
            IrrScene scene = new IrrScene();
            Copy(data, scene);

            return scene;
        }
Esempio n. 3
0
        public static new IrrNodeAnimatedMesh Get(IrrData data)
        {
            IrrNodeAnimatedMesh node = new IrrNodeAnimatedMesh();
            Copy(data, node);

            return node;
        }
Esempio n. 4
0
        public static void Copy(IrrData data, IrrNode node)
        {
            foreach (IrrData child in data.Children)
            {
                if (string.IsNullOrEmpty(child.Attr.Name))
                    continue;

                switch (child.Attr.Name.ToLower())
                {
                    case "name":
                        node.Name = child.Attr.Value as string;
                        break;
                    case "id":
                        node.ID = (int)child.Attr.Value;
                        break;
                    case "position":
                        node.Position = child.Attr.Value as float[];
                        break;
                    case "rotation":
                        node.Rotation = child.Attr.Value as float[];
                        break;
                    case "scale":
                        node.Scale = child.Attr.Value as float[];
                        break;
                    case "visible":
                        node.Visible = (bool)child.Attr.Value;
                        break;
                }
            }
        }
Esempio n. 5
0
        public static IrrNode Get(IrrData data)
        {
            IrrNode node = new IrrNode();
            Copy(data, node);

            return node;
        }
Esempio n. 6
0
        public static IrrData FindFromName(IrrData data, string name)
        {
            if (data.Name == name)
                return data;

            foreach (IrrData child in data.Children)
            {
                IrrData d = FindFromName(child, name);
                if (d == null)
                    continue;

                if (d.Name == name)
                    return d;
            }

            return null;
        }
Esempio n. 7
0
        public static void Copy(IrrData data, IrrScene scene)
        {
            foreach (IrrData child in data.Children)
            {
                if (string.IsNullOrEmpty(child.Attr.Name))
                    continue;

                switch (child.Attr.Name.ToLower())
                {
                    case "name":
                        scene.Name = child.Attr.Value as string;
                        break;
                    case "id":
                        scene.ID = (int)child.Attr.Value;
                        break;
                    case "ambientlight":
                        scene.AmbientLight = child.Attr.Value as float[];
                        break;
                }
            }
        }
Esempio n. 8
0
        public bool Run(Stream stream)
        {
            if (stream == null)
                return false;

            XmlDocument doc = new XmlDocument();
            doc.Load(stream);

            IrrData data = new IrrData();
            data.Name = "root";
            foreach (XmlNode node in doc.ChildNodes)
                data.Children.Add(RecursiveNode(doc, node));

            IrrData sceneData = FindFromName(data, "irr_scene");
            if (sceneData == null)
                return false;

            scene = CreateSceneFromData(sceneData);

            return true;
        }
Esempio n. 9
0
        public static void Copy(IrrData data, IrrMaterial material)
        {
            foreach (IrrData child in data.Children)
            {
                if (string.IsNullOrEmpty(child.Attr.Name))
                    continue;

                switch (child.Attr.Name.ToLower())
                {
                    case "type":
                        material.Type = EnumComverter.ToMaterialType(child.Attr.Value as string);
                        break;
                    case "ambient":
                        material.Ambient = child.Attr.Value as byte[];
                        break;
                    case "diffuse":
                        material.Diffuse = child.Attr.Value as byte[];
                        break;
                    case "emissive":
                        material.Emissive = child.Attr.Value as byte[];
                        break;
                    case "specular":
                        material.Specular = child.Attr.Value as byte[];
                        break;
                    case "shininess":
                        material.Shininess = (float)child.Attr.Value;
                        break;
                    case "param1":
                        material.Param1 = (float)child.Attr.Value;
                        break;
                    case "param2":
                        material.Param2 = (float)child.Attr.Value;
                        break;
                    case "texture1":
                        material.AddAsset(material.Texture1 = child.Attr.Value as string);
                        break;
                    case "texture2":
                        material.AddAsset(material.Texture2 = child.Attr.Value as string);
                        break;
                    case "texture3":
                        material.AddAsset(material.Texture3 = child.Attr.Value as string);
                        break;
                    case "texture4":
                        material.AddAsset(material.Texture4 = child.Attr.Value as string);
                        break;
                    case "wireframe":
                        material.Wireframe = (bool)child.Attr.Value;
                        break;
                    case "gouraudshading":
                        material.GouraudShading = (bool)child.Attr.Value;
                        break;
                    case "lighting":
                        material.Lighting = (bool)child.Attr.Value;
                        break;
                    case "zwriteenable":
                        material.ZWriteEnable = (bool)child.Attr.Value;
                        break;
                    case "zbuffer":
                        material.ZBuffer = (int)child.Attr.Value;
                        break;
                    case "backfaceculling":
                        material.BackfaceCulling = (bool)child.Attr.Value;
                        break;
                    case "frontfaceculling":
                        material.FrontfaceCulling = (bool)child.Attr.Value;
                        break;
                    case "fogenable":
                        material.FogEnable = (bool)child.Attr.Value;
                        break;
                    case "normalizenormals":
                        material.NormalizeNormals = (bool)child.Attr.Value;
                        break;
                    case "bilinearfilter1":
                        material.BilinearFilter1 = (bool)child.Attr.Value;
                        break;
                    case "bilinearfilter2":
                        material.BilinearFilter2 = (bool)child.Attr.Value;
                        break;
                    case "bilinearfilter3":
                        material.BilinearFilter3 = (bool)child.Attr.Value;
                        break;
                    case "bilinearfilter4":
                        material.BilinearFilter4 = (bool)child.Attr.Value;
                        break;
                    case "trilinearfilter1":
                        material.TrilinearFilter1 = (bool)child.Attr.Value;
                        break;
                    case "trilinearfilter2":
                        material.TrilinearFilter2 = (bool)child.Attr.Value;
                        break;
                    case "trilinearfilter3":
                        material.TrilinearFilter3 = (bool)child.Attr.Value;
                        break;
                    case "trilinearfilter4":
                        material.TrilinearFilter4 = (bool)child.Attr.Value;
                        break;
                    case "anisotropicfilter1":
                        material.AnisotropicFilter1 = (bool)child.Attr.Value;
                        break;
                    case "anisotropicfilter2":
                        material.AnisotropicFilter2 = (bool)child.Attr.Value;
                        break;
                    case "anisotropicfilter3":
                        material.AnisotropicFilter3 = (bool)child.Attr.Value;
                        break;
                    case "anisotropicfilter4":
                        material.AnisotropicFilter4 = (bool)child.Attr.Value;
                        break;
                    case "texturewrap1":
                        material.TextureWrap1 = EnumComverter.ToClampType(child.Attr.Value as string);
                        break;
                    case "texturewrap2":
                        material.TextureWrap2 = EnumComverter.ToClampType(child.Attr.Value as string);
                        break;
                    case "texturewrap3":
                        material.TextureWrap3 = EnumComverter.ToClampType(child.Attr.Value as string);
                        break;
                    case "texturewrap4":
                        material.TextureWrap4 = EnumComverter.ToClampType(child.Attr.Value as string);
                        break;
                }
            }
        }
Esempio n. 10
0
        public static IrrMaterial Get(IrrData data)
        {
            IrrMaterial material = new IrrMaterial();
            Copy(data, material);

            return material;
        }
Esempio n. 11
0
        private IrrScene CreateSceneFromData(IrrData data)
        {
            IrrScene scene = new IrrScene();
            IrrData attributeData = Parser.FindFromName(data, "attributes");
            IrrScene.Copy(attributeData, scene);

            foreach (IrrData child in data.Children)
            {
                if (child.Name == "node")
                    scene.AddNode(GetNode(child));
            }

            return scene;
        }
Esempio n. 12
0
        private IrrData RecursiveNode(XmlNode parent, XmlNode node)
        {
            IrrData data = new IrrData();

            if (!string.IsNullOrEmpty(node.Name))
            {
                data.Name = node.Name.ToLower();
                data.Attr.Name = XmlHelper.GetAttribute(node, "name");
                string value = XmlHelper.GetAttribute(node, "value");
                string type = XmlHelper.GetAttribute(node, "type");
                switch (node.Name.ToLower())
                {
                    case "xml":
                        break;
                    case "irr_scene":
                        break;
                    case "node":
                        data.Attr.Type = type;
                        break;
                    case "materials":
                        break;
                    case "attributes":
                        break;
                    case "bool":
                        data.Attr.Value = XmlHelper.GetBool(value);
                        break;
                    case "int":
                        data.Attr.Value = XmlHelper.GetInt(value);
                        break;
                    case "float":
                        data.Attr.Value = XmlHelper.GetFloat(value);
                        break;
                    case "string":
                        data.Attr.Value = value;
                        break;
                    case "color":
                        data.Attr.Value = XmlHelper.GetColor(value);
                        break;
                    case "colorf":
                        data.Attr.Value = XmlHelper.GetColorf(value);
                        break;
                    case "vector3d":
                        data.Attr.Value = XmlHelper.GetVector3D(value);
                        break;
                    case "texture":
                        data.Attr.Value = value;
                        break;
                    case "enum":
                        data.Attr.Value = value;
                        break;
                }
            }

            foreach (XmlNode child in node.ChildNodes)
                data.Children.Add(RecursiveNode(node, child));

            return data;
        }
Esempio n. 13
0
        private IrrNode GetNode(IrrData data)
        {
            if (data.Attr.Type == null)
                return null;

            IrrNode node = null;
            IrrData attributeData = Parser.FindFromName(data, "attributes");
            switch (data.Attr.Type)
            {
                case "animatedMesh":
                    node = IrrNodeAnimatedMesh.Get(attributeData);
                    break;
            }

            if (node == null)
                return null;

            foreach (IrrData child in data.Children)
            {
                if (string.IsNullOrEmpty(child.Name))
                    continue;

                if (child.Name == "materials")
                {
                    foreach (IrrData material in child.Children)
                    {
                        if (string.IsNullOrEmpty(material.Name))
                            continue;

                        if (material.Name == "attributes")
                            node.materials.Add(IrrMaterial.Get(material));
                    }
                }
            }

            return node;
        }