// object owning accessory should be locked
        private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Accessory accessory)
        {
            AccessoryPlugin3DViewSettings accessoryViewSettings = pluginViewSettings as AccessoryPlugin3DViewSettings;

            if ((accessoryViewSettings != null) && (accessory != null))
            {
                if (accessoryViewSettings.RenderOrientationCube)
                {
                    accessory.SetMode(viz.AccessoryMode.RotationCube);
                    accessory.Render();
                }

                if (accessoryViewSettings.RenderFrustum)
                {
                    accessory.SetMode(viz.AccessoryMode.ViewFrustum);
                    accessory.Render();
                }

                if (accessoryViewSettings.RenderFloorPlane)
                {
                    accessory.SetMode(viz.AccessoryMode.FloorPlane);
                    accessory.Render();
                }
            }
        }
        public PluginViewState(IPlugin plugin, IPluginViewSettings pluginViewSettings, FrameworkElement hostControl)
        {
            Debug.Assert(plugin != null);

            this.plugin             = plugin;
            this.pluginViewSettings = pluginViewSettings;
            this.hostControl        = hostControl;
        }
示例#3
0
        public IPluginViewSettings Add3DView(EventType eventType, Panel hostControl)
        {
            IPluginViewSettings pluginViewSettings = null;

            if (eventType == EventType.Monitor)
            {
                pluginViewSettings = new AudioPlugin3DViewSettings(this);
            }

            return(pluginViewSettings);
        }
示例#4
0
        public IPluginViewSettings Add3DView(EventType eventType, Panel hostControl)
        {
            IPluginViewSettings pluginViewSettings = null;

            switch (eventType)
            {
            case EventType.Monitor:
            case EventType.Inspection:
                pluginViewSettings = new IrPlugin3DViewSettings(this.pluginService, eventType);
                break;
            }

            return(pluginViewSettings);
        }
        public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture)
        {
            lock (this.lockObj)
            {
                switch (eventType)
                {
                case EventType.Monitor:
                    AccessoryPlugin.Render3D(pluginViewSettings, this.monitorAccessory);
                    break;

                case EventType.Inspection:
                    AccessoryPlugin.Render3D(pluginViewSettings, this.inspectionAccessory);
                    break;
                }
            }
        }
示例#6
0
        public viz.Texture GetTexture(EventType eventType, IPluginViewSettings pluginViewSettings)
        {
            viz.Texture value = null;

            switch (eventType)
            {
            case EventType.Monitor:
                value = this.GetTexture(pluginViewSettings, this.monitorData);
                break;

            case EventType.Inspection:
                value = this.GetTexture(pluginViewSettings, this.inspectionData);
                break;
            }

            return(value);
        }
        protected override IPluginViewSettings AddView(IPlugin plugin, out Panel hostControl)
        {
            DebugHelper.AssertUIThread();

            hostControl = null;
            IPluginViewSettings value = null;

            I2DVisualPlugin visualPlugin = plugin as I2DVisualPlugin;

            if (visualPlugin != null)
            {
                hostControl = new Canvas();

                value = visualPlugin.Add2DView(this.EventType, hostControl);
            }

            return(value);
        }
示例#8
0
        // 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);
                }
            }
        }
        private void Image2DPropertyViewContent_Loaded(object source, RoutedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            this.Loaded -= Image2DPropertyViewContent_Loaded;

            if ((this.pluginService != null) && (this.viewSettings != null))
            {
                foreach (IPlugin plugin in pluginService.Plugins)
                {
                    XElement pluginViewSettingsElement = viewSettings.GetPluginViewSettings(plugin.Id);

                    I2DVisualPlugin visualPlugin = plugin as I2DVisualPlugin;
                    if (visualPlugin != null)
                    {
                        ContentControl hostControl = new ContentControl();

                        IPluginViewSettings pluginViewSettings = visualPlugin.Add2DPropertyView(hostControl);

                        if (pluginViewSettings != null)
                        {
                            XElement pluginViewDataElement = null;
                            if (pluginViewSettingsElement != null)
                            {
                                pluginViewDataElement = pluginViewSettingsElement.Element("data");
                            }
                            pluginViewSettings.ReadFrom(pluginViewDataElement);
                        }

                        if ((pluginViewSettings != null) || (hostControl.Content != null))
                        {
                            PluginViewState pluginViewState = new PluginViewState(plugin, pluginViewSettings, hostControl);

                            this.pluginViewStates.Add(pluginViewState);

                            if (hostControl.Content != null)
                            {
                                this.List.Children.Add(hostControl);
                            }
                        }
                    }
                }
            }
        }
示例#10
0
        private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            viz.Texture value = null;

            lock (this.lockObj)
            {
                IrPluginViewSettings irPluginViewSettings = pluginViewSettings as IrPluginViewSettings;
                if (irPluginViewSettings != null)
                {
                    IrPlugin.UpdateData(irPluginViewSettings.RampTexture, data);

                    value = data.irTexture;
                }
            }

            return(value);
        }
