コード例 #1
0
 public BodyOptions(float r, float g, float b)
 {
     BoneEffect = new viz.Effect
     {
         EnableLighting = true,
         Ambient        = new viz.Vector(1.0f, 0.0f, 0.0f, 1.0f)
         {
             R = r, G = g, B = b
         },
         Specular = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f),
         Power    = 22.0f
     };
     JointEffect = new viz.Effect {
         Diffuse = new viz.Vector(0.0f, 1.0f, 0.0f, 1.0f)
     };;
     ColorVector = new viz.Vector(1, 1, 1, 1)
     {
         R = r, G = g, B = b
     };
 }
コード例 #2
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);
                        }
                    }
                }
            }
        }
コード例 #3
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);
                    }
                }
            }
        }
コード例 #4
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);
                        }
                    }
                }
            }
        }
コード例 #5
0
        // object owning data should be locked
        private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data, nui.Registration registration)
        {
            Debug.Assert(data != null);

            DepthPlugin3DViewSettings depthPlugin3DViewSettings = pluginViewSettings as DepthPlugin3DViewSettings;

            if ((registration != null) && (depthPlugin3DViewSettings != null))
            {
                DepthPlugin.UpdateData(depthPlugin3DViewSettings, texture, data);

                bool doColor     = false;
                bool doBodyIndex = false;

                if (texture != null)
                {
                    uint textureWidth  = texture.GetWidth();
                    uint textureHeight = texture.GetHeight();

                    doColor = (textureWidth == nui.Constants.STREAM_COLOR_WIDTH) &&
                              (textureHeight == nui.Constants.STREAM_COLOR_HEIGHT);

                    doBodyIndex = (texture.GetTextureFormat() == viz.TextureFormat.B8G8R8A8_UNORM) &&
                                  (textureWidth == nui.Constants.STREAM_DEPTH_WIDTH) &&
                                  (textureHeight == nui.Constants.STREAM_DEPTH_HEIGHT);
                }

                if ((depthPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex) ||
                    (!depthPlugin3DViewSettings.IsSupplyingSurface && depthPlugin3DViewSettings.ViewType == DepthPlugin3DViewSettings.Depth3DViewType.SurfaceNormal))
                {
                    if (data.depthMap != null)
                    {
                        // special case for body index
                        viz.Effect effect = new viz.Effect()
                        {
                            Direction      = new viz.Vector(0.5f, 0.3f, 1.5f, 0),
                            Ambient        = new viz.Vector(0.0f, 0.0f, 0.0f, 1.0f),
                            Diffuse        = new viz.Vector(0.5f, 0.5f, 0.5f, 1.0f),
                            Specular       = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f),
                            Power          = 25.0f,
                            EnableLighting = true,
                            EnableTexture  = false,
                        };

                        if ((depthPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex))
                        {
                            if (data.depthMap != null)
                            {
                                data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None);
                                effect.EnableTexture = true;
                            }
                        }

                        if (!depthPlugin3DViewSettings.IsSupplyingSurface)
                        {
                            texture = null;
                        }

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

                            IntPtr ptr = data.sharedDepthFrame.Buffer;

                            if (ptr != IntPtr.Zero)
                            {
                                registration.Process(ptr, data.uvTable.Buffer);
                            }

                            data.depthMap.UpdateUVTable(data.uvTable.Buffer, data.uvTable.Size);
                        }
                    }

                    if (data.depthMap != null)
                    {
                        viz.Effect effect = new viz.Effect()
                        {
                            EnableTexture = texture != null,
                        };

                        data.depthMap.Render(effect, texture);
                    }
                }
            }
        }
コード例 #6
0
 public BodyOptions(float r, float g, float b)
 {
     BoneEffect = new viz.Effect
         {
             EnableLighting = true,
             Ambient = new viz.Vector(1.0f, 0.0f, 0.0f, 1.0f) { R = r, G = g, B = b },
             Specular = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f),
             Power = 22.0f
         };
     JointEffect = new viz.Effect { Diffuse = new viz.Vector(0.0f, 1.0f, 0.0f, 1.0f) }; ;
     ColorVector = new viz.Vector(1, 1, 1, 1) { R = r, G = g, B = b };
 }