private RawIrPlugin3DViewSettings(RawIrPlugin3DViewSettings source)
            : base(source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.surface  = source.surface;
            this.viewType = source.viewType;
        }
Ejemplo n.º 2
0
        public IPluginViewSettings Add3DView(EventType eventType, Panel hostControl)
        {
            IPluginViewSettings pluginViewSettings = null;

            switch (eventType)
            {
            case EventType.Monitor:
                // no raw monitoring
                // pluginViewSettings = new RawIrPlugin3DViewSettings();
                break;

            case EventType.Inspection:
                pluginViewSettings = new RawIrPlugin3DViewSettings(this.pluginService, eventType);
                break;
            }

            return(pluginViewSettings);
        }
Ejemplo n.º 3
0
        private static void UpdateData(RawIrPlugin3DViewSettings 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 RawIrPlugin3DViewSettings.RawIr3DViewType.DepthColor:
                        data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Color);
                        break;

                    case RawIrPlugin3DViewSettings.RawIr3DViewType.DepthGrey:
                        data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Grey);
                        break;

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

                    case RawIrPlugin3DViewSettings.RawIr3DViewType.Ir:
                        data.depthMap.SetMode(viz.DepthVertexMode.Surface, viz.DepthRampMode.None);
                        data.irTexture.RampConversion(data.rawIrTexture, pluginViewSettings.RampTexture);
                        break;

                    default:
                        Debug.Assert(false);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            viz.Texture value = null;

            lock (this.lockObj)
            {
                RawIrPlugin2DViewSettings raw2DSettingsViewSettings = pluginViewSettings as RawIrPlugin2DViewSettings;
                if (raw2DSettingsViewSettings != null)
                {
                    RawIrPlugin.UpdateData(raw2DSettingsViewSettings, data);

                    if (raw2DSettingsViewSettings.ViewType == RawIrPlugin2DViewSettings.RawIr2DViewType.Ir)
                    {
                        value = data.irTexture;
                    }
                    else
                    {
                        value = data.depthTexture;
                    }
                }
                else
                {
                    RawIrPlugin3DViewSettings raw3DSettingsViewSettings = pluginViewSettings as RawIrPlugin3DViewSettings;
                    if (raw3DSettingsViewSettings != null)
                    {
                        if (raw3DSettingsViewSettings.ViewType == RawIrPlugin3DViewSettings.RawIr3DViewType.Ir)
                        {
                            value = data.irTexture;
                        }
                    }
                }
            }

            return(value);
        }
        private static void UpdateData(RawIrPlugin3DViewSettings 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 RawIrPlugin3DViewSettings.RawIr3DViewType.DepthColor:
                            data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Color);
                            break;

                        case RawIrPlugin3DViewSettings.RawIr3DViewType.DepthGrey:
                            data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Grey);
                            break;

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

                        case RawIrPlugin3DViewSettings.RawIr3DViewType.Ir:
                            data.depthMap.SetMode(viz.DepthVertexMode.Surface, viz.DepthRampMode.None);
                            data.irTexture.RampConversion(data.rawIrTexture, pluginViewSettings.RampTexture);
                            break;

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

            switch (eventType)
            {
                case EventType.Monitor:
                    // no raw monitoring
                    // pluginViewSettings = new RawIrPlugin3DViewSettings();
                    break;

                case EventType.Inspection:
                    pluginViewSettings = new RawIrPlugin3DViewSettings(this.pluginService, eventType);
                    break;
            }

            return pluginViewSettings;
        }
        private RawIrPlugin3DViewSettings(RawIrPlugin3DViewSettings source)
            : base(source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.surface = source.surface;
            this.viewType = source.viewType;
        }
Ejemplo n.º 8
0
        private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data, nui.Registration registration)
        {
            Debug.Assert(data != null);

            RawIrPlugin3DViewSettings rawPlugin3DViewSettings = pluginViewSettings as RawIrPlugin3DViewSettings;

            if (rawPlugin3DViewSettings != null)
            {
                RawIrPlugin.UpdateData(rawPlugin3DViewSettings, 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_IR_WIDTH) &&
                                  (textureHeight == nui.Constants.STREAM_IR_HEIGHT);
                }

                if ((!rawPlugin3DViewSettings.IsSupplyingSurface && (rawPlugin3DViewSettings.ViewType == RawIrPlugin3DViewSettings.RawIr3DViewType.Ir)) ||
                    (rawPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex) ||
                    (!rawPlugin3DViewSettings.IsSupplyingSurface && rawPlugin3DViewSettings.ViewType == RawIrPlugin3DViewSettings.RawIr3DViewType.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 ((rawPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex))
                        {
                            if (data.depthMap != null)
                            {
                                data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None);
                                effect.EnableTexture = true;
                            }
                        }

                        if (!rawPlugin3DViewSettings.IsSupplyingSurface && (rawPlugin3DViewSettings.ViewType != RawIrPlugin3DViewSettings.RawIr3DViewType.Ir))
                        {
                            texture = null;
                        }

                        data.depthMap.Render(effect, texture);
                    }
                }
                else
                {
                    if (rawPlugin3DViewSettings.IsSupplyingSurface && doColor)
                    {
                        // special case for color
                        if ((registration != null) && (data.depthMap != null) && (data.uvTable != null) && (data.sharedRawFrame != null))
                        {
                            data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithUV, viz.DepthRampMode.None);

                            IntPtr ptr = data.sharedRawFrame.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);
                    }
                }
            }
        }