//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { TexLoaderArgs texArgs = statement.Arguments as TexLoaderArgs; string[] paths = OpsHelpers.ResolvePathToMany(texArgs.Path as string); foreach (string path in paths) { OpsConsole.WriteLine("Loading texture from file: \"{0}\"", path); OpsTexture result = new OpsTexture(); ImageInformation Info = TextureLoader.ImageInformationFromFile(path); result.SRGB = texArgs.SRGB; if (Info.ResourceType == ResourceType.Textures) { result.Texture = TextureLoader.FromFile(context.Device, path); } else if (Info.ResourceType == ResourceType.VolumeTexture) { result.Texture = TextureLoader.FromVolumeFile(context.Device, path); } else if (Info.ResourceType == ResourceType.CubeTexture) { result.Texture = TextureLoader.FromCubeFile(context.Device, path); } result.Name = System.IO.Path.GetFileNameWithoutExtension(path); context.AddTexture(result); } }
public void Run(OpsContext context, OpsStatement statement) { Slice2dArgs args = statement.Arguments as Slice2dArgs; ArrayList containers = statement.GetContent(context); if (containers.Count != 1) { throw new OpsException("Src argument does not resolve to 1 texture. Textures found: " + containers.Count); } OpsTexture container = containers[0] as OpsTexture; OpsConsole.WriteLine("Slicing from texture:{0} and saving as {1}", container.Name, args.Dst); OpsTexture result = new OpsTexture(); result.Name = args.Dst; result.SRGB = container.SRGB; Texture newTexture = null; if (container.Texture is Texture) { Texture srcTexture = container.Texture as Texture; SurfaceDescription sd = srcTexture.GetLevelDescription(args.Mips); newTexture = new Texture(srcTexture.Device, sd.Width, sd.Height, 1, Usage.None, sd.Format, Pool.Managed); SurfaceLoader.FromSurface(newTexture.GetSurfaceLevel(0), srcTexture.GetSurfaceLevel(0), Filter.Dither | Filter.Triangle | (container.SRGB?Filter.Srgb:0), 0); } else if (container.Texture is VolumeTexture) { VolumeTexture srcTexture = container.Texture as VolumeTexture; VolumeDescription vd = srcTexture.GetLevelDescription(args.Mips); newTexture = new Texture(srcTexture.Device, vd.Width, vd.Height, 1, Usage.None, vd.Format, Pool.Managed); OpsTextureHelper.LoadSurfaceFromVolumeSlice(srcTexture, args.Mips, args.Volume, Filter.Dither | Filter.Triangle | (container.SRGB?Filter.Srgb:0), newTexture.GetSurfaceLevel(0)); } else if (container.Texture is CubeTexture) { CubeTexture srcTexture = container.Texture as CubeTexture; SurfaceDescription sd = srcTexture.GetLevelDescription(args.Mips); newTexture = new Texture(srcTexture.Device, sd.Width, sd.Height, 1, Usage.None, sd.Format, Pool.Managed); SurfaceLoader.FromSurface(newTexture.GetSurfaceLevel(0), srcTexture.GetCubeMapSurface(args.Face, 0), Filter.Dither | Filter.Triangle | (container.SRGB?Filter.Srgb:0), 0); } result.Texture = newTexture; context.AddTexture(result); }
public void Run(OpsContext context, OpsStatement statement) { NewTex3dArgs args = statement.Arguments as NewTex3dArgs; OpsConsole.WriteLine("Creating new volume texture named " + args.Name); OpsTexture result = new OpsTexture(); result.Name = args.Name; VolumeTexture newTexture = new VolumeTexture(context.Device, args.Width, args.Height, args.Depth, args.Mips, Usage.None, args.Format, Pool.Managed); result.Texture = newTexture; CopyToVolume(context, newTexture, args.Src, Filter.Triangle | Filter.Dither); context.AddTexture(result); }
public void Run(OpsContext context, OpsStatement statement) { NewTexCubeArgs args = statement.Arguments as NewTexCubeArgs; OpsConsole.WriteLine("Creating new cube texture named" + args.Name); OpsTexture result = new OpsTexture(); result.Name = args.Name; CubeTexture newTexture = new CubeTexture(context.Device, args.Size, args.Mips, Usage.None, args.Format, Pool.Managed); result.Texture = newTexture; CopyToCubeSide(context, newTexture, args.SrcXP, CubeMapFace.PositiveX, Filter.Triangle | Filter.Dither); CopyToCubeSide(context, newTexture, args.SrcYP, CubeMapFace.PositiveY, Filter.Triangle | Filter.Dither); CopyToCubeSide(context, newTexture, args.SrcZP, CubeMapFace.PositiveZ, Filter.Triangle | Filter.Dither); CopyToCubeSide(context, newTexture, args.SrcXM, CubeMapFace.NegativeX, Filter.Triangle | Filter.Dither); CopyToCubeSide(context, newTexture, args.SrcYM, CubeMapFace.NegativeY, Filter.Triangle | Filter.Dither); CopyToCubeSide(context, newTexture, args.SrcZM, CubeMapFace.NegativeZ, Filter.Triangle | Filter.Dither); context.AddTexture(result); }
public void Run(OpsContext context, OpsStatement statement) { NewTexCubeArgs args = statement.Arguments as NewTexCubeArgs; OpsConsole.WriteLine( "Creating new cube texture named" + args.Name); OpsTexture result = new OpsTexture(); result.Name = args.Name; CubeTexture newTexture = new CubeTexture( context.Device, args.Size , args.Mips , Usage.None , args.Format , Pool.Managed ); result.Texture = newTexture; CopyToCubeSide( context, newTexture, args.SrcXP, CubeMapFace.PositiveX, Filter.Triangle|Filter.Dither); CopyToCubeSide( context, newTexture, args.SrcYP, CubeMapFace.PositiveY, Filter.Triangle|Filter.Dither); CopyToCubeSide( context, newTexture, args.SrcZP, CubeMapFace.PositiveZ, Filter.Triangle|Filter.Dither); CopyToCubeSide( context, newTexture, args.SrcXM, CubeMapFace.NegativeX, Filter.Triangle|Filter.Dither); CopyToCubeSide( context, newTexture, args.SrcYM, CubeMapFace.NegativeY, Filter.Triangle|Filter.Dither); CopyToCubeSide( context, newTexture, args.SrcZM, CubeMapFace.NegativeZ, Filter.Triangle|Filter.Dither); context.AddTexture(result); }
public void Run(OpsContext context, OpsStatement statement) { Slice2dArgs args = statement.Arguments as Slice2dArgs; ArrayList containers = statement.GetContent(context); if(containers.Count !=1 ) throw new OpsException( "Src argument does not resolve to 1 texture. Textures found: " + containers.Count ); OpsTexture container = containers[0] as OpsTexture; OpsConsole.WriteLine( "Slicing from texture:{0} and saving as {1}", container.Name, args.Dst ); OpsTexture result = new OpsTexture(); result.Name = args.Dst; result.SRGB = container.SRGB; Texture newTexture = null; if(container.Texture is Texture) { Texture srcTexture = container.Texture as Texture; SurfaceDescription sd = srcTexture.GetLevelDescription(args.Mips); newTexture = new Texture(srcTexture.Device, sd.Width, sd.Height, 1, Usage.None, sd.Format, Pool.Managed); SurfaceLoader.FromSurface(newTexture.GetSurfaceLevel(0), srcTexture.GetSurfaceLevel(0), Filter.Dither|Filter.Triangle| (container.SRGB?Filter.Srgb:0), 0); } else if(container.Texture is VolumeTexture) { VolumeTexture srcTexture = container.Texture as VolumeTexture; VolumeDescription vd = srcTexture.GetLevelDescription(args.Mips); newTexture = new Texture(srcTexture.Device, vd.Width, vd.Height, 1, Usage.None, vd.Format, Pool.Managed); OpsTextureHelper.LoadSurfaceFromVolumeSlice(srcTexture, args.Mips, args.Volume, Filter.Dither|Filter.Triangle| (container.SRGB?Filter.Srgb:0), newTexture.GetSurfaceLevel(0) ); } else if(container.Texture is CubeTexture) { CubeTexture srcTexture = container.Texture as CubeTexture; SurfaceDescription sd = srcTexture.GetLevelDescription(args.Mips); newTexture = new Texture(srcTexture.Device, sd.Width, sd.Height, 1, Usage.None, sd.Format, Pool.Managed); SurfaceLoader.FromSurface(newTexture.GetSurfaceLevel(0), srcTexture.GetCubeMapSurface(args.Face,0), Filter.Dither|Filter.Triangle| (container.SRGB?Filter.Srgb:0), 0); } result.Texture = newTexture; context.AddTexture(result); }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { TexLoaderArgs texArgs = statement.Arguments as TexLoaderArgs; string[] paths = OpsHelpers.ResolvePathToMany( texArgs.Path as string ); foreach(string path in paths ) { OpsConsole.WriteLine("Loading texture from file: \"{0}\"", path ); OpsTexture result = new OpsTexture(); ImageInformation Info = TextureLoader.ImageInformationFromFile( path ); result.SRGB = texArgs.SRGB; if( Info.ResourceType == ResourceType.Textures ) { result.Texture = TextureLoader.FromFile(context.Device, path); } else if( Info.ResourceType == ResourceType.VolumeTexture ) { result.Texture = TextureLoader.FromVolumeFile(context.Device, path); } else if( Info.ResourceType == ResourceType.CubeTexture ) { result.Texture = TextureLoader.FromCubeFile(context.Device, path); } result.Name = System.IO.Path.GetFileNameWithoutExtension(path ); context.AddTexture(result); } }
public void Run(OpsContext context, OpsStatement statement) { NewTex2dArgs args = statement.Arguments as NewTex2dArgs; OpsConsole.WriteLine( "Creating a new texture named " + args.Name); OpsTexture result = new OpsTexture(); result.Name = args.Name; Texture newTexture = new Texture( context.Device, args.Width , args.Height , args.Mips , Usage.None , args.Format , Pool.Managed ); result.Texture = newTexture; CopyToTexture(context, newTexture, args.Src, Filter.Triangle|Filter.Dither); context.AddTexture(result); }