本文整理汇总了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;
}
示例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;
}