public void Evaluate(int SpreadMax) { FOut.Stream.IsChanged = false; var valid = _input != null; if (valid) { valid = _input.Spread.SliceCount > 0; } if (valid) { valid = _input[0] != null; } if (valid) { RenderRequest?.Invoke(this, FPluginHost); if (!_input.Spread.IsChanged && !_typeChanged && !FFlagChanged[0]) { return; } FOut.ResizeAndDismiss(_input.Spread.SliceCount, i => null); for (int i = 0; i < _input.Spread.SliceCount; i++) { if (FOut[i] == null) { FOut[i] = new VAuxObject { Object = _input[i] } } ; var vaux = (VAuxObject)FOut[i]; vaux.Object = _input[i]; } _typeChanged = false; FOut.Stream.IsChanged = FFlagChanged[0]; } else { FOut.Stream.IsChanged = _prevvalid; FOut.SliceCount = 0; } _prevvalid = valid; }
public void Evaluate(int SpreadMax) { if (FTextureIn.IsChanged) { for (int i = 0; i < FOutput.SliceCount; i++) { FOutput[i].SliceCount = 0; FFormat[i].SliceCount = 0; FStatus[i].SliceCount = 0; } FOutput.SliceCount = 1; FFormat.SliceCount = 1; FStatus.SliceCount = 1; } if (this.FTextureIn.IsConnected) { RenderRequest?.Invoke(this, FHost); if (AssignedContext == null) { FStatus.SliceCount = 0; return; } //Do NOT cache this, assignment done by the host var context = AssignedContext; FOutput.SliceCount = SpreadMax; FFormat.SliceCount = SpreadMax; FStatus.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { if (FTextureIn[i].Contains(context) && FRead[i]) { FOutput[i].SliceCount = 0; FFormat[i].SliceCount = 0; FStatus[i].SliceCount = 0; var reader = new ZXing.BarcodeReader(); try { MemoryStream memoryStream = new MemoryStream(); Texture2D.ToStream(context.CurrentDeviceContext, FTextureIn[i][context].Resource, SlimDX.Direct3D11.ImageFileFormat.Bmp, memoryStream); Bitmap bmp = new Bitmap(memoryStream); var results = reader.DecodeMultiple(bmp); if (results != null) { var count = results.Length; FOutput[i].SliceCount = count; FFormat[i].SliceCount = count; FStatus[i].SliceCount = count; for (int j = 0; j < count; j++) { var result = results[j]; FOutput[i][j] = result.Text; FFormat[i][j] = result.BarcodeFormat.ToString(); FStatus[i][j] = "Success"; } } else { FOutput[i].SliceCount = 1; FFormat[i].SliceCount = 1; FStatus[i].SliceCount = 1; FOutput[i][0] = ""; FFormat[i][0] = ""; FStatus[i][0] = "No Barcode Found"; } } catch (Exception ex) { FLogger.Log(ex); FOutput[i].SliceCount = 1; FFormat[i].SliceCount = 1; FStatus[i].SliceCount = 1; FOutput[i][0] = ""; FFormat[i][0] = ""; FStatus[i][0] = ex.Message; } } } } else { FOutput.SliceCount = 1; FFormat.SliceCount = 1; FStatus.SliceCount = 1; } }
public override void Evaluate(int SpreadMax, CVRSystem system) { if (FTextureIn.IsConnected) { RenderRequest?.Invoke(this, FHost); if (AssignedContext == null) { return; } try { if (FTextureIn[0].Contains(AssignedContext)) { long currpointer = FTextureIn[0][AssignedContext].Resource.ComPointer.ToInt64(); if ((FTextureIn.IsChanged || currpointer != SrcPointer) && currpointer > 0) { FTexture = new Texture_t { handle = new IntPtr(currpointer), eType = EGraphicsAPIConvention.API_DirectX, eColorSpace = FColorSpace[0] }; SrcPointer = currpointer; } FPointer[0] = currpointer; if (FColorSpace.IsChanged) { FTexture.eColorSpace = FColorSpace[0]; } //set tex VRTextureBounds_t boundsL; VRTextureBounds_t boundsR; if (FIsOUIn[0]) { boundsL = FOUTexBoundsL; boundsR = FOUTexBoundsR; } else { boundsL = FSBSTexBoundsL; boundsR = FSBSTexBoundsR; } var compositor = OpenVR.Compositor; var error = compositor.Submit(EVREye.Eye_Left, ref FTexture, ref boundsL, EVRSubmitFlags.Submit_Default); SetStatus(error); if (error != EVRCompositorError.None) { return; } error = compositor.Submit(EVREye.Eye_Right, ref FTexture, ref boundsR, EVRSubmitFlags.Submit_Default); SetStatus(error); if (error != EVRCompositorError.None) { return; } } else { FPointer[0] = -2; } } catch (Exception e) { SetStatus(e); } } }