示例#1
0
        private static void UpdateData(DepthPlugin3DViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            if ((pluginViewSettings != null) && (data.depthMap != null) && (data.depthTexture != null))
            {
                if (pluginViewSettings.IsSupplyingSurface)
                {
                    data.depthMap.SetMode(viz.DepthVertexMode.Surface, viz.DepthRampMode.None);
                }
                else
                {
                    switch (pluginViewSettings.ViewType)
                    {
                    case DepthPlugin3DViewSettings.Depth3DViewType.Color:
                        data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Color);
                        break;

                    case DepthPlugin3DViewSettings.Depth3DViewType.Grey:
                        data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Grey);
                        break;

                    case DepthPlugin3DViewSettings.Depth3DViewType.SurfaceNormal:
                        data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None);
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                    }
                }
            }
        }
示例#2
0
        public IPluginViewSettings Add3DView(EventType eventType, Panel hostControl)
        {
            IPluginViewSettings pluginViewSettings = new DepthPlugin3DViewSettings();

#if TODO_PLAYING_AROUND
            if (hostControl != null)
            {
                Border border = new Border()
                {
                    BorderBrush         = System.Windows.Media.Brushes.Yellow,
                    BorderThickness     = new System.Windows.Thickness(2),
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                    VerticalAlignment   = System.Windows.VerticalAlignment.Top,
                };
                TextBlock text = new TextBlock()
                {
                    Text                = "TEST",
                    Foreground          = System.Windows.Media.Brushes.Blue,
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                };
                border.Child = text;
                hostControl.Children.Add(border);
            }
#endif // TODO_PLAYING_AROUND

            return(pluginViewSettings);
        }
示例#3
0
        private DepthPlugin3DViewSettings(DepthPlugin3DViewSettings source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.surface  = source.surface;
            this.viewType = source.viewType;
        }
        private DepthPlugin3DViewSettings(DepthPlugin3DViewSettings source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.surface = source.surface;
            this.viewType = source.viewType;
        }
示例#5
0
        // 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);
                    }
                }
            }
        }
        private static void UpdateData(DepthPlugin3DViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            if ((pluginViewSettings != null) && (data.depthMap != null) && (data.depthTexture != null))
            {
                if (pluginViewSettings.IsSupplyingSurface)
                {
                    data.depthMap.SetMode(viz.DepthVertexMode.Surface, viz.DepthRampMode.None);
                }
                else
                {
                    switch (pluginViewSettings.ViewType)
                    {
                        case DepthPlugin3DViewSettings.Depth3DViewType.Color:
                            data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Color);
                            break;

                        case DepthPlugin3DViewSettings.Depth3DViewType.Grey:
                            data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Grey);
                            break;

                        case DepthPlugin3DViewSettings.Depth3DViewType.SurfaceNormal:
                            data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None);
                            break;

                        default:
                            Debug.Assert(false);
                            break;
                    }
                }
            }
        }
        public IPluginViewSettings Add3DView(EventType eventType, Panel hostControl)
        {
            IPluginViewSettings pluginViewSettings = new DepthPlugin3DViewSettings();

#if TODO_PLAYING_AROUND
            if (hostControl != null)
            {
                Border border = new Border()
                    {
                        BorderBrush = System.Windows.Media.Brushes.Yellow,
                        BorderThickness = new System.Windows.Thickness(2),
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                        VerticalAlignment = System.Windows.VerticalAlignment.Top,
                    };
                TextBlock text = new TextBlock()
                    {
                        Text = "TEST",
                        Foreground = System.Windows.Media.Brushes.Blue,
                        HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                    };
                border.Child = text;
                hostControl.Children.Add(border);
            }
#endif // TODO_PLAYING_AROUND

            return pluginViewSettings;
        }