示例#11
0
        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 RenderViewSettings(string title, IEnumerable <PluginViewState> pluginViewStates)
        {
            DebugHelper.AssertUIThread();

            this.title            = title;
            this.pluginViewStates = pluginViewStates;

            if (this.pluginViewStates != null)
            {
                foreach (PluginViewState pluginViewState in this.pluginViewStates)
                {
                    IPluginViewSettings pluginViewSettings = pluginViewState.PluginViewSettings;
                    if (pluginViewSettings != null)
                    {
                        pluginViewSettings.PropertyChanged += PluginViewSettings_PropertyChanged;
                        pluginViewState.PropertyChanged    += PluginViewSettings_PropertyChanged;
                    }
                }
            }
        }
示例#13
0
        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;
                }
            }
        }
示例#14
0
        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);
        }
示例#15
0
        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);
        }
示例#16
0
        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;
                }
            }
        }
示例#17
0
        // 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();
                }
            }
        }
示例#18
0
        public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture)
        {
            if (eventType == EventType.Monitor)
            {
                lock (this.lockObj)
                {
                    if (pluginViewSettings is AudioPlugin3DViewSettings)
                    {
                        if (this.beamConfidence > 0.0f)
                        {
                            viz.Effect effectBeam = new viz.Effect()
                            {
                                EnableLighting = true,
                                Ambient        = new viz.Vector(0.0f, 1.0f, 0.0f, 0.5f),
                            };

                            float[] matrixFloats = new float[16];
                            unsafe
                            {
                                fixed(float *pMatrix = &matrixFloats[0])
                                {
                                    MatrixHelper.CalculateBeamMatrix(this.beamAngle, pMatrix);
                                }
                            }

                            viz.Matrix mat = new viz.Matrix();
                            mat.R0 = new viz.Vector(matrixFloats[0], matrixFloats[1], matrixFloats[2], matrixFloats[3]);
                            mat.R1 = new viz.Vector(matrixFloats[4], matrixFloats[5], matrixFloats[6], matrixFloats[7]);
                            mat.R2 = new viz.Vector(matrixFloats[8], matrixFloats[9], matrixFloats[10], matrixFloats[11]);
                            mat.R3 = new viz.Vector(matrixFloats[12], matrixFloats[13], matrixFloats[14], matrixFloats[15]);

                            this.beamMesh.Render(viz.MeshRenderMode.IndexedTriangleList, mat, effectBeam, null);
                        }
                    }
                }
            }
        }
示例#19
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 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;
        }
        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;
        }
