public void SetRightEye()
 {
     autoEye = false;
     openEye = OpenEye.Right;
 }
    void FaceUpdated(ARFaceAnchor anchorData)
    {
        Vector3    pos = UnityARMatrixOps.GetPosition(anchorData.transform);
        Quaternion rot = UnityARMatrixOps.GetRotation(anchorData.transform);

        if (camManager.DeviceCamUsed)
        {
            headCenter.transform.position = pos;             // in device cam viewing mode, don't invert on x because this view is mirrored
            headCenter.transform.rotation = rot;
        }
        else
        {
            // invert on x because ARfaceAnchors are inverted on x (to mirror in display)
            headCenter.transform.position = new Vector3(-pos.x, pos.y, pos.z);
            headCenter.transform.rotation = new Quaternion(-rot.x, rot.y, rot.z, -rot.w);
        }

        currentBlendShapes = anchorData.blendShapes;

        if (autoEye)
        {
            if (currentBlendShapes.ContainsKey("eyeBlink_L"))                // of course, eyeBlink_L refers to the RIGHT eye! (mirrored geometry)
            {
                rightEyeClosed = currentBlendShapes ["eyeBlink_L"];
            }

            if (currentBlendShapes.ContainsKey("eyeBlink_R"))
            {
                leftEyeClosed = currentBlendShapes ["eyeBlink_R"];
            }

            //string str = string.Format ("L={0:#.##} R={1:#.##}", leftEyeClosed, rightEyeClosed);
            //eyeInfoText = str;

            // these values seem to be in the 0.2 .. 0.7 range..
            // but sometimes, when viewing the phone low in the visual field, they get very high even while open (eyelids almost close)
            // we'll use a difference metric and if exceeded we select the most open eye

            if (Mathf.Abs(rightEyeClosed - leftEyeClosed) > 0.2f)
            {
                if (rightEyeClosed > leftEyeClosed)
                {
                    openEye = OpenEye.Left;
                }
                else
                {
                    openEye = OpenEye.Right;
                }
            }

            /* // old method
             * if (rightEyeClosed > 0.5 && leftEyeClosed < 0.5)
             *      openEye = OpenEye.Left;
             *
             * if (rightEyeClosed < 0.5 && leftEyeClosed > 0.5)
             *      openEye = OpenEye.Right;*/
        }

        string str;

        if (openEye == OpenEye.Left)
        {
            str = "Left Eye";
        }
        else
        {
            str = "Right Eye";
        }

        if (autoEye)
        {
            eyeInfoText = "Auto: " + str;
        }
        else
        {
            eyeInfoText = str;
        }
    }
 public void SetLeftEye()
 {
     autoEye = false;
     openEye = OpenEye.Left;
 }