private void CreateSurface(object sender, CreateSurfaceEventArgs args) { var surface = new TextureSurface(GraphicsDevice); surface.OnDraw += InvalidateRectangle; args.Surface = surface; }
/// <summary> /// Assigns a texture to the specified material parameter. Allows you to specify a surface parameter that allows you /// to bind only a sub-set of the texture. /// </summary> /// <param name="name">Name of the texture parameter.</param> /// <param name="texture">Texture resource to assign.</param> /// <param name="surface">Subset of the texture to assign.</param> public void SetTexture(string name, RRef <Texture> texture, TextureSurface surface) { Internal_setTexture(mCachedPtr, name, texture, surface.mipLevel, surface.numMipLevels, surface.face, surface.numFaces); }
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; }
public void Clear(Vector4d value, TextureSurface target, int level = 0) { Clear(value, target.Levels[level]); }