Ejemplo n.º 1
0
    public void setPointsUncompressed(byte[] colorBytes, byte[] depthBytes)
    {
        _depthTex.LoadRawTextureData(depthBytes);
        _colorTex.LoadRawTextureData(colorBytes);

        _colorTex.Apply();
        _depthTex.Apply();

        BodiesManager b  = GameObject.Find(_local ? "LocalBodiesManager" : "RemoteBodiesManager").GetComponent <BodiesManager>();
        IKWarpInfo    wi = b.armsWarpInfo;



        try
        {
            //Body b = GameObject.Find("BodiesManager").GetComponent<BodiesManager>().human.body;

            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("_Warping",  0);

                mr.material.SetInt("_RemoveHead", wi.removeHead ? 1 : 0);
                mr.material.SetVector("_VRHead", wi.VRHead);
                mr.material.SetFloat("_HeadSize", wi.headSize);
                mr.material.SetFloat("_Y_HeadOffset", wi.Y_HeadOffset);

                if (!_local)
                {
                    //mr.material.SetInt("_LeftWarping", wi.leftWarping ? 1 : 0);
                    //mr.material.SetInt("_RightWarping", wi.rightWarping ? 1 : 0);
                    mr.material.SetInt("_LeftWarping", 1);
                    mr.material.SetInt("_RightWarping", 1);

                    mr.material.SetInt("_Debug", wi.debug ? 1 : 0);

                    mr.material.SetFloat("_tabley", b.table.position.y);

                    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);

                    mr.material.SetMatrix("_LEFT_UpperArmMatrix", wi.LEFT_UpperArmMatrix);
                    mr.material.SetMatrix("_LEFT_ForearmMatrix", wi.LEFT_ForearmMatrix);
                    mr.material.SetMatrix("_LEFT_HandMatrix", wi.LEFT_HandMatrix);

                    mr.material.SetMatrix("_RIGHT_UpperArmMatrix", wi.RIGHT_UpperArmMatrix);
                    mr.material.SetMatrix("_RIGHT_ForearmMatrix", wi.RIGHT_ForearmMatrix);
                    mr.material.SetMatrix("_RIGHT_HandMatrix", wi.RIGHT_HandMatrix);

                    //////// BODY
                    mr.material.SetVector("head", b.head.position);
                    mr.material.SetVector("neck", b.head.position);
                    mr.material.SetVector("spineShoulder", b.spineShoulder.position);
                    mr.material.SetVector("spineMid", b.spineMid.position);
                    mr.material.SetVector("spineBase", b.spineBase.position);
                    mr.material.SetVector("leftShoulder", wi.LEFT_OriginalShoulder);
                    mr.material.SetVector("leftElbow", wi.LEFT_OriginalElbow);
                    mr.material.SetVector("leftWrist", wi.LEFT_OriginalWrist);
                    mr.material.SetVector("leftHand", b.leftHand.position);
                    mr.material.SetVector("leftThumb", b.leftThumb.position);
                    mr.material.SetVector("leftHandTip", wi.LEFT_OriginalHandTip);
                    mr.material.SetVector("leftHip", b.leftHip.position);
                    mr.material.SetVector("leftKnee", b.leftKnee.position);
                    mr.material.SetVector("leftAnkle", b.leftAnkle.position);
                    mr.material.SetVector("leftFoot", b.leftFoot.position);
                    mr.material.SetVector("rightShoulder", wi.RIGHT_OriginalShoulder);
                    mr.material.SetVector("rightElbow", wi.RIGHT_OriginalElbow);
                    mr.material.SetVector("rightWrist", wi.RIGHT_OriginalWrist);
                    mr.material.SetVector("rightHand", b.rightHand.position);
                    mr.material.SetVector("rightThumb", b.rightThumb.position);
                    mr.material.SetVector("rightHandTip", wi.RIGHT_OriginalHandTip);
                    mr.material.SetVector("rightHip", b.rightHip.position);
                    mr.material.SetVector("rightKnee", b.rightKnee.position);
                    mr.material.SetVector("rightAnkle", b.rightAnkle.position);
                    mr.material.SetVector("rightFoot", b.rightFoot.position);
                    mr.material.SetVector("LEGBONE", b.LEGBONE.position);
                }
            }
        }
        catch
        {
            print("no body");
        }
    }
Ejemplo n.º 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();

        IKWarpInfo wi = GameObject.Find("RemoteBodiesManager").GetComponent <BodiesManager>().armsWarpInfo;

        //Body b = GameObject.Find("RemoteBodiesManager").GetComponent<BodiesManager>().human.body;

        print("points???");

        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);
        }
    }