Пример #1
0
    void OnNewFrame(VideoPlayer source, long frameIdx)
    {
        if (!_playing || _videoSeekActive)
        {
            return;
        }

        _depthStreamDone = !_decoder.DecompressRVL(_depthBytes, _width * _height);
        if (!_depthStreamDone)
        {
            _depthTex.LoadRawTextureData(_depthBytes);
        }
        else
        {
            return;
        }


        _depthTex.Apply();
        MeshRenderer[] renderers = GetComponentsInChildren <MeshRenderer>();
        for (int i = 0; i < renderers.Length; i++)
        {
            MeshRenderer mr = renderers[i];
            mr.material.SetTexture("_DepthTex", _depthTex);
            mr.material.SetFloat("_Brightness", brightness);
        }
        if (_rendering)
        {
            show();
        }
    }
Пример #2
0
    public void setPoints(byte[] colorBytes, byte[] depthBytes, bool compressed, int sizec, int scale)
    {
        if (scale != _texScale)
        {
            _texScale = scale;
            _width    = Mathf.CeilToInt(512.0f / scale);
            _height   = Mathf.CeilToInt(424.0f / scale);
            initStructs();
        }

        if (compressed)
        {
            bool ok = _decoder.DecompressRVL(depthBytes, _depthBytes, _width * _height);
            _colorDecoder.Decompress(colorBytes, colorBytes, sizec);
            if (ok)
            {
                _depthTex.LoadRawTextureData(_depthBytes);
                _colorTex.LoadRawTextureData(colorBytes);
            }
        }
        else
        {
            _depthTex.LoadRawTextureData(depthBytes);
            _colorTex.LoadRawTextureData(colorBytes);
        }
        _colorTex.Apply();
        _depthTex.Apply();



        MeshRenderer[] renderers = GetComponentsInChildren <MeshRenderer>();
        for (int i = 0; i < renderers.Length; i++)
        {
            MeshRenderer mr = renderers[i];
            mr.material.SetInt("_TexScale", _texScale);
            mr.material.SetTexture("_ColorTex", _colorTex);
            mr.material.SetTexture("_DepthTex", _depthTex);
            mr.material.SetFloat("_sigmaS", sigmaS);
            mr.material.SetFloat("_sigmaS", sigmaS);
            mr.material.SetInt("_SizeFilter", medianFilterSize);
            mr.material.SetInt("_calculateNormals", calculateNormals? 1:0);



            //mr.material.SetInt("_LeftWarping", wi.leftWarping ? 1 : 0);
            //mr.material.SetInt("_RightWarping", wi.rightWarping ? 1 : 0);
            //mr.material.SetFloat("_Distance", 0.5f);

            //mr.material.SetVector("_LEFT_OriginalShoulder", wi.LEFT_OriginalShoulder);
            //mr.material.SetVector("_LEFT_OriginalElbow", wi.LEFT_OriginalElbow);
            //mr.material.SetVector("_LEFT_OriginalWrist", wi.LEFT_OriginalWrist);
            //mr.material.SetVector("_LEFT_OriginalHandTip", wi.LEFT_OriginalHandTip);

            //mr.material.SetVector("_RIGHT_OriginalShoulder", wi.RIGHT_OriginalShoulder);
            //mr.material.SetVector("_RIGHT_OriginalElbow", wi.RIGHT_OriginalElbow);
            //mr.material.SetVector("_RIGHT_OriginalWrist", wi.RIGHT_OriginalWrist);
            //mr.material.SetVector("_RIGHT_OriginalHandTip", wi.RIGHT_OriginalHandTip);
        }
    }
Пример #3
0
    public void setPoints(byte[] colorBytes, byte[] depthBytes, bool compressed, int sizec, int scale)
    {
        if (scale != _texScale)
        {
            _texScale = scale;
            _width    = Mathf.CeilToInt(512.0f / scale);
            _height   = Mathf.CeilToInt(424.0f / scale);
            initStructs();
        }

        if (compressed)
        {
            bool ok = _decoder.DecompressRVL(depthBytes, _depthBytes, _width * _height);
            _colorDecoder.Decompress(colorBytes, colorBytes, sizec);
            if (ok)
            {
                _depthTex.LoadRawTextureData(_depthBytes);
                _colorTex.LoadRawTextureData(colorBytes);
            }
        }
        else
        {
            _depthTex.LoadRawTextureData(depthBytes);
            _colorTex.LoadRawTextureData(colorBytes);
        }
        _colorTex.Apply();
        _depthTex.Apply();
        MeshRenderer[] renderers = GetComponentsInChildren <MeshRenderer>();
        for (int i = 0; i < renderers.Length; i++)
        {
            MeshRenderer mr = renderers[i];
            mr.material.SetInt("_TexScale", _texScale);
            mr.material.SetTexture("_ColorTex", _colorTex);
            mr.material.SetTexture("_DepthTex", _depthTex);
            mr.material.SetFloat("_sigmaS", sigmaS);
            mr.material.SetFloat("_sigmaS", sigmaS);
            mr.material.SetInt("_SizeFilter", medianFilterSize);
            mr.material.SetInt("_calculateNormals", calculateNormals? 1:0);
            mr.material.SetInt("_hide", _hide ? 1 : 0);
        }
    }