private void InitializeRender(viz.Context context, EventTypePluginData data) { Debug.Assert(data != null); lock (this.lockObj) { Debug.Assert(data.rampTexture3d == null); Debug.Assert(data.rampTexture2d == null); if (context != null) { BodyIndexPlugin.CreateTextures(data, context); // 2D ramp texture is different from 3D ramp texture for visualization with skeleton uint[] rampData = new uint[BodyIndexPlugin.cRampTextureLength]; rampData[0] = 0xFFFF0000; rampData[1] = 0xFF00FF00; rampData[2] = 0xFF40FFFF; rampData[3] = 0xFFFFFF40; rampData[4] = 0xFFFF40FF; rampData[5] = 0xFF8080FF; for (int i = 6; i < rampData.Length; ++i) { rampData[i] = 0xFFFFFFFF; } data.rampTexture3d = new viz.Texture(context, (uint)rampData.Length, 1, viz.TextureFormat.B8G8R8A8_UNORM, false); unsafe { fixed(uint *pRampData = rampData) { data.rampTexture3d.UpdateData((byte *)pRampData, (uint)rampData.Length * sizeof(uint)); } } rampData[0] = 0xC0FF0000; rampData[1] = 0xC000FF00; rampData[2] = 0xC040FFFF; rampData[3] = 0xC0FFFF40; rampData[4] = 0xC0FF40FF; rampData[5] = 0xC08080FF; for (int i = 6; i < rampData.Length; i++) { rampData[i] = 0xFF000000; } data.rampTexture2d = new viz.Texture(context, (uint)rampData.Length, 1, viz.TextureFormat.B8G8R8A8_UNORM, false); unsafe { fixed(uint *pRampData = rampData) { data.rampTexture2d.UpdateData((byte *)pRampData, (uint)rampData.Length * sizeof(uint)); } } } } }
private void HandleEvent(KStudioEvent eventObj, EventTypePluginData data, EventType eventType) { if ((eventObj != null) && (data != null)) { if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.BodyIndex) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.BodyIndexMonitor)) { bool doDataEvent = false; bool doVisibleEvent = false; lock (this.lockObj) { bool isSelectedData = (this.selectedData == data); HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer(); doVisibleEvent = isSelectedData && (newSharedFrame == null) != (data.sharedBodyIndexFrame == null); data.sharedBodyIndexFrame = newSharedFrame; uint newWidth = nui.Constants.STREAM_BODY_INDEX_WIDTH; uint newHeight = nui.Constants.STREAM_BODY_INDEX_HEIGHT; if ((data.rawBodyIndexTexture == null) || (newWidth != data.imageWidth) || (newHeight != data.imageHeight)) { data.imageWidth = newWidth; data.imageHeight = newHeight; viz.Context context = null; if (this.pluginService != null) { context = this.pluginService.GetContext(eventType); } if (context != null) { BodyIndexPlugin.CreateTextures(data, context); } } if (BodyIndexPlugin.UpdateSelectedPixelValue(data)) { doDataEvent = isSelectedData; } } if (doVisibleEvent) { this.RaisePropertyChanged("HasSelected2DPixelData"); } if (doDataEvent) { this.RaisePropertyChanged("Selected2DPixelBodyIndex"); } } } }
protected virtual void Dispose(bool disposing) { if (disposing) { lock (this.lockObj) { BodyIndexPlugin.DisposeData(this.monitorData, true); BodyIndexPlugin.DisposeData(this.inspectionData, true); } } }
public void UninitializeRender(EventType eventType) { switch (eventType) { case EventType.Monitor: BodyIndexPlugin.DisposeData(this.monitorData, false); break; case EventType.Inspection: BodyIndexPlugin.DisposeData(this.inspectionData, false); break; } }
private void UpdatePropertyView(double x, double y, uint width, uint height, EventTypePluginData data) { Debug.Assert(data != null); bool doEvent = false; lock (this.lockObj) { if (this.selectedData != data) { doEvent = true; this.selectedData = data; } data.selected2DPixelX = 0; data.selected2DPixelY = 0; data.selected2DPixelBodyIndex = 0; if (width == data.imageWidth) { data.selected2DPixelX = (uint)x; } else { data.selected2DPixelX = (uint)((x / width) * data.imageWidth); } if (height == data.imageHeight) { data.selected2DPixelY = (uint)y; } else { data.selected2DPixelY = (uint)((y / height) * data.imageHeight); } BodyIndexPlugin.UpdateSelectedPixelValue(data); } this.RaisePropertyChanged("Selected2DPixelX"); this.RaisePropertyChanged("Selected2DPixelY"); this.RaisePropertyChanged("Selected2DPixelBodyIndex"); if (doEvent) { this.RaisePropertyChanged("HasSelected2DPixelData"); } }
private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; lock (this.lockObj) { BodyIndexPlugin.UpdateData(data); if (pluginViewSettings is BodyIndexPlugin2DViewSettings) { value = data.bodyIndexTexture2d; } else if (pluginViewSettings is BodyIndexPlugin3DViewSettings) { value = data.bodyIndexTexture3d; } } return(value); }