示例#22
0
 public void RemoveView(Guid viewId, Panel hostControl, IPluginViewSettings pluginViewSettings)
 {
 }
        private void InitializePlugins()
        {
            DebugHelper.AssertUIThread();

            if ((this.pluginService != null) && (this.viewSettings != null) && (this.pluginViewStates != null) && (this.pluginViewStates.Count == 0))
            {
                bool hasUserSet        = false;
                Guid depthPluginId     = new Guid(0x4fc932f6, 0x77a4, 0x4a22, 0xbe, 0x1f, 0x93, 0x42, 0x4d, 0x8e, 0xbb, 0x1a);
                Guid bodyPluginId      = new Guid(0x85a371bc, 0x7bb2, 0x4534, 0x86, 0x5d, 0xb7, 0x2, 0x67, 0x54, 0xe8, 0x76);
                Guid accessoryPluginId = new Guid(0xd1ec6fb2, 0xb19d, 0x4285, 0x9b, 0x69, 0xdc, 0x92, 0x1f, 0xeb, 0xf6, 0x9f);

                Dictionary <Guid, PluginViewState> defaultEnabled = new Dictionary <Guid, PluginViewState>();
                defaultEnabled[depthPluginId]     = null;
                defaultEnabled[bodyPluginId]      = null;
                defaultEnabled[accessoryPluginId] = null;

                foreach (IPlugin plugin in pluginService.Plugins)
                {
                    if ((this.filterFunc == null) || this.filterFunc(plugin))
                    {
                        bool enabled = false;
                        int  order   = int.MaxValue;

                        XElement pluginViewSettingsElement = viewSettings.GetPluginViewSettings(plugin.Id);
                        enabled = XmlExtensions.GetAttribute(pluginViewSettingsElement, "enabled", enabled);
                        order   = XmlExtensions.GetAttribute(pluginViewSettingsElement, "order", order);

                        if (enabled || (order != int.MaxValue)) // user has deliberately made changes
                        {
                            hasUserSet = true;
                        }

                        {
                            Panel hostControl;

                            IPluginViewSettings pluginViewSettings = AddView(plugin, out hostControl);
                            if (pluginViewSettings != null)
                            {
                                XElement pluginViewDataElement = null;
                                if (pluginViewSettingsElement != null)
                                {
                                    pluginViewDataElement = pluginViewSettingsElement.Element("data");
                                }
                                pluginViewSettings.ReadFrom(pluginViewDataElement);

                                PluginViewState pluginViewState = new PluginViewState(plugin, pluginViewSettings, hostControl)
                                {
                                    IsEnabled = enabled,
                                    Order     = order
                                };

                                this.pluginViewStates.Add(pluginViewState);

                                PluginViewState temp;
                                if (defaultEnabled.TryGetValue(plugin.Id, out temp))
                                {
                                    if (temp == null)
                                    {
                                        defaultEnabled[plugin.Id] = pluginViewState;
                                    }
                                }
                            }
                        }
                    }
                }

                if (!hasUserSet)
                {
                    foreach (PluginViewState pluginViewState in defaultEnabled.Values)
                    {
                        if (pluginViewState != null)
                        {
                            pluginViewState.IsEnabled = true;
                        }
                    }
                }

                this.pluginViewStates.Sort(delegate(PluginViewState a, PluginViewState b)
                {
                    int result = 0;
                    if (a == null)
                    {
                        if (b != null)
                        {
                            result = -1;
                        }
                    }
                    else
                    {
                        if (b == null)
                        {
                            result = 1;
                        }
                        else
                        {
                            result = a.Order.CompareTo(b.Order);
                            if (result == 0)
                            {
                                result = a.Plugin.Id.CompareTo(b.Plugin.Id);
                            }
                        }
                    }

                    return(result);
                });
            }
        }
        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;
        }
 public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height)
 {
 }
        public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture)
        {
            if (eventType == EventType.Monitor) 
            {
                lock (this.lockObj)
                {
                    if (pluginViewSettings is AudioPlugin3DViewSettings)
                    {
                        if (this.beamConfidence > 0.0f)
                        {
                            viz.Effect effectBeam = new viz.Effect()
                                {
                                    EnableLighting = true,
                                    Ambient = new viz.Vector(0.0f, 1.0f, 0.0f, 0.5f),
                                };

                            float[] matrixFloats = new float[16];
                            unsafe
                            {
                                fixed (float* pMatrix = &matrixFloats[0])
                                {
                                    MatrixHelper.CalculateBeamMatrix(this.beamAngle, pMatrix);
                                }
                            }

                            viz.Matrix mat = new viz.Matrix();
                            mat.R0 = new viz.Vector(matrixFloats[0], matrixFloats[1], matrixFloats[2], matrixFloats[3]);
                            mat.R1 = new viz.Vector(matrixFloats[4], matrixFloats[5], matrixFloats[6], matrixFloats[7]);
                            mat.R2 = new viz.Vector(matrixFloats[8], matrixFloats[9], matrixFloats[10], matrixFloats[11]);
                            mat.R3 = new viz.Vector(matrixFloats[12], matrixFloats[13], matrixFloats[14], matrixFloats[15]);

                            this.beamMesh.Render(viz.MeshRenderMode.IndexedTriangleList, mat, effectBeam, null);
                        }
                    }
                }
            }
        }
        public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height)
        {
            if (eventType == EventType.Monitor) 
            {
                lock (this.lockObj)
                {
                    if (this.frameTime == TimeSpan.MinValue)
                    {
                        return;
                    }

                    AudioPlugin2DViewSettings audioPluginViewSettings = pluginViewSettings as AudioPlugin2DViewSettings;
                    if (audioPluginViewSettings != null)
                    {
                        float x = 10; // margin on left
                        float chartX = x + 100; // offset to chart rendering
                        float y = 10; // margin on top
                        float deltaY = 24; // height of each row

                        // chart window size
                        float chartHeight = 20;
                        float chartWidth = 600;

                        // max value in chart, bigger ones got capped
                        float chartValueCap = 0.02f;

                        // special color for current frame in time line
                        viz.Vector currentFrameColor = new viz::Vector(1, 0, 0, 1);

                        viz.Vector? color = null;

                        if ((audioPluginViewSettings.RenderBeam) && (this.font != null))
                        {
                            string str;
                            if (this.beamConfidence > 0.0f)
                            {
                                str = string.Format(CultureInfo.CurrentCulture, Strings.Audio_Beam_Label_Format, this.beamAngle); // TODO: option for other display? like degrees?
                            }
                            else
                            {
                                str = Strings.Audio_Beam_Invalid_Label;
                            }
                            this.font.DrawText(str, x, y, color);
                        }
                        y += deltaY;

                        if (this.sharedAudioFrame != null)
                        {
                            if (this.sharedAudioFrame.Size >= cAudioFrameSizeMinimum)
                            {
                                IntPtr bufferPtr = this.sharedAudioFrame.Buffer;

                                unsafe
                                {
                                    nui.AUDIO_FRAME* pFrame = (nui.AUDIO_FRAME*)bufferPtr.ToPointer();
                                    nui.AUDIO_SUBFRAME* pSubFrame = &(pFrame->FirstSubFrame);

                                    ulong currentFirstFrameTimeStamp = (ulong)this.frameTime.Ticks;
                                    ulong timeStampOffset = currentFirstFrameTimeStamp - pSubFrame->TimeCounter;
                                    ulong currentLastFrameTimeStamp = pSubFrame[pFrame->SubFrameCount - 1].TimeCounter + timeStampOffset;

#if TODO_LOCAL_PLAYBACK
                                    if ((this.timelineBegin != 0) || (this.timelineEnd != 0))
                                    {
                                        // timeline rendering

                                        if (this.timelineDirty)
                                        {
                                            this.timelineData->Sort(new System.Comparison<TimelineEntry>(TimelineEntry.Compare));
                                            timelineDirty = false;
                                        }

                                        if (audioPluginViewSettings.RenderOutput)
                                        {
                                            if (this.font != null)
                                            {
                                                this.font.DrawText(this.outString, x, y, color);

                                                for (int i = 0; i < this.timelineData.Count; i++)
                                                {
                                                    ulong timeStamp = this.timelineData[i]->TimeStamp;
                                                    if (timeStamp < this.timelineBegin) continue;
                                                    if (timeStamp > this.timelineEnd) break;

                                                    float normalizedValue = (float)(Math.Min(chartValueCap, Math.Abs(this.timelineData[i].Output)) / chartValueCap);
                                                    float topLeftX = chartX + (timeStamp - this.timelineBegin) * chartWidth / (this.timelineEnd - this.timelineBegin);
                                                    float topLeftY = y + (1 - normalizedValue) * chartHeight / 2;
                                                    float chartBarHeight = Math.Max(normalizedValue * chartHeight, 1.0f);
                                                    bool isCurrentFrame = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp);
                                                    float barZ = isCurrentFrame ? 0 : 0.01f; // put current frame at a smaller z so it's always visible
                                                    float barWidth = isCurrentFrame ? 2.0f : 1.0f; // make current frame tick bold
                                                    viz::Vector? barColor = isCurrentFrame ? currentFrameColor : null;

                                                    if (this.overlay != null)
                                                    {
                                                        this.overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor);
                                                    }
                                                }
                                            }
                                            y += deltaY;
                                        }

                                        for (int iMIC = 0; iMIC < NUIP_AUDIO_NUM_MIC; iMIC++)
                                        {
                                            if ((int)renderOptionType == (int)RenderOptionType::MIC0 + iMIC)
                                            {
                                                _font->DrawText(renderOptionName, x, y, color);

                                                for (int iSample = 0; iSample < _timelineData->Count; iSample++)
                                                {
                                                    UInt64 timeStamp = _timelineData[iSample]->TimeStamp;
                                                    if (timeStamp < _timelineBegin) continue;
                                                    if (timeStamp > _timelineEnd) break;

                                                    float normalizedValue = min(chartValueCap, fabs(_timelineData[iSample]->MIC[iMIC])) / chartValueCap;
                                                    float topLeftX = chartX + (timeStamp - _timelineBegin) * chartWidth / (_timelineEnd - _timelineBegin);
                                                    float topLeftY = y + (1 - normalizedValue) * chartHeight / 2;
                                                    float chartBarHeight = max(normalizedValue * chartHeight, 1.0f);
                                                    bool isCurrentFrame = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp);
                                                    float barZ = isCurrentFrame ? 0 : 0.01f;
                                                    float barWidth = isCurrentFrame ? 2.0f : 1.0f;
                                                    Nullable<Xbox::Kinect::Viz::Vector> barColor;
                                                    if (isCurrentFrame) barColor = currentFrameColor;

                                                    _overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor);
                                                }
                                            }
                                            y += deltaY;
                                        }

                                        for (int iSPK = 0; iSPK < NUIP_AUDIO_NUM_SPK; iSPK++)
                                        {
                                            if ((int)renderOptionType == (int)RenderOptionType::SPK0 + iSPK)
                                            {
                                                _font->DrawText(renderOptionName, x, y, color);

                                                for (int iSample = 0; iSample < _timelineData->Count; iSample++)
                                                {
                                                    UInt64 timeStamp = _timelineData[iSample]->TimeStamp;
                                                    if (timeStamp < _timelineBegin) continue;
                                                    if (timeStamp > _timelineEnd) break;

                                                    float normalizedValue = min(chartValueCap, fabs(_timelineData[iSample]->SPK[iSPK])) / chartValueCap;
                                                    float topLeftX = chartX + (timeStamp - _timelineBegin) * chartWidth / (_timelineEnd - _timelineBegin);
                                                    float topLeftY = y + (1 - normalizedValue) * chartHeight / 2;
                                                    float chartBarHeight = max(normalizedValue * chartHeight, 1.0f);
                                                    bool isCurrentFrame = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp);
                                                    float barZ = isCurrentFrame ? 0 : 0.01f;
                                                    float barWidth = isCurrentFrame ? 2.0f : 1.0f;
                                                    Nullable<Xbox::Kinect::Viz::Vector> barColor;
                                                    if (isCurrentFrame) barColor = currentFrameColor;

                                                    _overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor);
                                                }
                                            }
                                            y += deltaY;
                                        }
                                    }
                                    else
#endif // TODO_LOCAL_PLAYBACK
                                    {
                                        // live rendering
                                        float barWidth = 1;
                                        UInt64 timeSpan = 2 * 10 * 1000 * 1000; // in 100ns unit

                                        if (audioPluginViewSettings.RenderOutput)
                                        {
                                            if (this.font != null)
                                            {
                                                this.font.DrawText(this.outString, x, y, color);
                                            }

                                            if (this.outChart != null)
                                            {
                                                this.outChart.RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap);
                                            }

                                            y += deltaY;
                                        }

                                        if (this.micCharts != null)
                                        {
                                            for (int i = 0; i < this.micCharts.Length; ++i)
                                            {
                                                if (audioPluginViewSettings.GetTrackOption((AudioTrack)(AudioTrack.Mic0 + i)))
                                                {
                                                    if (this.font != null)
                                                    {
                                                        this.font.DrawText(this.micStrings[i], x, y, color);
                                                    }

                                                    this.micCharts[i].RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap);

                                                    y += deltaY;
                                                }
                                            }
                                        }

                                        if (this.speakerCharts != null)
                                        {
                                            for (int i = 0; i < this.speakerCharts.Length; ++i)
                                            {
                                                if (audioPluginViewSettings.GetTrackOption((AudioTrack)(AudioTrack.SpeakerL + i)))
                                                {
                                                    if (this.font != null)
                                                    {
                                                        this.font.DrawText(this.speakerStrings[i], x, y, color);
                                                    }

                                                    this.speakerCharts[i].RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap);

                                                    y += deltaY;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#28
0
        public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height)
        {
            if (eventType == EventType.Monitor)
            {
                lock (this.lockObj)
                {
                    if (this.frameTime == TimeSpan.MinValue)
                    {
                        return;
                    }

                    AudioPlugin2DViewSettings audioPluginViewSettings = pluginViewSettings as AudioPlugin2DViewSettings;
                    if (audioPluginViewSettings != null)
                    {
                        float x      = 10;      // margin on left
                        float chartX = x + 100; // offset to chart rendering
                        float y      = 10;      // margin on top
                        float deltaY = 24;      // height of each row

                        // chart window size
                        float chartHeight = 20;
                        float chartWidth  = 600;

                        // max value in chart, bigger ones got capped
                        float chartValueCap = 0.02f;

                        // special color for current frame in time line
                        viz.Vector currentFrameColor = new viz::Vector(1, 0, 0, 1);

                        viz.Vector?color = null;

                        if ((audioPluginViewSettings.RenderBeam) && (this.font != null))
                        {
                            string str;
                            if (this.beamConfidence > 0.0f)
                            {
                                str = string.Format(CultureInfo.CurrentCulture, Strings.Audio_Beam_Label_Format, this.beamAngle); // TODO: option for other display? like degrees?
                            }
                            else
                            {
                                str = Strings.Audio_Beam_Invalid_Label;
                            }
                            this.font.DrawText(str, x, y, color);
                        }
                        y += deltaY;

                        if (this.sharedAudioFrame != null)
                        {
                            if (this.sharedAudioFrame.Size >= cAudioFrameSizeMinimum)
                            {
                                IntPtr bufferPtr = this.sharedAudioFrame.Buffer;

                                unsafe
                                {
                                    nui.AUDIO_FRAME *   pFrame    = (nui.AUDIO_FRAME *)bufferPtr.ToPointer();
                                    nui.AUDIO_SUBFRAME *pSubFrame = &(pFrame->FirstSubFrame);

                                    ulong currentFirstFrameTimeStamp = (ulong)this.frameTime.Ticks;
                                    ulong timeStampOffset            = currentFirstFrameTimeStamp - pSubFrame->TimeCounter;
                                    ulong currentLastFrameTimeStamp  = pSubFrame[pFrame->SubFrameCount - 1].TimeCounter + timeStampOffset;

#if TODO_LOCAL_PLAYBACK
                                    if ((this.timelineBegin != 0) || (this.timelineEnd != 0))
                                    {
                                        // timeline rendering

                                        if (this.timelineDirty)
                                        {
                                            this.timelineData->Sort(new System.Comparison <TimelineEntry>(TimelineEntry.Compare));
                                            timelineDirty = false;
                                        }

                                        if (audioPluginViewSettings.RenderOutput)
                                        {
                                            if (this.font != null)
                                            {
                                                this.font.DrawText(this.outString, x, y, color);

                                                for (int i = 0; i < this.timelineData.Count; i++)
                                                {
                                                    ulong timeStamp = this.timelineData[i]->TimeStamp;
                                                    if (timeStamp < this.timelineBegin)
                                                    {
                                                        continue;
                                                    }
                                                    if (timeStamp > this.timelineEnd)
                                                    {
                                                        break;
                                                    }

                                                    float       normalizedValue = (float)(Math.Min(chartValueCap, Math.Abs(this.timelineData[i].Output)) / chartValueCap);
                                                    float       topLeftX        = chartX + (timeStamp - this.timelineBegin) * chartWidth / (this.timelineEnd - this.timelineBegin);
                                                    float       topLeftY        = y + (1 - normalizedValue) * chartHeight / 2;
                                                    float       chartBarHeight  = Math.Max(normalizedValue * chartHeight, 1.0f);
                                                    bool        isCurrentFrame  = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp);
                                                    float       barZ            = isCurrentFrame ? 0 : 0.01f;   // put current frame at a smaller z so it's always visible
                                                    float       barWidth        = isCurrentFrame ? 2.0f : 1.0f; // make current frame tick bold
                                                    viz::Vector?barColor        = isCurrentFrame ? currentFrameColor : null;

                                                    if (this.overlay != null)
                                                    {
                                                        this.overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor);
                                                    }
                                                }
                                            }
                                            y += deltaY;
                                        }

                                        for (int iMIC = 0; iMIC < NUIP_AUDIO_NUM_MIC; iMIC++)
                                        {
                                            if ((int)renderOptionType == (int)RenderOptionType::MIC0 + iMIC)
                                            {
                                                _font->DrawText(renderOptionName, x, y, color);

                                                for (int iSample = 0; iSample < _timelineData->Count; iSample++)
                                                {
                                                    UInt64 timeStamp = _timelineData[iSample]->TimeStamp;
                                                    if (timeStamp < _timelineBegin)
                                                    {
                                                        continue;
                                                    }
                                                    if (timeStamp > _timelineEnd)
                                                    {
                                                        break;
                                                    }

                                                    float normalizedValue = min(chartValueCap, fabs(_timelineData[iSample]->MIC[iMIC])) / chartValueCap;
                                                    float topLeftX        = chartX + (timeStamp - _timelineBegin) * chartWidth / (_timelineEnd - _timelineBegin);
                                                    float topLeftY        = y + (1 - normalizedValue) * chartHeight / 2;
                                                    float chartBarHeight  = max(normalizedValue * chartHeight, 1.0f);
                                                    bool  isCurrentFrame  = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp);
                                                    float barZ            = isCurrentFrame ? 0 : 0.01f;
                                                    float barWidth        = isCurrentFrame ? 2.0f : 1.0f;
                                                    Nullable <Xbox::Kinect::Viz::Vector> barColor;
                                                    if (isCurrentFrame)
                                                    {
                                                        barColor = currentFrameColor;
                                                    }

                                                    _overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor);
                                                }
                                            }
                                            y += deltaY;
                                        }

                                        for (int iSPK = 0; iSPK < NUIP_AUDIO_NUM_SPK; iSPK++)
                                        {
                                            if ((int)renderOptionType == (int)RenderOptionType::SPK0 + iSPK)
                                            {
                                                _font->DrawText(renderOptionName, x, y, color);

                                                for (int iSample = 0; iSample < _timelineData->Count; iSample++)
                                                {
                                                    UInt64 timeStamp = _timelineData[iSample]->TimeStamp;
                                                    if (timeStamp < _timelineBegin)
                                                    {
                                                        continue;
                                                    }
                                                    if (timeStamp > _timelineEnd)
                                                    {
                                                        break;
                                                    }

                                                    float normalizedValue = min(chartValueCap, fabs(_timelineData[iSample]->SPK[iSPK])) / chartValueCap;
                                                    float topLeftX        = chartX + (timeStamp - _timelineBegin) * chartWidth / (_timelineEnd - _timelineBegin);
                                                    float topLeftY        = y + (1 - normalizedValue) * chartHeight / 2;
                                                    float chartBarHeight  = max(normalizedValue * chartHeight, 1.0f);
                                                    bool  isCurrentFrame  = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp);
                                                    float barZ            = isCurrentFrame ? 0 : 0.01f;
                                                    float barWidth        = isCurrentFrame ? 2.0f : 1.0f;
                                                    Nullable <Xbox::Kinect::Viz::Vector> barColor;
                                                    if (isCurrentFrame)
                                                    {
                                                        barColor = currentFrameColor;
                                                    }

                                                    _overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor);
                                                }
                                            }
                                            y += deltaY;
                                        }
                                    }
                                    else
#endif // TODO_LOCAL_PLAYBACK
                                    {
                                        // live rendering
                                        float  barWidth = 1;
                                        UInt64 timeSpan = 2 * 10 * 1000 * 1000; // in 100ns unit

                                        if (audioPluginViewSettings.RenderOutput)
                                        {
                                            if (this.font != null)
                                            {
                                                this.font.DrawText(this.outString, x, y, color);
                                            }

                                            if (this.outChart != null)
                                            {
                                                this.outChart.RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap);
                                            }

                                            y += deltaY;
                                        }

                                        if (this.micCharts != null)
                                        {
                                            for (int i = 0; i < this.micCharts.Length; ++i)
                                            {
                                                if (audioPluginViewSettings.GetTrackOption((AudioTrack)(AudioTrack.Mic0 + i)))
                                                {
                                                    if (this.font != null)
                                                    {
                                                        this.font.DrawText(this.micStrings[i], x, y, color);
                                                    }

                                                    this.micCharts[i].RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap);

                                                    y += deltaY;
                                                }
                                            }
                                        }

                                        if (this.speakerCharts != null)
                                        {
                                            for (int i = 0; i < this.speakerCharts.Length; ++i)
                                            {
                                                if (audioPluginViewSettings.GetTrackOption((AudioTrack)(AudioTrack.SpeakerL + i)))
                                                {
                                                    if (this.font != null)
                                                    {
                                                        this.font.DrawText(this.speakerStrings[i], x, y, color);
                                                    }

                                                    this.speakerCharts[i].RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap);

                                                    y += deltaY;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#29
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);
                    }
                }
            }
        }
        // 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, 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);
                }
            }
        }
        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 void RemoveView(Guid viewId, Panel hostControl, IPluginViewSettings pluginViewSettings)
 {
 }
        public viz.Texture GetTexture(EventType eventType, IPluginViewSettings pluginViewSettings)
        {
            viz.Texture value = null;

            switch (eventType)
            {
                case EventType.Monitor:
                    value = this.GetTexture(pluginViewSettings, this.monitorData);
                    break;

                case EventType.Inspection:
                    value = this.GetTexture(pluginViewSettings, this.inspectionData);
                    break;
            }

            return value;
        }
