Ejemplo n.º 1
0
    void Update()
    {
        if (kinectManager && kinectManager.IsInitialized())
        {
            KinectInterop.SensorData sensorData = kinectManager.GetSensorData();

            if (sensorData != null && sensorData.depthImage != null && sensorData.colorImageTexture &&
                userBlendMat != null && lastDepthFrameTime != sensorData.lastDepthFrameTime)
            {
                lastDepthFrameTime = sensorData.lastDepthFrameTime;
                userBlendMat.SetTexture("_ColorTex", sensorData.colorImageTexture);

                if (KinectInterop.MapColorFrameToDepthCoords(sensorData, ref color2DepthCoords))
                {
                    color2DepthBuffer.SetData(color2DepthCoords);
                }

                for (int i = 0; i < sensorData.depthImage.Length; i++)
                {
                    int depth = sensorData.depthImage[i];
                    depthImageBufferData[i] = (float)depth;
                }

                depthImageBuffer.SetData(depthImageBufferData);
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (!shaderRectInited)
        {
            PortraitBackground portraitBack = PortraitBackground.Instance;
            if (portraitBack && portraitBack.IsInitialized())
            {
                shaderUvRect = portraitBack.GetShaderUvRect();
            }

            if (userBlendMat != null)
            {
                userBlendMat.SetFloat("_ColorOfsX", shaderUvRect.x);
                userBlendMat.SetFloat("_ColorMulX", shaderUvRect.width);
                userBlendMat.SetFloat("_ColorOfsY", shaderUvRect.y);
                userBlendMat.SetFloat("_ColorMulY", shaderUvRect.height);
            }

            shaderRectInited = true;
        }

        if (kinectManager && kinectManager.IsInitialized())
        {
            KinectInterop.SensorData sensorData = kinectManager.GetSensorData();

            if (sensorData != null && sensorData.depthImage != null &&
                (sensorData.colorImageTexture2D || sensorData.colorImageTexture) &&
                userBlendMat != null && lastDepthFrameTime != sensorData.lastDepthFrameTime)
            {
                lastDepthFrameTime = sensorData.lastDepthFrameTime;
                //userBlendMat.SetTexture("_ColorTex", sensorData.colorImageTexture);

                //if (kinectManager.autoHeightAngle == KinectManager.AutoHeightAngle.AutoUpdate || kinectManager.autoHeightAngle == KinectManager.AutoHeightAngle.AutoUpdateAndShowInfo)
                //{
                //	depthFactor = 1f + Mathf.Sin (Mathf.Abs (kinectManager.sensorAngle) * Mathf.Deg2Rad);
                //	userBlendMat.SetFloat("_DepthFactor", depthFactor);
                //}

                if (KinectInterop.MapColorFrameToDepthCoords(sensorData, ref color2DepthCoords))
                {
                    color2DepthBuffer.SetData(color2DepthCoords);
                }

                // buffer for depths
                for (int i = 0; i < sensorData.depthImage.Length; i++)
                {
                    ushort depth = sensorData.depthImage[i];
                    depthImageBufferData[i] = (float)depth;
                }

                depthImageBuffer.SetData(depthImageBufferData);

                // color camera texture
                Texture colorTex = backManager && sensorData.color2DepthTexture ? (Texture)sensorData.color2DepthTexture :
                                   (Texture)(sensorData.colorImageTexture2D ? sensorData.colorImageTexture2D : sensorData.colorImageTexture);
                userBlendMat.SetTexture("_ColorTex", colorTex);
            }
        }
    }
Ejemplo n.º 3
0
    // Token: 0x060000C5 RID: 197 RVA: 0x0000A3D4 File Offset: 0x000085D4
    private void Update()
    {
        bool flag = !this.shaderRectInited;

        if (flag)
        {
            PortraitBackground portraitBack = PortraitBackground.Instance;
            bool flag2 = portraitBack && portraitBack.IsInitialized();
            if (flag2)
            {
                this.shaderUvRect = portraitBack.GetShaderUvRect();
            }
            bool flag3 = this.userBlendMat != null;
            if (flag3)
            {
                this.userBlendMat.SetFloat("_ColorOfsX", this.shaderUvRect.x);
                this.userBlendMat.SetFloat("_ColorMulX", this.shaderUvRect.width);
                this.userBlendMat.SetFloat("_ColorOfsY", this.shaderUvRect.y);
                this.userBlendMat.SetFloat("_ColorMulY", this.shaderUvRect.height);
                this.userBlendMat.SetFloat("_Brightness", GlobalSettings.Brightness);
                this.userBlendMat.SetFloat("_Contrast", GlobalSettings.Contrast);
                this.userBlendMat.SetFloat("_Saturation", GlobalSettings.Saturation);
            }
            this.shaderRectInited = true;
        }
        bool flag4 = this.kinectManager && this.kinectManager.IsInitialized();

        if (flag4)
        {
            KinectInterop.SensorData sensorData = this.kinectManager.GetSensorData();
            bool flag5 = sensorData != null && sensorData.depthImage != null && (sensorData.colorImageTexture2D || sensorData.colorImageTexture) && this.userBlendMat != null && this.lastDepthFrameTime != sensorData.lastDepthFrameTime;
            if (flag5)
            {
                this.lastDepthFrameTime = sensorData.lastDepthFrameTime;
                bool flag6 = KinectInterop.MapColorFrameToDepthCoords(sensorData, ref this.color2DepthCoords);
                if (flag6)
                {
                    this.color2DepthBuffer.SetData(this.color2DepthCoords);
                }
                for (int i = 0; i < sensorData.depthImage.Length; i++)
                {
                    ushort depth = sensorData.depthImage[i];
                    this.depthImageBufferData[i] = (float)depth;
                }
                this.depthImageBuffer.SetData(this.depthImageBufferData);
                Texture colorTex = (this.backManager && sensorData.color2DepthTexture) ? sensorData.color2DepthTexture : (sensorData.colorImageTexture2D ? sensorData.colorImageTexture2D : sensorData.colorImageTexture);
                this.userBlendMat.SetTexture("_ColorTex", colorTex);
            }
        }
        this.UpdateHeadPos();
    }