public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { lock (this.lockObj) { EventTypePluginData data = null; nui.Registration registration = null; switch (eventType) { case EventType.Monitor: data = this.monitorData; break; case EventType.Inspection: data = this.inspectionData; break; } if (data != null) { if (this.pluginService != null) { registration = this.pluginService.GetRegistration(eventType); if (data.lastRegistration != registration) { data.lastRegistration = this.pluginService.GetRegistration(eventType); if ((data.lastRegistration != null) && (data.depthMap != null)) { uint xyTableSize; IntPtr xyTable = data.lastRegistration.GetXYTable(out xyTableSize); data.depthMap.UpdateXYTable(xyTable, xyTableSize); } } } DepthPlugin.Render3D(pluginViewSettings, texture, data, registration); } } }
public nui.Registration GetRegistration(EventType eventType) { DebugHelper.AssertUIThread(); nui.Registration value = null; switch (eventType) { case EventType.Monitor: Debug.Assert(this.monitorData != null); value = this.monitorData.registration; break; case EventType.Inspection: Debug.Assert(this.inspectionData != null); value = this.inspectionData.registration; break; } return(value); }
public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { lock (this.lockObj) { nui.Registration registration = null; if (this.pluginService != null) { registration = pluginService.GetRegistration(eventType); } switch (eventType) { case EventType.Monitor: RawIrPlugin.Render3D(pluginViewSettings, texture, this.monitorData, registration); break; case EventType.Inspection: RawIrPlugin.Render3D(pluginViewSettings, texture, this.inspectionData, registration); break; } } }
public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height) { lock (this.lockObj) { nui.Registration registration = null; if (this.pluginService != null) { registration = this.pluginService.GetRegistration(eventType); } switch (eventType) { case EventType.Monitor: BodyPlugin.Render2D(pluginViewSettings, texture, left, top, width, height, this.monitorData, registration); break; case EventType.Inspection: BodyPlugin.Render2D(pluginViewSettings, texture, left, top, width, height, this.inspectionData, registration); break; } } }
// object owning data should be locked private static void Render3D(IPluginViewSettings pluginViewSettings, EventTypePluginData data, nui.Registration registration) { Debug.Assert(data != null); BodyPlugin3DViewSettings bodyPluginViewSettings = pluginViewSettings as BodyPlugin3DViewSettings; if ((bodyPluginViewSettings != null) && (registration != null) && (data.body != null) && data.bodiesValid) { if (bodyPluginViewSettings.RenderBodies || bodyPluginViewSettings.RenderHands) { data.body.Begin(); for (uint i = 0; i < BodyPlugin.bodyOptions.Length; ++i) { if (bodyPluginViewSettings.RenderBodies) { BodyOptions bodyOption = BodyPlugin.bodyOptions[i]; data.body.RenderBones(i, bodyOption.BoneEffect); if (bodyPluginViewSettings.RenderJointOrientations) { data.body.RenderJointOrientations(i, bodyOption.JointEffect); } data.body.RenderJoints(i, bodyOption.JointEffect); if (bodyPluginViewSettings.RenderInfo && (data.font != null)) { // PlayderIndex (sic) data.body.RenderInfo(i, viz.BodyInfoFlag.PlayderIndex, data.font, bodyOption.ColorVector); } } if (bodyPluginViewSettings.RenderHands) { data.body.RenderHandStates(i); } } data.body.End(0.0f); } } }
// object owning data should be locked private static void Render2D(IPluginViewSettings pluginViewSettings, viz.Texture texture, float left, float top, float width, float height, EventTypePluginData data, nui.Registration registration) { Debug.Assert(data != null); BodyPlugin2DViewSettings bodyPluginViewSettings = pluginViewSettings as BodyPlugin2DViewSettings; if ((bodyPluginViewSettings != null) && (registration != null) && (data.body != null) && data.bodiesValid) { if (bodyPluginViewSettings.RenderBodies || bodyPluginViewSettings.RenderHands) { viz.Body2DMode bodyMode = viz.Body2DMode.DepthIR; if ((texture != null) && (texture.GetWidth() == nui.Constants.STREAM_COLOR_WIDTH) && (texture.GetHeight() == nui.Constants.STREAM_COLOR_HEIGHT)) { bodyMode = viz.Body2DMode.Color; } data.body.Begin2D(left, top, width, height, bodyMode, registration.GetCalibrationData()); for (uint i = 0; i < BodyPlugin.bodyOptions.Length; ++i) { if (bodyPluginViewSettings.RenderBodies) { viz.Vector color = BodyPlugin.bodyOptions[i].ColorVector; color.A = 0.7f; data.body.RenderBones2D(i, color); } if (bodyPluginViewSettings.RenderHands) { data.body.RenderHandStates2D(i); } } data.body.End2D(); } } }
// object owning data should be locked private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data, nui.Registration registration) { Debug.Assert(data != null); DepthPlugin3DViewSettings depthPlugin3DViewSettings = pluginViewSettings as DepthPlugin3DViewSettings; if ((registration != null) && (depthPlugin3DViewSettings != null)) { DepthPlugin.UpdateData(depthPlugin3DViewSettings, texture, data); bool doColor = false; bool doBodyIndex = false; if (texture != null) { uint textureWidth = texture.GetWidth(); uint textureHeight = texture.GetHeight(); doColor = (textureWidth == nui.Constants.STREAM_COLOR_WIDTH) && (textureHeight == nui.Constants.STREAM_COLOR_HEIGHT); doBodyIndex = (texture.GetTextureFormat() == viz.TextureFormat.B8G8R8A8_UNORM) && (textureWidth == nui.Constants.STREAM_DEPTH_WIDTH) && (textureHeight == nui.Constants.STREAM_DEPTH_HEIGHT); } if ((depthPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex) || (!depthPlugin3DViewSettings.IsSupplyingSurface && depthPlugin3DViewSettings.ViewType == DepthPlugin3DViewSettings.Depth3DViewType.SurfaceNormal)) { if (data.depthMap != null) { // special case for body index viz.Effect effect = new viz.Effect() { Direction = new viz.Vector(0.5f, 0.3f, 1.5f, 0), Ambient = new viz.Vector(0.0f, 0.0f, 0.0f, 1.0f), Diffuse = new viz.Vector(0.5f, 0.5f, 0.5f, 1.0f), Specular = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f), Power = 25.0f, EnableLighting = true, EnableTexture = false, }; if ((depthPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex)) { if (data.depthMap != null) { data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None); effect.EnableTexture = true; } } if (!depthPlugin3DViewSettings.IsSupplyingSurface) { texture = null; } data.depthMap.Render(effect, texture); } } else { if (depthPlugin3DViewSettings.IsSupplyingSurface && doColor) { // special case for color if ((registration != null) && (data.depthMap != null) && (data.uvTable != null) && (data.sharedDepthFrame != null)) { data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithUV, viz.DepthRampMode.None); IntPtr ptr = data.sharedDepthFrame.Buffer; if (ptr != IntPtr.Zero) { registration.Process(ptr, data.uvTable.Buffer); } data.depthMap.UpdateUVTable(data.uvTable.Buffer, data.uvTable.Size); } } if (data.depthMap != null) { viz.Effect effect = new viz.Effect() { EnableTexture = texture != null, }; data.depthMap.Render(effect, texture); } } } }