// returns the depth map position for a 3d joint position
    public Vector2 GetDepthMapPosForJointPos(Vector3 posJoint)
    {
        Vector3 vDepthPos = KinectWrapper.MapSkeletonPointToDepthPoint(posJoint);
        Vector2 vMapPos   = new Vector2(vDepthPos.x, vDepthPos.y);

        return(vMapPos);
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (!manager.IsInitialized())
        {
            return;
        }

        Texture2D kinectTexture2D = manager.GetUsersLblTex();

        tmp.SetPixels32(kinectTexture2D.GetPixels32());
        tmp.Apply();


        uint player1 = manager.GetPlayer1ID();

        if (manager.IsJointTracked(player1, (int)KinectWrapper.NuiSkeletonPositionIndex.Head))
        {
            Vector3 headPosition =
                KinectWrapper.MapSkeletonPointToDepthPoint(manager.GetRawSkeletonJointPos(player1,
                                                                                          (int)KinectWrapper.NuiSkeletonPositionIndex.Head));
            for (int x = 0, i = -((int)headTexture.width / 2);
                 i < headTexture.width / 2 && x < headTexture.width;
                 ++i, ++x)
            {
                for (int y = 0, j = -((int)headTexture.height / 2);
                     j < headTexture.height / 2 && y < headTexture.height;
                     ++j, ++y)
                {
                    headTexture.SetPixel(x, y, tmp.GetPixel((int)headPosition.x + i, (int)headPosition.y + j));
                }
            }

            headTexture.Apply();
            Controller.FaceTexture2D = headTexture;
            Texture2D test = new Texture2D(headTexture.width, headTexture.height);
            test.LoadImage(headTexture.EncodeToPNG());
            GuiTexture.texture = test;
        }
    }