private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; lock (this.lockObj) { if (data.sharedDepthFrame != null) { DepthPlugin2DViewSettings depth2DSettingsViewSettings = pluginViewSettings as DepthPlugin2DViewSettings; if (depth2DSettingsViewSettings != null) { DepthPlugin.UpdateData(depth2DSettingsViewSettings, data); value = data.depthTexture; } } } return(value); }
// 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); } } } }