示例#35
0
 public viz.Texture GetTexture(EventType eventType, IPluginViewSettings pluginViewSettings)
 {
     return(null);
 }
        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;
                }
            }
        }
示例#37
0
 public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture)
 {
 }
        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);
                    }
                }
            }
        }
        // object owning accessory should be locked
        private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Accessory accessory)
        {
            AccessoryPlugin3DViewSettings accessoryViewSettings = pluginViewSettings as AccessoryPlugin3DViewSettings;
            if ((accessoryViewSettings != null) && (accessory != null))
            {
                if (accessoryViewSettings.RenderOrientationCube)
                {
                    accessory.SetMode(viz.AccessoryMode.RotationCube);
                    accessory.Render();
                }

                if (accessoryViewSettings.RenderFrustum)
                {
                    accessory.SetMode(viz.AccessoryMode.ViewFrustum);
                    accessory.Render();
                }

                if (accessoryViewSettings.RenderFloorPlane)
                {
                    accessory.SetMode(viz.AccessoryMode.FloorPlane);
                    accessory.Render();
                }
            }
        }
        public void ShowSettings()
        {
            DebugHelper.AssertUIThread();

            if (this.viewSettings != null)
            {
                HashSet <KStudioEventStreamIdentifier> availableStreamIds = null;

                if (this.availableStreamsGetter != null)
                {
                    switch (this.eventType)
                    {
                    case EventType.Monitor:
                        availableStreamIds = this.availableStreamsGetter.GetAvailableMonitorStreams();
                        break;

                    case EventType.Inspection:
                        availableStreamIds = this.availableStreamsGetter.GetAvailableComboStreams();
                        break;
                    }
                }

                ObservableCollection <PluginViewState> pluginViewStatesCopy = new ObservableCollection <PluginViewState>();

                foreach (PluginViewState pluginViewState in this.pluginViewStates)
                {
                    PluginViewState     pluginViewStateCopy    = new PluginViewState(pluginViewState);
                    IPluginViewSettings pluginViewSettingsCopy = pluginViewStateCopy.PluginViewSettings;

                    if (pluginViewSettingsCopy != null)
                    {
                        pluginViewStatesCopy.Add(pluginViewStateCopy);

                        pluginViewSettingsCopy.CheckRequirementsSatisfied(availableStreamIds);
                    }
                }

                string viewTitle = this.Title;

                using (RenderViewSettings settings = new RenderViewSettings(viewTitle, pluginViewStatesCopy))
                {
                    RenderViewSettingsDialog settingsDialog = new RenderViewSettingsDialog()
                    {
                        DataContext = settings,
                        Owner       = Window.GetWindow(this),
                        Title       = this.SettingsTitle,
                    };

                    XElement viewSettingsElement = viewSettings.ViewSettingsElement;
                    settingsDialog.Width  = settingsDialog.Width = XmlExtensions.GetAttribute(viewSettingsElement, "editWidth", settingsDialog.Width);
                    settingsDialog.Height = settingsDialog.Height = XmlExtensions.GetAttribute(viewSettingsElement, "editHeight", settingsDialog.Height);

                    settingsDialog.ShowDialog();

                    if (settingsDialog.DialogResult == true)
                    {
                        int order = 0;

                        foreach (PluginViewState pluginViewState in pluginViewStatesCopy)
                        {
                            XElement pluginViewElement = new XElement("plugin");

                            if (pluginViewState.PluginViewSettings != null)
                            {
                                XElement pluginViewDataElement = new XElement("data");
                                pluginViewState.PluginViewSettings.WriteTo(pluginViewDataElement);
                                pluginViewElement.Add(pluginViewDataElement);
                            }

                            pluginViewState.Order = order;

                            pluginViewElement.SetAttributeValue("enabled", pluginViewState.IsEnabled.ToString(CultureInfo.InvariantCulture));
                            pluginViewElement.SetAttributeValue("order", pluginViewState.Order.ToString(CultureInfo.InvariantCulture));

                            viewSettings.SetPluginViewSettings(pluginViewState.Plugin.Id, pluginViewElement);
                            ++order;
                        }

                        if (viewSettingsElement != null)
                        {
                            viewSettingsElement.SetAttributeValue("editWidth", settingsDialog.ActualWidth.ToString(CultureInfo.InvariantCulture));
                            viewSettingsElement.SetAttributeValue("editHeight", settingsDialog.ActualHeight.ToString(CultureInfo.InvariantCulture));
                        }

                        this.pluginViewStates.Clear();
                        this.pluginViewStates.AddRange(pluginViewStatesCopy);

                        this.OnSettingsChanged();
                    }
                }
            }
        }
        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;
                }
            }
        }
        private void PluginViewSettings_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            IPluginViewSettings pluginViewSettings      = null;
            PluginViewState     pluginViewStateChanging = sender as PluginViewState;

            if (pluginViewStateChanging != null)
            {
                pluginViewSettings = pluginViewStateChanging.PluginViewSettings;
            }
            else
            {
                pluginViewSettings = sender as IPluginViewSettings;
            }

            Debug.Assert(pluginViewSettings != null);

            IPlugin3DViewSettings plugin3DViewSettings = pluginViewSettings as IPlugin3DViewSettings;

            bool isSupplyingSurface = false;
            bool isSupplyingTexture = false;
            bool isRenderingOpaque  = false;

            switch (e.PropertyName)
            {
            case "IsEnabled":
            {
                Debug.Assert(pluginViewStateChanging != null);
                if (pluginViewStateChanging.IsEnabled)
                {
                    if (plugin3DViewSettings != null)
                    {
                        isSupplyingSurface = plugin3DViewSettings.IsSupplyingSurface;
                        isSupplyingTexture = plugin3DViewSettings.IsSupplyingTexture;
                    }
                    isRenderingOpaque = pluginViewSettings.IsRendingOpaque;
                }
            }
            break;

            case "IsSupplyingSurface":
                if (plugin3DViewSettings != null)
                {
                    isSupplyingSurface = plugin3DViewSettings.IsSupplyingSurface;
                }
                break;

            case "IsSupplyingTexture":
                if (plugin3DViewSettings != null)
                {
                    isSupplyingTexture = plugin3DViewSettings.IsSupplyingTexture;
                }
                break;

            case "IsRenderingOpaque":
                isRenderingOpaque = pluginViewSettings.IsRendingOpaque;
                break;
            }

            if (isSupplyingSurface || isSupplyingTexture || isRenderingOpaque)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    if (isSupplyingSurface)
                    {
                        // tell any other plugin that thought it was supplying the texture that it might not be
                        foreach (PluginViewState pluginViewState in this.pluginViewStates)
                        {
                            IPlugin3DViewSettings other3DViewSettings = pluginViewState.PluginViewSettings as IPlugin3DViewSettings;
                            if ((other3DViewSettings != null) && pluginViewState.IsEnabled && (other3DViewSettings != plugin3DViewSettings))
                            {
                                pluginViewState.IsEnabled = other3DViewSettings.OtherIsSupplyingSurface();
                            }
                        }
                    }

                    if (isSupplyingTexture)
                    {
                        // tell any other plugin that thought it was supplying the texture that it might not be
                        foreach (PluginViewState pluginViewState in this.pluginViewStates)
                        {
                            IPlugin3DViewSettings other3DViewSettings = pluginViewState.PluginViewSettings as IPlugin3DViewSettings;
                            if ((other3DViewSettings != null) && pluginViewState.IsEnabled && (other3DViewSettings != plugin3DViewSettings))
                            {
                                pluginViewState.IsEnabled = other3DViewSettings.OtherIsSupplyingTexture();
                            }
                        }
                    }
                    else
                    if (isRenderingOpaque)
                    {
                        // tell any other plugin that thought it was rendering opaque that it might not be
                        foreach (PluginViewState pluginViewState in this.pluginViewStates)
                        {
                            IPluginViewSettings otherViewSettings = pluginViewState.PluginViewSettings;
                            if ((otherViewSettings != null) && pluginViewState.IsEnabled && (otherViewSettings != pluginViewSettings))
                            {
                                pluginViewState.IsEnabled = otherViewSettings.OtherIsRenderingOpaque();
                            }
                        }
                    }
                }));
            }
        }
 public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture)
 {
 }
示例#44
0
 public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height)
 {
 }
        private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data)
        {
            Debug.Assert(data != null);

            viz.Texture value = null;

            lock (this.lockObj)
            {
                IrPluginViewSettings irPluginViewSettings = pluginViewSettings as IrPluginViewSettings;
                if (irPluginViewSettings != null)
                {
                    IrPlugin.UpdateData(irPluginViewSettings.RampTexture, data);

                    value = data.irTexture;
                }
            }

            return value;
        }
 public viz.Texture GetTexture(EventType eventType, IPluginViewSettings pluginViewSettings)
 {
     return null;
 }
        public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture)
        {
            lock (this.lockObj)
            {
                switch (eventType)
                {
                    case EventType.Monitor:
                        AccessoryPlugin.Render3D(pluginViewSettings, this.monitorAccessory);
                        break;

                    case EventType.Inspection:
                        AccessoryPlugin.Render3D(pluginViewSettings, this.inspectionAccessory);
                        break;
                }
            }
        }