//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { StripifyArguments arguments = statement.Arguments as StripifyArguments; OpsConsole.WriteLine( "Stripifying models" ); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { int[] adjIn= null; int[] adjOut= null; int[] faceRemap= null; GraphicsStream vertexRemapStream= null; adjIn= meshContainer.GetAdjacency(); Mesh oldMesh = meshContainer.MeshData.Mesh; Mesh newMesh = oldMesh.Optimize(arguments.meshFlags, adjIn, out adjOut, out faceRemap, out vertexRemapStream); meshContainer.ReplaceMesh(newMesh); meshContainer.SetAdjacency(adjOut); meshContainer.RemapSkin(vertexRemapStream); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { AdjacencyArguments arguments = statement.Arguments as AdjacencyArguments; OpsConsole.WriteLine("Generating Adjacencies"); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { int[] adj = null; if (arguments.Topological) { adj = meshContainer.MeshData.Mesh.ConvertPointRepsToAdjacency((int[])null); } else { adj = new int[meshContainer.MeshData.Mesh.NumberFaces * 3]; meshContainer.MeshData.Mesh.GenerateAdjacency( arguments.Epsilon, adj); } meshContainer.SetAdjacency(adj); } } }
//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 static void CopyToCubeSide(OpsContext context, CubeTexture newTexture, string srcArg, CubeMapFace face, Filter filter) { if (srcArg == null || srcArg.Length == 0) { return; } OpsTexture src = context.GetTexture(srcArg); if (src == null) { throw new OpsException("Could not find source texture: " + srcArg); } if (src.Texture is CubeTexture) { SurfaceLoader.FromSurface(newTexture.GetCubeMapSurface(face, 0), ((CubeTexture)src.Texture).GetCubeMapSurface(face, 0), filter | (src.SRGB?Filter.SrgbIn:0), 0); } else if (src.Texture is Texture) { SurfaceLoader.FromSurface(newTexture.GetCubeMapSurface(face, 0), ((Texture)src.Texture).GetSurfaceLevel(0), filter | (src.SRGB?Filter.SrgbIn:0), 0); } else { throw new OpsException("Source texture is not a texture2D: " + srcArg); } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { AdjacencyArguments arguments = statement.Arguments as AdjacencyArguments; OpsConsole.WriteLine( "Generating Adjacencies"); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { int[] adj = null; if(arguments.Topological) { adj = meshContainer.MeshData.Mesh.ConvertPointRepsToAdjacency((int[])null); } else { adj= new int[meshContainer.MeshData.Mesh.NumberFaces*3]; meshContainer.MeshData.Mesh.GenerateAdjacency( arguments.Epsilon, adj); } meshContainer.SetAdjacency(adj); } } }
private string SelectCardFromList() { string retVal = ""; try { if (mCardDefList.Count == 0) { return(retVal); } List <OpsSelectionEntry> entryList = new List <OpsSelectionEntry>(); entryList.Add(new OpsSelectionEntry(0, "-- Detectar Tarjeta --", 0)); for (int index = 0; index < mCardDefList.Count; index++) { entryList.Add(new OpsSelectionEntry(index + 1, mCardDefList[index].IssuerName, index)); } int selectedOption = OpsContext.SelectionRequest("Tarjetas", "Seleccione Tarjeta", entryList) ?? -1; if (selectedOption > 0) { retVal = mCardDefList[selectedOption - 1].IssuerCode.TrimStart('0'); } } catch (Exception ex) { } return(retVal); }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { UnloadArguments args = statement.Arguments as UnloadArguments; if (args.Type == ContentType.GENERIC || args.Type == ContentType.MODELS) { ArrayList models = context.FindModels(args.Src); foreach (OpsModel model in models) { OpsConsole.WriteLine("Unloading model: '{0}'", model.Name); context.RemoveModel(model.Name); } } if (args.Type == ContentType.GENERIC || args.Type == ContentType.TEXTURES) { ArrayList textures = context.FindTextures(args.Src); foreach (OpsTexture texture in textures) { OpsConsole.WriteLine("Unloading texture: '{0}'", texture.Name); context.RemoveTexture(texture.Name); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { AddVDataArguments arguments = statement.Arguments as AddVDataArguments; OpsConsole.WriteLine( String.Format("Adding vertex element {0} of type {1}", arguments.FriendlyName, arguments.type) ); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { VertexElement[] OldVEs= meshContainer.MeshData.Mesh.Declaration.Clone() as VertexElement[]; int iExists; if( false == MeshDeclarationHelper.FindElement(OldVEs, arguments.usage, arguments.usageIdx, out iExists) ) { int addedIdx; VertexElement[] VEs= MeshDeclarationHelper.AddElement(OldVEs, arguments.type, arguments.usage, arguments.usageIdx, out addedIdx ); Mesh newMesh = meshContainer.MeshData.Mesh.Clone( meshContainer.MeshData.Mesh.Options.Value, VEs, meshContainer.MeshData.Mesh.Device); meshContainer.ReplaceMesh( newMesh ); } else { OpsConsole.WriteLine( String.Format("Found existing vertex element {0}{1} on {2}", arguments.usage, arguments.usageIdx, meshContainer.FriendlyName(model) )); } } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { AddVDataArguments arguments = statement.Arguments as AddVDataArguments; OpsConsole.WriteLine(String.Format("Adding vertex element {0} of type {1}", arguments.FriendlyName, arguments.type)); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { VertexElement[] OldVEs = meshContainer.MeshData.Mesh.Declaration.Clone() as VertexElement[]; int iExists; if (false == MeshDeclarationHelper.FindElement(OldVEs, arguments.usage, arguments.usageIdx, out iExists)) { int addedIdx; VertexElement[] VEs = MeshDeclarationHelper.AddElement(OldVEs, arguments.type, arguments.usage, arguments.usageIdx, out addedIdx); Mesh newMesh = meshContainer.MeshData.Mesh.Clone(meshContainer.MeshData.Mesh.Options.Value, VEs, meshContainer.MeshData.Mesh.Device); meshContainer.ReplaceMesh(newMesh); } else { OpsConsole.WriteLine(String.Format("Found existing vertex element {0}{1} on {2}", arguments.usage, arguments.usageIdx, meshContainer.FriendlyName(model))); } } } }
public void Run(OpsContext context, OpsStatement statement) { TexFormatArgs args = statement.Arguments as TexFormatArgs; ArrayList containers = statement.GetContent(context); OpsConsole.WriteLine("Changing texture formats to " + args.Format); foreach (OpsTexture container in containers) { if (container.Texture is Texture) { Texture oldTexture = container.Texture as Texture; SurfaceDescription sd = oldTexture.GetLevelDescription(0); container.Texture = OpsTextureHelper.CloneTexture(oldTexture, sd.Width, sd.Height, oldTexture.LevelCount, args.Format, Usage.None, Filter.Triangle | Filter.Dither | (container.SRGB?Filter.Srgb:0), Pool.Managed); } else if (container.Texture is VolumeTexture) { VolumeTexture oldTexture = container.Texture as VolumeTexture; VolumeDescription vd = oldTexture.GetLevelDescription(0); container.Texture = OpsTextureHelper.CloneVolume(oldTexture, vd.Width, vd.Height, vd.Depth, oldTexture.LevelCount, args.Format, Usage.None, Filter.Triangle | Filter.Dither | (container.SRGB?Filter.Srgb:0), Pool.Managed); } else if (container.Texture is CubeTexture) { CubeTexture oldTexture = container.Texture as CubeTexture; SurfaceDescription sd = oldTexture.GetLevelDescription(0); container.Texture = OpsTextureHelper.CloneCube(oldTexture, sd.Width, oldTexture.LevelCount, args.Format, Usage.None, Filter.Triangle | Filter.Dither | (container.SRGB?Filter.Srgb:0), Pool.Managed); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OptimizeArguments arguments = statement.Arguments as OptimizeArguments; OpsConsole.WriteLine("Optimizing models"); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { int[] adjIn = null; int[] adjOut = null; int[] faceRemap = null; GraphicsStream vertexRemapStream = null; if (arguments.weldType != WeldType.None) { adjIn = meshContainer.GetAdjacency(); meshContainer.MeshData.Mesh.WeldVertices(arguments.epsilonFlags, arguments.epsilons, adjIn, out adjOut, out faceRemap, out vertexRemapStream); meshContainer.SetAdjacency(adjOut); meshContainer.RemapSkin(vertexRemapStream); } adjIn = meshContainer.GetAdjacency(); Mesh newMesh = meshContainer.MeshData.Mesh.Optimize(arguments.meshFlags, adjIn, out adjOut, out faceRemap, out vertexRemapStream); meshContainer.ReplaceMesh(newMesh); meshContainer.SetAdjacency(adjOut); meshContainer.RemapSkin(vertexRemapStream); } } }
public static void CopyToVolume(OpsContext context, VolumeTexture newTexture, string srcArg, Filter filter) { if (srcArg == null || srcArg.Length == 0) { return; } ArrayList srcList = context.FindTextures(srcArg); if (srcList == null || srcList.Count == 0) { throw new OpsException("Could not find source texture: " + srcArg); } if (((OpsTexture)srcList[0]).Texture is VolumeTexture) { VolumeLoader.FromVolume(newTexture.GetVolumeLevel(0), ((VolumeTexture)((OpsTexture)srcList[0]).Texture).GetVolumeLevel(0), filter, 0); } else { for (int i = 0; i < srcList.Count; i++) { OpsTexture src = srcList[i] as OpsTexture; if (!(src.Texture is Texture)) { throw new OpsException("Source texture pattern is not 1 volume texture or all 2D textures: " + srcArg); } OpsTextureHelper.LoadVolumeSliceFromSurface(newTexture, 0, i, filter, ((Texture)src.Texture).GetSurfaceLevel(0)); } } newTexture.GenerateMipSubLevels(); }
public void Run(OpsContext context, OpsStatement statement) { TexFormatArgs args = statement.Arguments as TexFormatArgs; ArrayList containers = statement.GetContent(context); OpsConsole.WriteLine( "Changing texture formats to " + args.Format ); foreach(OpsTexture container in containers) { if(container.Texture is Texture) { Texture oldTexture = container.Texture as Texture; SurfaceDescription sd = oldTexture.GetLevelDescription(0); container.Texture = OpsTextureHelper.CloneTexture(oldTexture, sd.Width, sd.Height, oldTexture.LevelCount, args.Format, Usage.None, Filter.Triangle|Filter.Dither| (container.SRGB?Filter.Srgb:0), Pool.Managed); } else if(container.Texture is VolumeTexture) { VolumeTexture oldTexture = container.Texture as VolumeTexture; VolumeDescription vd = oldTexture.GetLevelDescription(0); container.Texture = OpsTextureHelper.CloneVolume(oldTexture, vd.Width, vd.Height, vd.Depth, oldTexture.LevelCount, args.Format, Usage.None, Filter.Triangle|Filter.Dither| (container.SRGB?Filter.Srgb:0), Pool.Managed ); } else if(container.Texture is CubeTexture) { CubeTexture oldTexture = container.Texture as CubeTexture; SurfaceDescription sd = oldTexture.GetLevelDescription(0); container.Texture = OpsTextureHelper.CloneCube(oldTexture, sd.Width, oldTexture.LevelCount, args.Format, Usage.None, Filter.Triangle|Filter.Dither| (container.SRGB?Filter.Srgb:0), Pool.Managed ); } } }
public UnitOfWork(OpsContext context, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager) { _context = context ?? throw new ArgumentNullException(nameof(context)); _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager)); _roleManager = roleManager ?? throw new ArgumentNullException(nameof(roleManager)); }
public PrismaInterfaceExtApp(IExecutionContext context) : base(context) { try { this.OpsInitEvent += OnOpsInitEvent; this.OpsTmedPreviewEvent += OnOpsTmedPreviewEvent; this.OpsTransactionCancelEvent += OnOpsTransactionCancelEvent; this.OpsErrorMessageEvent += OnOpsErrorMessageEvent; string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\"; ConfigMgr.Instance.Initialize(path + "\\bp.payment.config"); if (ConfigMgr.Instance.ShowIFCVersion) { OpsContext.ShowMessage("PRISMA PAYMENT Version: " + this.GetType().Assembly.GetName().Version.ToString()); } LOG.Info("{Message}", "PRISMA PAYMENT Version: " + this.GetType().Assembly.GetName().Version.ToString()); mCardPlanMap = GetCCPlanDef(); IntegratedPOS.SetPortParameters( new COM_PARAMS() { COMName = "COM" + ConfigMgr.Instance.LAPOSSerialPortNumber, BaudRate = UInt16.Parse(ConfigMgr.Instance.LAPOSSerialPortBaudRate), Parity = (byte)(ConfigMgr.Instance.LAPOSSerialPortParity.Length == 1 ? ConfigMgr.Instance.LAPOSSerialPortParity[0] : 'N'), ByteSize = UInt16.Parse(ConfigMgr.Instance.LAPOSSerialPortByteSize), StopBits = UInt16.Parse(ConfigMgr.Instance.LAPOSSerialPortStopBits), }); string errMsg = ""; if (IntegratedPOS.GetIssuer(out mCardDefList, ref errMsg) != VPI_ERROR_CODE.VPI_OK) { LOG.Error("{Message}", $"Error reading card list from POS\r\n{errMsg}"); } //LOG.Instance.LogEvent("MP QR PAYMENT Version: " + this.GetType().Assembly.GetName().Version.ToString(), TWS.Log.Logger.VERBOSITY_LEVEL.INFO); /* FOR FUTURE USE * //licensing * LicenseMgr.Instance.Initialize(path, path, "TWS.Simphony.MP.Payment.dll", false); * * mHardID = HardwareIdReader.GetHash(OpsContext.Product + "_" + * OpsContext.LocationId + "_" + * OpsContext.PropertyID + "_" + * OpsContext.WorkstationID); * * mLicensed = LicenseMgr.Instance.ValidateLicense("TWS.Simphony.MP.Payment.dll", mHardID, true);*/ } catch (Exception ex) { OpsContext.ShowException(ex, "Exception creating MPQRInterfaceExtApp"); throw ex; } }
public void Run(OpsContext context, OpsStatement statement) { TexResizeArgs args = statement.Arguments as TexResizeArgs; ArrayList containers = statement.GetContent(context); OpsConsole.WriteLine( "Resizing textures to width:{0} height:{1} depth:{2}", args.Width, args.Height, args.Depth ); foreach(OpsTexture container in containers) { if (container.Texture is Texture) { Texture oldTexture = container.Texture as Texture; SurfaceDescription sd = oldTexture.GetLevelDescription(0); if (args.Width == -1) args.Width = sd.Width; if (args.Height == -1) args.Height = sd.Height; int mips = OpsTextureHelper.NumMips(args.Width, args.Height, 1); container.Texture = OpsTextureHelper.CloneTexture(oldTexture, args.Width, args.Height, mips, sd.Format, Usage.None, args.Filter | (container.SRGB ? Filter.Srgb : 0), Pool.Managed); } else if (container.Texture is VolumeTexture) { VolumeTexture oldTexture = container.Texture as VolumeTexture; VolumeDescription vd = oldTexture.GetLevelDescription(0); if (args.Width == -1) args.Width = vd.Width; if (args.Height == -1) args.Height = vd.Height; if (args.Depth == -1) args.Depth = vd.Depth; int mips = OpsTextureHelper.NumMips(args.Width, args.Height, args.Depth); container.Texture = OpsTextureHelper.CloneVolume(oldTexture, args.Width, args.Height, args.Depth, mips, vd.Format, Usage.None, args.Filter | (container.SRGB ? Filter.Srgb : 0), Pool.Managed); } else if (container.Texture is CubeTexture) { CubeTexture oldTexture = container.Texture as CubeTexture; SurfaceDescription sd = oldTexture.GetLevelDescription(0); if (args.Width == -1) args.Width = sd.Width; int mips = OpsTextureHelper.NumMips(args.Width, args.Width, 1); container.Texture = OpsTextureHelper.CloneCube(oldTexture, args.Width, mips, sd.Format, Usage.None, args.Filter | (container.SRGB ? Filter.Srgb : 0), Pool.Managed); } } }
public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine( "Texture information" ); OpsConsole.WriteLine(format, "Names", "Type", "Width", "Height", "Depth", "Mips", "Format" ); foreach( OpsTexture container in statement.GetContent(context) ) { string name = container.Name; string type = container.Texture.GetType().Name; int width = 0; int height = 0; int depth = 0; int mips = 0; string pixelFormat = ""; if(container.Texture is Texture) { Texture texture = container.Texture as Texture; SurfaceDescription sd = texture.GetLevelDescription(0); width = sd.Width; height = sd.Height; mips = texture.LevelCount; pixelFormat = sd.Format.ToString(); } else if(container.Texture is VolumeTexture) { VolumeTexture texture = container.Texture as VolumeTexture; VolumeDescription vd = texture.GetLevelDescription(0); width = vd.Width; height = vd.Height; depth = vd.Depth; mips = texture.LevelCount; pixelFormat = vd.Format.ToString(); } else if(container.Texture is CubeTexture) { CubeTexture texture = container.Texture as CubeTexture; SurfaceDescription sd = texture.GetLevelDescription(0); width = sd.Width; height = sd.Height; mips = texture.LevelCount; pixelFormat = sd.Format.ToString(); } OpsConsole.WriteLine( format, name, type, width, height, depth, mips, pixelFormat); } }
public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine("Texture information"); OpsConsole.WriteLine(format, "Names", "Type", "Width", "Height", "Depth", "Mips", "Format"); foreach (OpsTexture container in statement.GetContent(context)) { string name = container.Name; string type = container.Texture.GetType().Name; int width = 0; int height = 0; int depth = 0; int mips = 0; string pixelFormat = ""; if (container.Texture is Texture) { Texture texture = container.Texture as Texture; SurfaceDescription sd = texture.GetLevelDescription(0); width = sd.Width; height = sd.Height; mips = texture.LevelCount; pixelFormat = sd.Format.ToString(); } else if (container.Texture is VolumeTexture) { VolumeTexture texture = container.Texture as VolumeTexture; VolumeDescription vd = texture.GetLevelDescription(0); width = vd.Width; height = vd.Height; depth = vd.Depth; mips = texture.LevelCount; pixelFormat = vd.Format.ToString(); } else if (container.Texture is CubeTexture) { CubeTexture texture = container.Texture as CubeTexture; SurfaceDescription sd = texture.GetLevelDescription(0); width = sd.Width; height = sd.Height; mips = texture.LevelCount; pixelFormat = sd.Format.ToString(); } OpsConsole.WriteLine(format, name, type, width, height, depth, mips, pixelFormat); } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsUVAtlasArguments options = statement.Arguments as OpsUVAtlasArguments; OpsConsole.WriteLine("UVAtlasing models. This might take a while."); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { OpsConsole.WriteLine( "\t\tBeginning " + meshContainer.FriendlyName(model)); VertexElement[] VEs= meshContainer.MeshData.Mesh.Declaration; int destinationIdx; if( false == MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.TextureCoordinate, options.TexIdx, out destinationIdx) ) { throw new OpsException("Cannot generate UVAtlas without texture coordinates (use command AddVData)"); } UVAtlasOutput uvout; try { uvout = UVAtlas.Create( meshContainer.MeshData.Mesh, options.MaxCharts, options.Stretch, options.Width, options.Height, options.Gutter, options.TexIdx, meshContainer.GetAdjacencyStream(), null, null, 0.0f); } catch(Microsoft.DirectX.Direct3D.InvalidMeshException e) { throw new OpsException("UVAtlas considers this mesh invalid. This is most likely because the mesh is non-manifold. Using the clean and optimize commands first to remove some non-manifold properties MAY fix the problem. Also consider less restrictive argument values.", e); } catch(Exception e) { throw new OpsException("UVAtlas was unable to complete. Try using more flexible argument values, cleaning, and/or optimizing models first.", e); } meshContainer.ReplaceMesh( uvout.Mesh ); meshContainer.RemapSkin( uvout.VertexRemapArray ); OpsConsole.WriteLine( "\ttCompleted"); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine( "Generating normals"); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { meshContainer.MeshData.Mesh.ComputeNormals(meshContainer.GetAdjacencyStream()); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine("Generating normals"); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { meshContainer.MeshData.Mesh.ComputeNormals(meshContainer.GetAdjacencyStream()); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsUVAtlasArguments options = statement.Arguments as OpsUVAtlasArguments; OpsConsole.WriteLine("UVAtlasing models. This might take a while."); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { OpsConsole.WriteLine("\t\tBeginning " + meshContainer.FriendlyName(model)); VertexElement[] VEs = meshContainer.MeshData.Mesh.Declaration; int destinationIdx; if (false == MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.TextureCoordinate, options.TexIdx, out destinationIdx)) { throw new OpsException("Cannot generate UVAtlas without texture coordinates (use command AddVData)"); } UVAtlasOutput uvout; try { uvout = UVAtlas.Create( meshContainer.MeshData.Mesh, options.MaxCharts, options.Stretch, options.Width, options.Height, options.Gutter, options.TexIdx, meshContainer.GetAdjacencyStream(), null, null, 0.0f); } catch (Microsoft.DirectX.Direct3D.InvalidMeshException e) { throw new OpsException("UVAtlas considers this mesh invalid. This is most likely because the mesh is non-manifold. Using the clean and optimize commands first to remove some non-manifold properties MAY fix the problem. Also consider less restrictive argument values.", e); } catch (Exception e) { throw new OpsException("UVAtlas was unable to complete. Try using more flexible argument values, cleaning, and/or optimizing models first.", e); } meshContainer.ReplaceMesh(uvout.Mesh); meshContainer.RemapSkin(uvout.VertexRemapArray); OpsConsole.WriteLine("\ttCompleted"); } } }
public void Run(OpsContext context, OpsStatement statement) { MipArgs args = statement.Arguments as MipArgs; ArrayList containers = statement.GetContent(context); OpsConsole.WriteLine( "Generating Mipmaps"); foreach(OpsTexture container in containers) { TextureLoader.FilterTexture( container.Texture, args.Start, args.Filter | (container.SRGB?Filter.Srgb:0)); } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { string[] paths = OpsHelpers.ResolvePathToMany( statement.Arguments as string ); foreach(string path in paths ) { OpsConsole.WriteLine("Loading model from file: \"{0}\"", path ); OpsModel model = OpsModel.FromFile(context.Device, path); context.AddModel(model); } }
public static void SendOpsCommand(OpsContext opsContext_, OpsCommand cmd_, Func <bool> waitCondition_) { mOpsContext = opsContext_; new Thread(() => SendOpsCommandThread(new object[] { cmd_ }, waitCondition_)) { Name = "SEND OPS COMMAND THREAD" }.Start(); /* * we use lambda notation because in .NETCF there is no ParametrizedThreadStart support. * This way we can pass any arguments in a similar way */ }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { string[] paths = OpsHelpers.ResolvePathToMany(statement.Arguments as string); foreach (string path in paths) { OpsConsole.WriteLine("Loading model from file: \"{0}\"", path); OpsModel model = OpsModel.FromFile(context.Device, path); context.AddModel(model); } }
public void Run(OpsContext context, OpsStatement statement) { MipArgs args = statement.Arguments as MipArgs; ArrayList containers = statement.GetContent(context); OpsConsole.WriteLine("Generating Mipmaps"); foreach (OpsTexture container in containers) { TextureLoader.FilterTexture(container.Texture, args.Start, args.Filter | (container.SRGB?Filter.Srgb:0)); } }
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 CreditCardPrintTicketEvent() { VPI_ERROR_CODE retCode; string errMsg = ""; if ((retCode = IntegratedPOS.PrintTicket(ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar Imprimir el Ticket\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Print Ticket operation failed:\r\n{errMsg}"); } else { OpsContext.ShowMessage("Operación exitosa.\r\n"); } }
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); }
public void CreditCardGetBatchCloseData() { VPI_ERROR_CODE retCode; string errMsg = ""; List <BATCHCLOSEDATA_OUT> batchList; if ((retCode = IntegratedPOS.GetBatchCloseData(out batchList, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar obtener los totales de Cierre de Lote\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Get Batch Close Data operation failed:\r\n{errMsg}"); return; } OpsContext.ShowTextList("Cierre de Lote", batchList.Select(batch => batch.DumpString())); }
public void CreditCardBatchCloseEvent() { VPI_ERROR_CODE retCode; BATCHCLOSE_OUT batchOut; string errMsg = ""; if ((retCode = IntegratedPOS.BatchClose(out batchOut, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar Cerrar el Lote.\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Batch Close operation failed:\r\n{batchOut.DumpString()}"); return; } OpsContext.ShowMessage(batchOut.DumpString()); }
public void Run(OpsContext context, OpsStatement statement) { Splice2dArgs args = statement.Arguments as Splice2dArgs; ArrayList srcList = statement.GetContent(context); if (srcList.Count != 1) { throw new OpsException("Could not find the source texture. 1 is require but found " + srcList.Count); } OpsTexture srcContainer = ((OpsTexture)srcList[0]); if (!(srcContainer.Texture is Texture)) { throw new OpsException("Source texture is not 2D"); } Texture srcTexture = srcContainer.Texture as Texture; OpsConsole.WriteLine("Splicing texture:{0} into one or more textures", srcContainer.Name); ArrayList dstContainers = context.FindTextures(args.Dst); foreach (OpsTexture dstContainer in dstContainers) { if (dstContainer.Texture is Texture) { Texture dstTexture = dstContainer.Texture as Texture; SurfaceLoader.FromSurface(dstTexture.GetSurfaceLevel(args.Mips), srcTexture.GetSurfaceLevel(0), Filter.Dither | Filter.Triangle | (srcContainer.SRGB?Filter.SrgbIn:0) | (dstContainer.SRGB?Filter.SrgbOut:0), 0); } else if (dstContainer.Texture is VolumeTexture) { VolumeTexture dstTexture = dstContainer.Texture as VolumeTexture; OpsTextureHelper.LoadVolumeSliceFromSurface(dstTexture, args.Mips, args.Volume, Filter.Dither | Filter.Triangle | (srcContainer.SRGB?Filter.SrgbIn:0) | (dstContainer.SRGB?Filter.SrgbOut:0), srcTexture.GetSurfaceLevel(0)); } else if (dstContainer.Texture is CubeTexture) { CubeTexture dstTexture = dstContainer.Texture as CubeTexture; SurfaceLoader.FromSurface(dstTexture.GetCubeMapSurface(args.Face, args.Mips), srcTexture.GetSurfaceLevel(0), Filter.Dither | Filter.Triangle | (srcContainer.SRGB?Filter.SrgbIn:0) | (dstContainer.SRGB?Filter.SrgbOut:0), 0); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { FlattenArguments arguments = statement.Arguments as FlattenArguments; ArrayList models = statement.GetContent(context); OpsConsole.WriteLine("Flattening models into '{0}'", arguments.NewModel); Mesh[] meshes; Matrix[] localToWorlds; int[][] adjacencies; ExtendedMaterial[] materials; EffectInstance[] effectInstances; GetLists(models, out meshes, out localToWorlds, out adjacencies, out materials, out effectInstances); Mesh newMesh = PrtEngine.ConcatenateMeshes( meshes, MeshFlags.SystemMemory | MeshFlags.Use32Bit, localToWorlds, null, null, context.Device); int[] newAdj = ConcatenateAdjacency(newMesh, meshes, adjacencies); OpsMeshContainer newMC = new OpsMeshContainer(); newMC.Name = arguments.NewModel; newMC.ReplaceMesh(newMesh); newMC.SetMaterials(materials); newMC.SetEffectInstances(effectInstances); newMC.SetAdjacency(newAdj); OpsFrame newFrame = new OpsFrame(); newFrame.Name = arguments.NewModel; newFrame.MeshContainer = newMC; OpsModel newModel = new OpsModel(); newModel.Name = arguments.NewModel; newModel.HierarchyRoot = newFrame; context.AddModel(newModel); }
private List <PLAN_OUT> DoCCGetPlan() { List <PLAN_OUT> retVal = new List <PLAN_OUT>(); VPI_ERROR_CODE retCode; string errMsg = ""; if ((retCode = IntegratedPOS.GetPlan(out retVal, ref errMsg)) != VPI_ERROR_CODE.VPI_OK) { OpsContext.ShowError($"Error al intentar obtener el Listado de Tarjetas\r\n{errMsg}"); LOG.Error("{Message}", $"LAPOS Get Issuer operation failed:\r\n{errMsg}"); return(retVal); } OpsContext.ShowTextList("Listado de Planes", retVal.Select(plan => plan.DumpString())); return(retVal); }
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) { 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) { DelVDataArguments arguments = statement.Arguments as DelVDataArguments; OpsConsole.WriteLine(String.Format("Deleting vertex element {0}", arguments.FriendlyName)); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { VertexElement[] OldVEs = meshContainer.MeshData.Mesh.Declaration.Clone() as VertexElement[]; int srcUsageIdx = arguments.usageIdx; if (arguments.hasSrcUsageIdx == false) { for (int i = 0; i < OldVEs.Length; i++) { if (OldVEs[i].DeclarationUsage == arguments.usage) { srcUsageIdx = OldVEs[i].UsageIndex; break; } } } if (srcUsageIdx < 0) { continue; } int iRemove; if (MeshDeclarationHelper.FindElement(OldVEs, arguments.usage, srcUsageIdx, out iRemove)) { VertexElement[] VEs = MeshDeclarationHelper.RemoveElement(OldVEs, iRemove); Mesh newMesh = meshContainer.MeshData.Mesh.Clone(meshContainer.MeshData.Mesh.Options.Value, VEs, meshContainer.MeshData.Mesh.Device); meshContainer.ReplaceMesh(newMesh); } else { OpsConsole.WriteLine(String.Format("Could not find vertex element {0}{1} on {2}", arguments.usage, arguments.usageIdx, meshContainer.FriendlyName(model))); } } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { TexSaverArgs texArgs = statement.Arguments as TexSaverArgs; ArrayList containers = statement.GetContent(context); if (containers.Count != 1) { throw new OpsException("'src' argument resolves to " + containers.Count + " textures where it must be 1 texture"); } OpsTexture container = containers[0] as OpsTexture; OpsConsole.WriteLine("Saving texture: {0} to path: {1}", container.Name, texArgs.Path); TextureLoader.Save(texArgs.Path, texArgs.Format, container.Texture); }
public void SaveCustomerData() { if (EncryptionKey == null || EncryptionKey.Length <= 0) { string Error = "The Covid Customer Data Encryption Key is not configured."; OpsContext.ShowError(Error); base.Logger.LogAlways(Error); return; } string FullName = GetCustomerName(); string PhoneNumber; if (!string.IsNullOrEmpty(FullName)) { PhoneNumber = GetCustomerPhoneNumber(); if (!string.IsNullOrEmpty(PhoneNumber)) { try { var Success = SaveDataToFile($"{FullName},{PhoneNumber},{DateTime.Now.ToString("yyyyMMddHHmmss")}"); if (!Success) { OpsContext.ShowError("Failure saving customer records. Please check EGateway log file for further information. "); } else { OpsContext.ShowMessage("Successfully saved customer records"); // Potentially print chit. } } catch (Exception ex) { string Error = $"CovidCustomerData: Failed to save the customer data. {System.Environment.NewLine}Reason: {ex.Message}"; base.Logger.LogAlways(Error); OpsContext.ShowError(Error); } } } PurgeOldCustomerRecords(); }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { FlattenArguments arguments = statement.Arguments as FlattenArguments; ArrayList models = statement.GetContent(context); OpsConsole.WriteLine( "Flattening models into '{0}'", arguments.NewModel); Mesh[] meshes; Matrix[] localToWorlds; int[][] adjacencies; ExtendedMaterial[] materials; EffectInstance[] effectInstances; GetLists( models, out meshes, out localToWorlds, out adjacencies, out materials, out effectInstances); Mesh newMesh = PrtEngine.ConcatenateMeshes( meshes, MeshFlags.SystemMemory|MeshFlags.Use32Bit, localToWorlds, null, null, context.Device); int[] newAdj = ConcatenateAdjacency( newMesh, meshes, adjacencies); OpsMeshContainer newMC = new OpsMeshContainer(); newMC.Name = arguments.NewModel; newMC.ReplaceMesh( newMesh ); newMC.SetMaterials( materials ); newMC.SetEffectInstances( effectInstances ); newMC.SetAdjacency( newAdj ); OpsFrame newFrame = new OpsFrame(); newFrame.Name = arguments.NewModel; newFrame.MeshContainer = newMC; OpsModel newModel = new OpsModel(); newModel.Name = arguments.NewModel; newModel.HierarchyRoot = newFrame; context.AddModel(newModel); }
public void Run(OpsContext context, OpsStatement statement) { Splice2dArgs args = statement.Arguments as Splice2dArgs; ArrayList srcList = statement.GetContent(context); if(srcList.Count != 1) throw new OpsException("Could not find the source texture. 1 is require but found " + srcList.Count); OpsTexture srcContainer = ((OpsTexture)srcList[0]); if(!(srcContainer.Texture is Texture)) throw new OpsException("Source texture is not 2D"); Texture srcTexture = srcContainer.Texture as Texture; OpsConsole.WriteLine( "Splicing texture:{0} into one or more textures", srcContainer.Name ); ArrayList dstContainers = context.FindTextures(args.Dst); foreach( OpsTexture dstContainer in dstContainers) { if(dstContainer.Texture is Texture) { Texture dstTexture = dstContainer.Texture as Texture; SurfaceLoader.FromSurface(dstTexture.GetSurfaceLevel(args.Mips), srcTexture.GetSurfaceLevel(0), Filter.Dither|Filter.Triangle| (srcContainer.SRGB?Filter.SrgbIn:0)| (dstContainer.SRGB?Filter.SrgbOut:0), 0); } else if(dstContainer.Texture is VolumeTexture) { VolumeTexture dstTexture = dstContainer.Texture as VolumeTexture; OpsTextureHelper.LoadVolumeSliceFromSurface(dstTexture, args.Mips, args.Volume, Filter.Dither|Filter.Triangle| (srcContainer.SRGB?Filter.SrgbIn:0)| (dstContainer.SRGB?Filter.SrgbOut:0), srcTexture.GetSurfaceLevel(0) ); } else if(dstContainer.Texture is CubeTexture) { CubeTexture dstTexture = dstContainer.Texture as CubeTexture; SurfaceLoader.FromSurface(dstTexture.GetCubeMapSurface(args.Face, args.Mips), srcTexture.GetSurfaceLevel(0), Filter.Dither|Filter.Triangle| (srcContainer.SRGB?Filter.SrgbIn:0)| (dstContainer.SRGB?Filter.SrgbOut:0), 0); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine("Validating models"); foreach (OpsModel model in statement.GetContent(context)) { foreach (OpsMeshContainer meshContainer in model.GetMeshEnumerator()) { string errorsAndWarnings; meshContainer.MeshData.Mesh.Validate(meshContainer.GetAdjacencyStream(), out errorsAndWarnings); if (errorsAndWarnings.Length != 0) { OpsConsole.WriteLine("Invalid " + meshContainer.FriendlyName(model)); OpsConsole.WriteLine(errorsAndWarnings); } } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine( "Mesh information"); foreach( OpsModel model in statement.GetContent(context) ) { OpsConsole.WriteLine( "MODEL: '{0}'", model.Name); OpsConsole.WriteLine(format, "Names", "Faces", "Vertices", "Attributes", "Boundings" ); foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { float radius = 0; VertexElement[] VEs= meshContainer.MeshData.Mesh.Declaration; int posIdx; if( MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.Position, 0, out posIdx) ) { using (VertexBuffer vb = meshContainer.MeshData.Mesh.VertexBuffer) { GraphicsStream vertexData = vb.Lock( VEs[posIdx].Offset, vb.Description.Size - VEs[posIdx].Offset, LockFlags.None); Vector3 center; radius = Geometry.ComputeBoundingSphere( vertexData, meshContainer.MeshData.Mesh.NumberVertices, meshContainer.MeshData.Mesh.NumberBytesPerVertex, out center); vb.Unlock(); } } OpsConsole.WriteLine( format, meshContainer.Name, meshContainer.MeshData.Mesh.NumberFaces, meshContainer.MeshData.Mesh.NumberVertices, meshContainer.MeshData.Mesh.NumberAttributes, radius); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine("Validating models" ); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { string errorsAndWarnings; meshContainer.MeshData.Mesh.Validate(meshContainer.GetAdjacencyStream(), out errorsAndWarnings); if(errorsAndWarnings.Length != 0) { OpsConsole.WriteLine("Invalid " + meshContainer.FriendlyName(model) ); OpsConsole.WriteLine(errorsAndWarnings); } } } }
private void RenderCubeMapFace(OpsContext context, CubeTexture newTexture, Surface rt, CubeMapFace face, int mip, int size, bool SRGB) { context.Device.SetRenderTarget(0, rt); ShadeVertex[] vb = new ShadeVertex[] { ShadeVertex.ForCube(-1.0f, -1.0f, size, face), ShadeVertex.ForCube(1.0f, -1.0f, size, face), ShadeVertex.ForCube(-1.0f, 1.0f, size, face), ShadeVertex.ForCube(1.0f, 1.0f, size, face), }; context.Device.BeginScene(); context.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vb); context.Device.EndScene(); context.Device.SetRenderTarget(0, context.Device.GetBackBuffer(0, 0, BackBufferType.Mono)); SurfaceLoader.FromSurface(newTexture.GetCubeMapSurface(face, mip), rt, Filter.None | (SRGB?Filter.SrgbOut:0), 0); }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { SavexArguments arguments = statement.Arguments as SavexArguments; ArrayList models = statement.GetContent(context); if(models.Count != 1) { string errorStr = string.Format( "Save requires only one model but found {0}. Try changing/using the Src argument.", models.Count ); throw new OpsException(errorStr); } OpsModel model = models[0] as OpsModel; OpsConsole.WriteLine( "Saving model: {0} to path: {1}", model.Name , arguments.Filename); if(model.HierarchyRoot == null) throw new OpsException("There is nothing currently in the application's context. Must use a Load command first."); Mesh.SaveHierarchyToFile( arguments.Filename, arguments.saveType, model.HierarchyRoot, model.AnimationMixer, null); }
private void RenderCubeMapFace(OpsContext context, CubeTexture newTexture, Surface rt, CubeMapFace face, int mip, int size, bool SRGB) { context.Device.SetRenderTarget(0, rt); ShadeVertex[] vb = new ShadeVertex[] { ShadeVertex.ForCube(-1.0f, -1.0f, size, face), ShadeVertex.ForCube( 1.0f, -1.0f, size, face), ShadeVertex.ForCube(-1.0f, 1.0f, size, face), ShadeVertex.ForCube( 1.0f, 1.0f, size, face), }; context.Device.BeginScene(); context.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vb); context.Device.EndScene(); context.Device.SetRenderTarget(0, context.Device.GetBackBuffer(0, 0, BackBufferType.Mono) ); SurfaceLoader.FromSurface(newTexture.GetCubeMapSurface(face, mip), rt, Filter.None| (SRGB?Filter.SrgbOut:0), 0); }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { CloneVDataArguments arguments = statement.Arguments as CloneVDataArguments; OpsConsole.WriteLine( String.Format("Cloning vertex element {0} as {1}", arguments.FriendlySrcName, arguments.FriendlyDstName) ); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { int srcIdx; int dstIdx; VertexElement[] OldVEs= meshContainer.MeshData.Mesh.Declaration.Clone() as VertexElement[]; int srcUsageIdx = arguments.srcUsageIdx; if( arguments.hasSrcUsageIdx == false) { for( int i = 0 ; i < OldVEs.Length; i++ ) { if( OldVEs[i].DeclarationUsage == arguments.srcUsage ) { srcUsageIdx = OldVEs[i].UsageIndex; break; } } } if(srcUsageIdx < 0) continue; if(!MeshDeclarationHelper.FindElement( OldVEs, arguments.srcUsage, srcUsageIdx, out srcIdx)) throw new OpsException("Could not find source vertex element"); int dstUsageIdxPerMesh = arguments.dstUsageIdx; if(!arguments.hasDstUsageIdx) { if(MeshDeclarationHelper.FindValidUsageIndex(OldVEs, arguments.dstUsage, out dstUsageIdxPerMesh, out dstIdx) ) throw new OpsException("Could not find open usage index for destination vertex element"); } int copyIdx; VertexElement[] VEs= MeshDeclarationHelper.AddElement(OldVEs, OldVEs[srcIdx].DeclarationType, arguments.dstUsage, dstUsageIdxPerMesh, out copyIdx); if(!MeshDeclarationHelper.FindElement( VEs, arguments.srcUsage, srcUsageIdx, out srcIdx)) throw new OpsException("Could not find source vertex element"); if(!MeshDeclarationHelper.FindElement( VEs, arguments.dstUsage, dstUsageIdxPerMesh, out dstIdx)) throw new OpsException("Could not find destination vertex element"); Mesh newMesh = meshContainer.MeshData.Mesh.Clone( meshContainer.MeshData.Mesh.Options.Value, VEs, meshContainer.MeshData.Mesh.Device); int sizeInBytes = MeshDeclarationHelper.GetTypeSize( VEs[srcIdx].DeclarationType ); int srcOffset = VEs[srcIdx].Offset; int dstOffset = VEs[dstIdx].Offset; byte[] copyBuffer = new byte[sizeInBytes]; VertexBuffer vb = newMesh.VertexBuffer; GraphicsStream gs = vb.Lock(0, 0, LockFlags.None); for(int iVertex = 0; iVertex < newMesh.NumberVertices; iVertex++) { gs.Seek(newMesh.NumberBytesPerVertex * iVertex + srcOffset, SeekOrigin.Begin); gs.Read(copyBuffer, 0, sizeInBytes); gs.Seek(newMesh.NumberBytesPerVertex * iVertex + dstOffset, SeekOrigin.Begin); gs.Write(copyBuffer, 0, sizeInBytes); } vb.Unlock(); gs= null; vb= null; meshContainer.ReplaceMesh(newMesh); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { DelVDataArguments arguments = statement.Arguments as DelVDataArguments; OpsConsole.WriteLine( String.Format("Deleting vertex element {0}", arguments.FriendlyName) ); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { VertexElement[] OldVEs= meshContainer.MeshData.Mesh.Declaration.Clone() as VertexElement[]; int srcUsageIdx = arguments.usageIdx; if( arguments.hasSrcUsageIdx == false) { for( int i = 0 ; i < OldVEs.Length; i++ ) { if( OldVEs[i].DeclarationUsage == arguments.usage ) { srcUsageIdx = OldVEs[i].UsageIndex; break; } } } if(srcUsageIdx < 0) continue; int iRemove; if(MeshDeclarationHelper.FindElement(OldVEs, arguments.usage, srcUsageIdx, out iRemove)) { VertexElement[] VEs= MeshDeclarationHelper.RemoveElement(OldVEs, iRemove); Mesh newMesh = meshContainer.MeshData.Mesh.Clone( meshContainer.MeshData.Mesh.Options.Value, VEs, meshContainer.MeshData.Mesh.Device); meshContainer.ReplaceMesh( newMesh ); } else { OpsConsole.WriteLine( String.Format("Could not find vertex element {0}{1} on {2}", arguments.usage, arguments.usageIdx, meshContainer.FriendlyName(model)) ); } } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine( "Cleaning models"); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { string errorsAndWarnings; meshContainer.MeshData.Mesh.Validate(meshContainer.GetAdjacencyStream(), out errorsAndWarnings); if(errorsAndWarnings == null || errorsAndWarnings.Length == 0) continue; else { OpsConsole.WriteLine( "Cleaning '{0}'", meshContainer.FriendlyName(model) ); OpsConsole.WriteLine(errorsAndWarnings); } VertexElement[] OldVEs= null; int offsetOfIndex = -1; Mesh dirtyMesh = meshContainer.MeshData.Mesh; if(meshContainer.SkinInformation != null) { int psizeUsageIdx = -1; int remapIdx = -1; OldVEs= meshContainer.MeshData.Mesh.Declaration.Clone() as VertexElement[]; if(!MeshDeclarationHelper.FindValidUsageIndex(OldVEs, DeclarationUsage.PointSize, out psizeUsageIdx)) throw new OpsException("Could not add remapping-indexing vertex element to declaration"); VertexElement[] VEs= MeshDeclarationHelper.AddElement(OldVEs, DeclarationType.Float1, DeclarationUsage.PointSize, psizeUsageIdx, out remapIdx); dirtyMesh = meshContainer.MeshData.Mesh.Clone( meshContainer.MeshData.Mesh.Options.Value, VEs, meshContainer.MeshData.Mesh.Device); offsetOfIndex = VEs[remapIdx].Offset; VertexBuffer vb = dirtyMesh.VertexBuffer; GraphicsStream gs = vb.Lock(0, 0,LockFlags.None); for(int iVertex = 0; iVertex < dirtyMesh.NumberVertices; iVertex++) { gs.Seek(dirtyMesh.NumberBytesPerVertex * iVertex + offsetOfIndex, SeekOrigin.Begin); gs.Write(iVertex); } vb.Unlock(); gs= null; vb= null; } int[] adjOut; Mesh cleanedMesh= Mesh.Clean(CleanType.BackFacing|CleanType.BowTies, dirtyMesh, meshContainer.GetAdjacency(), out adjOut, out errorsAndWarnings); if(errorsAndWarnings != null && errorsAndWarnings.Length != 0) { OpsConsole.WriteLine("Remaining Errors and Warnings:"); OpsConsole.WriteLine(errorsAndWarnings); } if(meshContainer.SkinInformation != null) { int[] vertexRemap = new int[cleanedMesh.NumberVertices]; VertexBuffer vb = cleanedMesh.VertexBuffer; GraphicsStream gs = vb.Lock(0, 0,LockFlags.None); for(int iVertex = 0; iVertex < cleanedMesh.NumberVertices; iVertex++) { gs.Seek(cleanedMesh.NumberBytesPerVertex*iVertex+offsetOfIndex, SeekOrigin.Begin); vertexRemap[iVertex] = (int)gs.Read(typeof(int)); } vb.Unlock(); meshContainer.RemapSkin( vertexRemap ); cleanedMesh = cleanedMesh.Clone(cleanedMesh.Options.Value, OldVEs, cleanedMesh.Device); } meshContainer.SetAdjacency(adjOut); meshContainer.ReplaceMesh(cleanedMesh); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OpsConsole.WriteLine( "Resetting the entire context"); context.Reset(); }
private ConstantTable SetupDevice(OpsContext context, ShadeArgs args) { string errStr = null; ConstantTable constantTable; GraphicsStream pshader; GraphicsStream vshader; try { ConstantTable dummyTable; errStr = null; vshader = ShaderLoader.CompileShader(ShadeVertex.VertexShader, "VertexShader", null, null, "vs_3_0", ShaderFlags.None, out errStr, out dummyTable); } finally { if (errStr != null && errStr.Length > 0) { OpsConsole.WriteLine("Vertex Shader Compiler messages: " + errStr); OpsConsole.WriteLine("If this message is regarding your entry point, it may be something other than the default 'main'. Please use the argument 'Shader' to specify it."); } } try { Macro dxopsMacro = new Macro(); dxopsMacro.Name = "__DXOPS"; dxopsMacro.Definition = "1"; errStr = null; pshader = ShaderLoader.CompileShaderFromFile(args.File, args.Shader, new Macro[]{ dxopsMacro } , null, "ps_3_0", ShaderFlags.None, out errStr, out constantTable); } finally { if (errStr != null && errStr.Length > 0) { OpsConsole.WriteLine("Pixel Shader Compiler messages: " + errStr); OpsConsole.WriteLine("If this message is regarding your entry point, it may be something other than the default 'main'. Please use the argument 'Shader' to specify it." ); } } context.Device.SetRenderState(RenderStates.CullMode, (int)Cull.None); context.Device.SetRenderState(RenderStates.FillMode, (int)FillMode.Solid); context.Device.SetRenderState(RenderStates.AlphaTestEnable, false); context.Device.SetRenderState(RenderStates.AlphaBlendEnable, false); context.Device.SetRenderState(RenderStates.StencilEnable, false); context.Device.SetRenderState(RenderStates.ZEnable, false); context.Device.SetRenderState(RenderStates.ZBufferWriteEnable, false); context.Device.DepthStencilSurface = null; VertexDeclaration decl = new VertexDeclaration(context.Device, ShadeVertex.VertexDeclaration); context.Device.VertexDeclaration = decl; VertexShader vs = new VertexShader(context.Device, vshader); context.Device.VertexShader = vs; PixelShader ps = new PixelShader(context.Device, pshader); context.Device.PixelShader = ps; constantTable.SetDefaults(context.Device); foreach(OpsParsedArgument constant in args.Constants) { EffectHandle h = constantTable.GetConstant(null, constant.Name); if (h == null) { OpsConsole.WriteLine( "WARNING: Parameter '{0}' was not found in shader.", constant.Name); continue; } ConstantDescription[] cds = constantTable.GetConstantDescription(h, 1); ConstantDescription cd = cds[0]; switch (cd.Class) { case ParameterClass.Object: {//texture switch (cd.ParameterType) { case ParameterType.Texture: case ParameterType.Texture1D: case ParameterType.Texture2D: case ParameterType.Texture3D: case ParameterType.TextureCube: { OpsTexture container = context.GetTexture(constant.Value); int sampler = constantTable.GetSamplerIndex(h); context.Device.SetTexture(sampler, container.Texture); } break; } break; } case ParameterClass.Scalar: case ParameterClass.Vector: case ParameterClass.MatrixColumns: case ParameterClass.MatrixRows: { ArrayList floatList = new ArrayList(); string[] floatStrings = constant.Value.Split(new char[] { ' ', ',' }); foreach (string floatStr in floatStrings) { if (floatStr.Length > 0) { floatList.Add(float.Parse(floatStr)); } } float[] floats = (float[])floatList.ToArray(typeof(float)); constantTable.SetValue(context.Device, h, floats); } break; } } return constantTable; }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { TangentArguments options = statement.Arguments as TangentArguments; OpsConsole.WriteLine( "Generating tangent frames" ); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { VertexElement[] VEs = meshContainer.MeshData.Mesh.Declaration; int texIdx; if( false == MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.TextureCoordinate, 0, out texIdx) ) { throw new OpsException("Cannot generate tangents without texture coordinates (use command uvatlas)"); } int normIdx; if( false == MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.Normal, 0, out normIdx) ) { throw new OpsException("Cannot generate tangents without normals (use command GenNormals)"); } int tanIdx; if( false == MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.Tangent, 0, out tanIdx) ) { throw new OpsException("Cannot generate tangents without a place to store Tangent0 (use command AddVData)"); } int binormIdx; if( false == MeshDeclarationHelper.FindElement(VEs, DeclarationUsage.BiNormal, 0, out binormIdx) ) { throw new OpsException("Cannot generate tangents without a place to store BiNormal0 (use command AddVData)"); } bool success = false; try { GraphicsStream vertexRemapStream= null; Mesh newMesh = Geometry.ComputeTangentFrame( meshContainer.MeshData.Mesh, (int)DeclarationUsage.TextureCoordinate, options.TexIdx, (int)DeclarationUsage.Tangent, 0, (int)DeclarationUsage.BiNormal, 0, (int)DeclarationUsage.Normal, 0, options.Options, meshContainer.GetAdjacencyStream(), options.ThreshPE, options.ThreshSP, options.ThreshNE, out vertexRemapStream); if(newMesh != null) { meshContainer.ReplaceMesh(newMesh); meshContainer.RemapSkin(vertexRemapStream); success = true; } else { success = false; OpsConsole.WriteLine("Failed in 1st attempt to generate tangents on " + meshContainer.FriendlyName(model) ); } } catch(Exception) { OpsConsole.WriteLine("Failed in 1st attempt to generate tangents on " + meshContainer.FriendlyName(model) ); //eating exception } if(!success) { try { meshContainer.MeshData.Mesh.ComputeTangent( options.TexIdx, 0, 0, 0, meshContainer.GetAdjacencyStream()); } catch(Exception) { OpsConsole.WriteLine( "Failed in final attempt to generate tangents on " + meshContainer.FriendlyName(model) ); throw; } } } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { OptimizeArguments arguments = statement.Arguments as OptimizeArguments; OpsConsole.WriteLine( "Optimizing models"); foreach( OpsModel model in statement.GetContent(context) ) { foreach( OpsMeshContainer meshContainer in model.GetMeshEnumerator() ) { int[] adjIn= null; int[] adjOut= null; int[] faceRemap= null; GraphicsStream vertexRemapStream= null; if(arguments.weldType != WeldType.None) { adjIn= meshContainer.GetAdjacency(); meshContainer.MeshData.Mesh.WeldVertices(arguments.epsilonFlags, arguments.epsilons, adjIn, out adjOut, out faceRemap, out vertexRemapStream ); meshContainer.SetAdjacency(adjOut); meshContainer.RemapSkin(vertexRemapStream); } adjIn= meshContainer.GetAdjacency(); Mesh newMesh = meshContainer.MeshData.Mesh.Optimize(arguments.meshFlags, adjIn, out adjOut, out faceRemap, out vertexRemapStream); meshContainer.ReplaceMesh(newMesh); meshContainer.SetAdjacency(adjOut); meshContainer.RemapSkin(vertexRemapStream); } } }
//IOpsCommand public void Run(OpsContext context, OpsStatement statement) { TexSaverArgs texArgs = statement.Arguments as TexSaverArgs; ArrayList containers = statement.GetContent(context); if(containers.Count != 1) throw new OpsException("'src' argument resolves to "+containers.Count+" textures where it must be 1 texture"); OpsTexture container = containers[0] as OpsTexture; OpsConsole.WriteLine("Saving texture: {0} to path: {1}", container.Name ,texArgs.Path ); TextureLoader.Save(texArgs.Path, texArgs.Format, container.Texture); }
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 static void CopyToCubeSide(OpsContext context, CubeTexture newTexture, string srcArg, CubeMapFace face, Filter filter) { if(srcArg == null || srcArg.Length == 0) return; OpsTexture src = context.GetTexture(srcArg); if(src == null) throw new OpsException("Could not find source texture: "+srcArg ); if(src.Texture is CubeTexture) { SurfaceLoader.FromSurface(newTexture.GetCubeMapSurface(face, 0), ((CubeTexture)src.Texture).GetCubeMapSurface(face,0), filter| (src.SRGB?Filter.SrgbIn:0), 0); } else if (src.Texture is Texture) { SurfaceLoader.FromSurface(newTexture.GetCubeMapSurface(face, 0), ((Texture)src.Texture).GetSurfaceLevel(0), filter| (src.SRGB?Filter.SrgbIn:0), 0); } else throw new OpsException("Source texture is not a texture2D: "+srcArg); }
public void Run(OpsContext context, OpsStatement statement) { ShadeArgs args = statement.Arguments as ShadeArgs; ConstantTable constantTable = SetupDevice(context, args); EffectHandle hTarget = constantTable.GetConstant(null, "Target"); ArrayList containers = statement.GetContent(context); OpsConsole.WriteLine( "Shading textures with \"{0}\"", args.File); foreach(OpsTexture container in containers) { if(hTarget != null) { context.Device.SetTexture( constantTable.GetSamplerIndex(hTarget), container.Texture); } if(container.Texture is Texture) { Texture oldTexture = container.Texture as Texture; Texture newTexture = OpsTextureHelper.CloneTexture(oldTexture, Usage.None, Pool.Managed); for( int mip = 0; mip < oldTexture.LevelCount; mip++) { SurfaceDescription sd = oldTexture.GetLevelDescription(mip); CheckFormatValid(sd.Format); Surface rt = context.Device.CreateRenderTarget(sd.Width, sd.Height, sd.Format, MultiSampleType.None, 0, true); context.Device.SetRenderTarget(0, rt); ShadeVertex[] vb = new ShadeVertex[] { ShadeVertex.ForTexture(-1.0f, -1.0f, sd.Width, sd.Height), ShadeVertex.ForTexture( 1.0f, -1.0f, sd.Width, sd.Height), ShadeVertex.ForTexture(-1.0f, 1.0f, sd.Width, sd.Height), ShadeVertex.ForTexture( 1.0f, 1.0f, sd.Width, sd.Height), }; context.Device.BeginScene(); context.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vb); context.Device.EndScene(); context.Device.SetRenderTarget(0, context.Device.GetBackBuffer(0, 0, BackBufferType.Mono) ); SurfaceLoader.FromSurface(newTexture.GetSurfaceLevel(mip), rt, Filter.None| (container.SRGB?Filter.SrgbOut:0), 0); } oldTexture.Dispose(); container.Texture = newTexture; } else if(container.Texture is VolumeTexture) { VolumeTexture oldTexture = container.Texture as VolumeTexture; VolumeTexture newTexture = OpsTextureHelper.CloneVolume(oldTexture, Usage.None, Pool.Managed); for( int mip = 0; mip < oldTexture.LevelCount; mip++) { VolumeDescription vd = oldTexture.GetLevelDescription(mip); CheckFormatValid(vd.Format); Surface sliceRT = context.Device.CreateRenderTarget(vd.Width, vd.Height, vd.Format, MultiSampleType.None, 0, true); for(int slice = 0; slice < vd.Depth; slice++) { context.Device.SetRenderTarget(0, sliceRT); ShadeVertex[] vb = new ShadeVertex[] { ShadeVertex.ForVolume(-1.0f, -1.0f, slice, vd.Width, vd.Height, vd.Depth), ShadeVertex.ForVolume( 1.0f, -1.0f, slice, vd.Width, vd.Height, vd.Depth), ShadeVertex.ForVolume(-1.0f, 1.0f, slice, vd.Width, vd.Height, vd.Depth), ShadeVertex.ForVolume( 1.0f, 1.0f, slice, vd.Width, vd.Height, vd.Depth), }; context.Device.BeginScene(); context.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vb); context.Device.EndScene(); context.Device.SetRenderTarget(0, context.Device.GetBackBuffer(0, 0, BackBufferType.Mono) ); OpsTextureHelper.LoadVolumeSliceFromSurface(newTexture, mip, slice, Filter.None| (container.SRGB?Filter.SrgbOut:0), sliceRT); } sliceRT.Dispose(); } oldTexture.Dispose(); container.Texture = newTexture; } else if(container.Texture is CubeTexture) { CubeTexture oldTexture = container.Texture as CubeTexture; CubeTexture newTexture = OpsTextureHelper.CloneCube(oldTexture, Usage.None, Pool.Managed); for( int mip = 0; mip < oldTexture.LevelCount; mip++) { SurfaceDescription sd = oldTexture.GetLevelDescription(mip); CheckFormatValid(sd.Format); Surface rt = context.Device.CreateRenderTarget( sd.Width, sd.Height, sd.Format, MultiSampleType.None, 0, true ); RenderCubeMapFace( context, newTexture, rt, CubeMapFace.PositiveX, mip, sd.Width, container.SRGB ); RenderCubeMapFace( context, newTexture, rt, CubeMapFace.PositiveY, mip, sd.Width, container.SRGB); RenderCubeMapFace( context, newTexture, rt, CubeMapFace.PositiveZ, mip, sd.Width, container.SRGB); RenderCubeMapFace( context, newTexture, rt, CubeMapFace.NegativeX, mip, sd.Width, container.SRGB); RenderCubeMapFace( context, newTexture, rt, CubeMapFace.NegativeY, mip, sd.Width, container.SRGB); RenderCubeMapFace( context, newTexture, rt, CubeMapFace.NegativeZ, mip, sd.Width, container.SRGB); } oldTexture.Dispose(); container.Texture = newTexture; } } }
//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); } }