Beispiel #1
0
        public void Load()
        {
            Il.ilInit();
            Ilu.iluInit();

            if (tex2dConv == null)
            {
                tex2dConv = new TextureConverter();
            }
            if (idxMapMixer == null) 
            {
                idxMapMixer = new IndexMapMixer();
            }
            if (idxMapMixer4 == null) 
            {
                idxMapMixer4 = new IndexMapMixer4();
            }
            ConverterManager.Instance.Register(tex2dConv);
            ConverterManager.Instance.Register(idxMapMixer);
            ConverterManager.Instance.Register(idxMapMixer4);
        }
Beispiel #2
0
        public void Load()
        {
            Il.ilInit();
            Ilu.iluInit();

            if (tex2dConv == null)
            {
                tex2dConv = new TextureConverter();
            }
            if (idxMapMixer == null)
            {
                idxMapMixer = new IndexMapMixer();
            }
            if (idxMapMixer4 == null)
            {
                idxMapMixer4 = new IndexMapMixer4();
            }
            ConverterManager.Instance.Register(tex2dConv);
            ConverterManager.Instance.Register(idxMapMixer);
            ConverterManager.Instance.Register(idxMapMixer4);
        }
        Material ParseMaterial(XmlReader xml, ResourceLocation dest, string srcPath)
        {
            float opacity = 1;
            Material mat = new Material(null);
            int depth = xml.Depth;

            Color4F diffuse = new Color4F();
            Color4F ambient = new Color4F();
            Color4F specular = new Color4F();
            Color4F emissive = new Color4F();


            while (xml.Read() && xml.Depth > depth)
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    switch (xml.Name)
                    {
                        case "Diffuse":
                            diffuse = ParseColor(xml.ReadString());
                            break;
                        case "Ambient":
                            ambient = ParseColor(xml.ReadString());
                            break;
                        case "Specular":
                            specular = ParseColor(xml.ReadString());
                            break;
                        case "Emissive":
                            emissive = ParseColor(xml.ReadString());
                            break;
                        case "Opacity":
                            opacity = float.Parse(xml.ReadString()) / 100f;
                            break;
                        case "Power":
                            mat.Power = float.Parse(xml.ReadString());
                            break;
                        case "DiffuseMap":
                            string texFile = xml.ReadString();
                            string texFileName = Path.GetFileNameWithoutExtension(texFile) + ".tex";
                            mat.SetTextureFile(0, texFileName);

                            FileLocation fl = dest as FileLocation;
                            if (fl != null)
                            {
                                string dstTex = Path.Combine(Path.GetDirectoryName(fl.Path), texFileName);
                                if (!File.Exists(dstTex) && File.Exists(texFile))
                                {
                                    TextureConverter conv = new TextureConverter();
                                    conv.Convert(fl, new DevFileLocation(dstTex));
                                    //File.Copy(Path.Combine(srcPath, texFile), dstTex, false);
                                }
                            }
                            break;

                    }
                }

            }
            mat.IsTransparent = opacity < 1;
            ambient.Alpha = opacity;
            diffuse.Alpha = opacity;
            emissive.Alpha = opacity;
            specular.Alpha = opacity;

            mat.Ambient = ambient;
            mat.Diffuse = diffuse;
            mat.Emissive = emissive;
            mat.Specular = specular;
            

            return mat;
        }
Beispiel #4
0
        Material ParseMaterial(XmlReader xml, ResourceLocation dest, string srcPath)
        {
            float    opacity = 1;
            Material mat     = new Material(null);
            int      depth   = xml.Depth;

            Color4F diffuse  = new Color4F();
            Color4F ambient  = new Color4F();
            Color4F specular = new Color4F();
            Color4F emissive = new Color4F();


            while (xml.Read() && xml.Depth > depth)
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    switch (xml.Name)
                    {
                    case "Diffuse":
                        diffuse = ParseColor(xml.ReadString());
                        break;

                    case "Ambient":
                        ambient = ParseColor(xml.ReadString());
                        break;

                    case "Specular":
                        specular = ParseColor(xml.ReadString());
                        break;

                    case "Emissive":
                        emissive = ParseColor(xml.ReadString());
                        break;

                    case "Opacity":
                        opacity = float.Parse(xml.ReadString()) / 100f;
                        break;

                    case "Power":
                        mat.Power = float.Parse(xml.ReadString());
                        break;

                    case "DiffuseMap":
                        string texFile     = xml.ReadString();
                        string texFileName = Path.GetFileNameWithoutExtension(texFile) + ".tex";
                        mat.SetTextureFile(0, texFileName);

                        FileLocation fl = dest as FileLocation;
                        if (fl != null)
                        {
                            string dstTex = Path.Combine(Path.GetDirectoryName(fl.Path), texFileName);
                            if (!File.Exists(dstTex) && File.Exists(texFile))
                            {
                                TextureConverter conv = new TextureConverter();
                                conv.Convert(fl, new DevFileLocation(dstTex));
                                //File.Copy(Path.Combine(srcPath, texFile), dstTex, false);
                            }
                        }
                        break;
                    }
                }
            }
            mat.IsTransparent = opacity < 1;
            ambient.Alpha     = opacity;
            diffuse.Alpha     = opacity;
            emissive.Alpha    = opacity;
            specular.Alpha    = opacity;

            mat.Ambient  = ambient;
            mat.Diffuse  = diffuse;
            mat.Emissive = emissive;
            mat.Specular = specular;


            return(mat);
        }