当前位置: 首页>>代码示例>>C#>>正文


C# Material.SetTextureFile方法代码示例

本文整理汇总了C#中Material.SetTextureFile方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetTextureFile方法的具体用法?C# Material.SetTextureFile怎么用?C# Material.SetTextureFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Material的用法示例。


在下文中一共展示了Material.SetTextureFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseMaterial

        Material ParseMaterial(XmlReader xml)
        {
            Material res = new Material(null);
            int depth = xml.Depth;
            float opacity = 1;

            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 = ParseColor3(xml.ReadString());
                            break;
                        case "Ambient":
                            ambient = ParseColor3(xml.ReadString());
                            break;
                        case "Specular":
                            specular = ParseColor3(xml.ReadString());
                            break;
                        case "Emissive":
                            emissive = ParseColor3(xml.ReadString());
                            break;
                        case "Opacity":
                            opacity = float.Parse(xml.ReadString()) / 100f;
                            break;
                        case "Power":
                            res.Power = float.Parse(xml.ReadString());
                            break;
                        case "DiffuseMap":
                            res.SetTextureFile(0, xml.ReadString());
                            break;
                    }
                }
            }

            res.Diffuse = new Color4F(opacity, diffuse.Red, diffuse.Green, diffuse.Blue);
            res.Ambient = new Color4F(opacity, ambient.Red, ambient.Green, ambient.Blue);
            res.Specular = new Color4F(opacity, specular.Red, specular.Green, specular.Blue);
            res.Emissive = new Color4F(opacity, emissive.Red, emissive.Green, emissive.Blue);

            return res;
        }
开发者ID:yuri410,项目名称:lrvbsvnicg,代码行数:49,代码来源:XMLModelParser.cs

示例2: ParseMaterial

        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;
        }
开发者ID:yuri410,项目名称:lrvbsvnicg,代码行数:72,代码来源:Xml2ModelConverter.cs


注:本文中的Material.SetTextureFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。