本文整理汇总了C#中Material.AddSurface方法的典型用法代码示例。如果您正苦于以下问题:C# Material.AddSurface方法的具体用法?C# Material.AddSurface怎么用?C# Material.AddSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Material
的用法示例。
在下文中一共展示了Material.AddSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMaterial
private Material CreateMaterial(ModelMaterial modelmtrl)
{
var shininess = modelmtrl.Params.OfType<ParamF> ().FirstOrDefault(i => i.Name == "_Shininess");
var maintex = modelmtrl.Params.OfType<ParamTex>().FirstOrDefault(i => i.Name == "_MainTex");
var color = modelmtrl.Params.OfType<ParamCol>().FirstOrDefault(i => i.Name == "_Color");
var mtrl = new Material();
var id = modelmtrl.Descriptions[0];
var name = modelmtrl.Descriptions[0];
mtrl.ID = "Material-"+id;
mtrl.Name = "Material-"+name;
mtrl.Shader = ShaderType.Phong;
mtrl.Shininess = null == shininess ? 1 : shininess.Value;
mtrl.Transparency= 1;
if(null != maintex)
{
var surf = new TextureSurface("Surface-"+id+"-Diff", name+"-Diff");
surf.Texture= CreateBitmapTexture(maintex);
surf.TexCoord = 1;
mtrl.AddSurface(SurfaceSlot.Diffuse, surf);
} else
if(null != color)
{
var surf = new ColorSurface("Surface-"+id+"-Diff", name+"-Diff");
surf.Color3 = new SlimDX.Color3(color.R, color.G, color.B);
mtrl.AddSurface(SurfaceSlot.Diffuse, surf);
} else
{
var surf = new ColorSurface("Surface-"+id+"-Diff", name+"-Diff");
surf.Color3 = new SlimDX.Color3(1, 1, 1);
mtrl.AddSurface(SurfaceSlot.Diffuse, surf);
}
mtrl.AddSurface(SurfaceSlot.Ambient, new SlimDX.Color4(1.0f, 0.5f, 0.5f, 0.5f));
mtrl.AddSurface(SurfaceSlot.Specular, new SlimDX.Color4(1.0f, 0.0f, 0.0f, 0.0f));
mtrl.AddSurface(SurfaceSlot.Reflective, new SlimDX.Color4(1.0f, 0.0f, 0.0f, 0.0f));
mtrl.AddSurface(SurfaceSlot.Transparent, new SlimDX.Color4(1.0f, 1.0f, 1.0f, 1.0f));
Materials.Add(mtrl.ID, mtrl);
Root.Instances.Add(mtrl);
return mtrl;
}