// Update is called once per frame
    void Update()
    {
        // track time
        inputtime += Time.deltaTime;
        if (Input.GetKeyDown("space") || m_GripAction.GetStateDown(m_Pose.inputSource))
        {
            SceneManager.LoadScene("3DAuthenticationSchemeTappingOnly");
            started = false;
            stopped = false;
        }

        if (m_GrabAction.GetStateDown(m_Pose.inputSource) && !started)
        {
            fw.StartRecording();
            //Debug.Log("recording started");
            started = true;
            mdfw.StartRecording();
            inputtime = 0;
            mdfw.WriteToFileCsv(new DataModel(inputtime, passwordmodel.getUserInput()));
        }
        else if (m_GrabAction.GetStateDown(m_Pose.inputSource) && started && !stopped)
        {
            Debug.Log("writing");
            mdfw.WriteToFileCsv(new DataModel(inputtime, passwordmodel.getUserInput()));
        }

        if (hand.Userinput.Count == 4 && !stopped)
        {
            mdfw.WriteToFileCsv(new DataModel(inputtime, passwordmodel.getUserInput()));

            stopped = true;
            List <String> userinputStrings = new List <String>();
            foreach (var userinput in hand.Userinput)
            {
                Debug.Log(userinput);
                userinputStrings.Add(userinput.name);
                passwordmodel.backupInput(userinput.name);
            }
            //passwordmodel.checkPassword(userinputStrings);
            passwordmodel.entryError(userinputStrings);
            Debug.Log("recording stopped");
            fw.StopRecording();
            mdfw.StopRecording();

            if (passwordmodel.getErrors() == 0)
            {
                foreach (GameObject pin in GameObject.FindGameObjectsWithTag("Interactable"))
                {
                    pin.GetComponent <MeshRenderer>().material = _pincorrect;
                }
            }
            else
            {
                foreach (GameObject pin in GameObject.FindGameObjectsWithTag("Interactable"))
                {
                    pin.GetComponent <MeshRenderer>().material = _pinwrong;
                }
            }
        }
    }
    private void Update()
    {
        if (Input.inputString == "x")
        {
            fullfw.StopRecording();
            fw.StopRecording();
        }
        if ((Input.inputString == "1" || m_GripAction.GetStateDown(m_Pose.inputSource)) && stopped)
        //Input.inputString == "2" ||
        //Input.inputString == "3" ||
        //Input.inputString == "4" ||
        //Input.inputString == "5" ||
        //Input.inputString == "6")
        {
            fullfw.StopRecording();
            fw.StopRecording();
            Debug.Log(trials + "versuche");

            if (trials == 0)
            {
                GameObject.Find("Controller (left)").SetActive(false);
                return;
            }
            trials--;
            foreach (MaterialHolder materialobj in materialholderList)
            {
                //Debug.Log("test");
                // Debug.Log(materialobj.Material);
                // Debug.Log(materialobj.Gameobject);
                //Debug.Log(_pincorrect);
                materialobj.Gameobject.GetComponent <MeshRenderer>().material = materialobj.Material;
                //materialobj.Gameobject.GetComponent<MeshRenderer>().material = _pincorrect;
            }
            Init();
        }

        /* if (Input.inputString == "4") {
         *   // rotate cube
         *   // get side area (in this case left)
         *   GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(0, 270, -90);
         * }
         * if (Input.inputString == "5")
         *   {
         *   // rotate cube
         *   // get back area
         *   GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(-90, 270, -90);
         * }
         * if (Input.inputString == "6")
         *   {
         *   // rotate cube
         *   // bet bottom area
         *   GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(180, 180, 0);
         * }*/

        // track time
        inputtime     += Time.deltaTime;
        fullinputtime += Time.deltaTime;
        //if (m_GripAction.GetStateDown(m_Pose.inputSource))
        //{
        //   GameObject.Find("Planes").transform.Rotate(0, 180, 0);
        // }

        if (_eyeTracker.Connected)
        {
            var latestHitObject = _gazeTrail.LatestHitObject;
            if (latestHitObject != null && latestHitObject.name.StartsWith("POS") && m_GrabAction.GetStateDown(m_Pose.inputSource) && !stopped)
            {
                if (!started)
                { // when to start with recording by using dwell time?
                    fw.StartRecording();
                    mdfw.StartRecording();
                    started   = true;
                    inputtime = 0;
                }
                mdfw.WriteToFileCsv(new DataModel(inputtime, latestHitObject.name));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, latestHitObject.name));

                passwordmodel.backupInput(latestHitObject.name);

                selectedPINS.Add(latestHitObject.name);

                if (selectedPINS.Count == 4)
                {
                    stopped = true;

                    passwordmodel.entryError(selectedPINS);
                    mdfw.WriteToFileCsv(new DataModel(inputtime, "correct password: "******"correct password: "******"PIN"))
                    {
                        pin.GetComponent <MeshRenderer>().material = _pincorrect;
                    }
                }
                else if (selectedPINS.Count == 4)
                {
                    foreach (GameObject pin in GameObject.FindGameObjectsWithTag("PIN"))
                    {
                        pin.GetComponent <MeshRenderer>().material = _pinwrong;
                    }
                }
            }
        }
        _gazeTrail.ParticleColor = Color.blue;
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.inputString == "x")
        {
            fullfw.StopRecording();
            fw.StopRecording();
        }

        if ((Input.inputString == "1" || m_GripAction.GetStateDown(m_Pose.inputSource)) && stopped)
        //Input.inputString == "2" ||
        //Input.inputString == "3" ||
        //Input.inputString == "4" ||
        //Input.inputString == "5" ||
        //Input.inputString == "6")
        {
            fullfw.StopRecording();
            fw.StopRecording();
            Debug.Log(trials + "versuche");
            if (trials == 0)
            {
                GameObject.Find("Controller (left)").SetActive(false);
                return;
            }
            trials--;


            foreach (MaterialHolder materialobj in materialholderList)
            {
                materialobj.Gameobject.GetComponent <MeshRenderer>().material = materialobj.Material;
            }
            Init();
        }

        /*if (Input.inputString == "4")
         * {
         *  // rotate cube
         *  // get side area (in this case left)
         *  GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(0, 270, -90);
         * }
         * if (Input.inputString == "5")
         * {
         *  // rotate cube
         *  // get back area
         *  GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(-90, 270, -90);
         * }
         * if (Input.inputString == "6")
         * {
         *  // rotate cube
         *  // bet bottom area
         *  GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(180, 180, 0);
         * }*/
        // track time
        inputtime     += Time.deltaTime;
        fullinputtime += Time.deltaTime;
        // Down
        Vector3 origin    = GameObject.Find("Camera").transform.position;
        Vector3 direction = GameObject.Find("HeadPosePoint").transform.forward;

        Debug.DrawRay(origin, direction * 10f, Color.red);
        Ray ray = new Ray(origin, direction);


        //if (m_GripAction.GetStateDown(m_Pose.inputSource))
        //{
        //   GameObject.Find("Planes").transform.Rotate(0, 180, 0);
        // }
        if (Physics.Raycast(ray, out RaycastHit raycastHit))
        {
            if (m_GrabAction.GetStateDown(m_Pose.inputSource) && raycastHit.transform.tag == "Interactable" && !started && !stopped)
            {
                Debug.Log("zuhuu");
                fw.StartRecording();
                started = true;
                mdfw.StartRecording();
                inputtime = 0;
                passwordmodel.backupInput(raycastHit.transform.name);
                mdfw.WriteToFileCsv(new DataModel(inputtime, raycastHit.transform.name));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, raycastHit.transform.name));
                raycastHit.collider.GetComponent <MeshRenderer>().material = tapped;
                Userinput.Add(raycastHit.transform.gameObject);
            }
            else if (m_GrabAction.GetStateDown(m_Pose.inputSource) && raycastHit.transform.tag == "Interactable" && started && !stopped)
            {
                passwordmodel.backupInput(raycastHit.transform.name);
                raycastHit.collider.GetComponent <MeshRenderer>().material = tapped;
                Userinput.Add(raycastHit.transform.gameObject);
                mdfw.WriteToFileCsv(new DataModel(inputtime, raycastHit.transform.name));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, raycastHit.transform.name));
            }
        }



        //Up


        //workaround bug
        Debug.Log(Userinput.Count);
        if (Userinput.Count == 4 && !stopped)
        {
            stopped = true;
            List <String> userinputStrings = new List <String>();
            foreach (var userinput in Userinput)
            {
                userinputStrings.Add(userinput.name);
            }
            //passwordmodel.checkPassword(userinputStrings);
            passwordmodel.entryError(userinputStrings);
            Debug.Log("password fehler" + passwordmodel.getErrors());
            mdfw.WriteToFileCsv(new DataModel(inputtime, "correct password: "******"correct password: "******"recording stopped");
            // fw.StopRecording();
            mdfw.StopRecording();
            //fullfw.StopRecording();
            fullmdfw.StopRecording();

            if (passwordmodel.getErrors() == 0)
            {
                foreach (GameObject pin in GameObject.FindGameObjectsWithTag("Interactable"))
                {
                    pin.GetComponent <MeshRenderer>().material = _pincorrect;
                }
            }
            else
            {
                foreach (GameObject pin in GameObject.FindGameObjectsWithTag("Interactable"))
                {
                    pin.GetComponent <MeshRenderer>().material = _pinwrong;
                }
            }
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.inputString == "x")
        {
            fullfw.StopRecording();
            fw.StopRecording();
        }

        if ((Input.inputString == "1" || m_GripAction.GetStateDown(m_Pose.inputSource)) && stopped)
        //Input.inputString == "2" ||
        //Input.inputString == "3" ||
        //Input.inputString == "4" ||
        //Input.inputString == "5" ||
        //Input.inputString == "6")
        {
            fullfw.StopRecording();
            fw.StopRecording();
            Debug.Log(trials + "versuche");
            if (trials == 0)
            {
                GameObject.Find("Controller (left)").SetActive(false);
                return;
            }
            trials--;

            //if (!stopped)
            // {
            //    mdfw.StopRecording();
            //     fullmdfw.StopRecording();
            //    stopped = true;
            // }
            //SceneManager.LoadScene("3DAuthenticationSchemeGazeTrigger");

            foreach (MaterialHolder materialobj in materialholderList)
            {
                //Debug.Log("test");
                // Debug.Log(materialobj.Material);
                // Debug.Log(materialobj.Gameobject);
                //Debug.Log(_pincorrect);
                materialobj.Gameobject.GetComponent <MeshRenderer>().material = materialobj.Material;
                //materialobj.Gameobject.GetComponent<MeshRenderer>().material = _pincorrect;
            }
            Init();
        }

        /*if (Input.inputString == "4")
         * {
         *  // rotate cube
         *  // get side area (in this case left)
         *  GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(0, 270, -90);
         * }
         * if (Input.inputString == "5")
         * {
         *  // rotate cube
         *  // get back area
         *  GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(-90, 270, -90);
         * }
         * if (Input.inputString == "6")
         * {
         *  // rotate cube
         *  // bet bottom area
         *  GameObject.Find("Planes").transform.localRotation = Quaternion.Euler(180, 180, 0);
         * } */
        // track time
        inputtime     += Time.deltaTime;
        fullinputtime += Time.deltaTime;

        //if (m_GripAction.GetStateDown(m_Pose.inputSource))
        //{
        //   GameObject.Find("Planes").transform.Rotate(0, 180, 0);
        // }
        // Down
        if (m_GrabAction.GetStateDown(m_Pose.inputSource) && !started && !stopped)
        {
            if (current != null && GetNearestGameObject() != null)
            {
                fw.StartRecording();
                //Debug.Log("recording started");
                started = true;
                mdfw.StartRecording();
                inputtime = 0;
                passwordmodel.backupInput(GetNearestGameObject().name);
                mdfw.WriteToFileCsv(new DataModel(inputtime, GetNearestGameObject().name));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, GetNearestGameObject().name));
                GetNearestGameObject().GetComponent <MeshRenderer>().material = tapped;
                Userinput.Add(GetNearestGameObject());
            }

            //call method Input();
            //Pickup();
        }


        //Up
        else if (m_GrabAction.GetStateDown(m_Pose.inputSource) && started && !stopped)
        {
            if (current != null && GetNearestGameObject() != null)
            {
                passwordmodel.backupInput(GetNearestGameObject().name);

                GetNearestGameObject().GetComponent <MeshRenderer>().material = tapped;
                Userinput.Add(GetNearestGameObject());
                mdfw.WriteToFileCsv(new DataModel(inputtime, GetNearestGameObject().name));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, GetNearestGameObject().name));
            }
        }

        //workaround bug
        Debug.Log(Userinput.Count);
        if (Userinput.Count == 4 && !stopped)
        {
            stopped = true;
            List <String> userinputStrings = new List <String>();
            foreach (var userinput in Userinput)
            {
                userinputStrings.Add(userinput.name);
            }
            //passwordmodel.checkPassword(userinputStrings);
            passwordmodel.entryError(userinputStrings);
            mdfw.WriteToFileCsv(new DataModel(inputtime, "correct password: "******"correct password: "******"recording stopped");
            // fw.StopRecording();
            mdfw.StopRecording();
            //fullfw.StopRecording();
            fullmdfw.StopRecording();

            if (passwordmodel.getErrors() == 0)
            {
                foreach (GameObject pin in GameObject.FindGameObjectsWithTag("Interactable"))
                {
                    pin.GetComponent <MeshRenderer>().material = _pincorrect;
                }
            }
            else
            {
                foreach (GameObject pin in GameObject.FindGameObjectsWithTag("Interactable"))
                {
                    pin.GetComponent <MeshRenderer>().material = _pinwrong;
                }
            }
        }
    }
    private void Update()
    {
        if (!started && triggerScript.getStatusTriggerRight())
        {
            Debug.Log("recording started");
            fw.StartRecording();
            started = true;
        }
        if (newtrial)
        {
            // reset all variables from the old trial
            for (int i = 0; i <= feedbackmodel.Count - 1; i++)
            {
                feedbackmodel[i].Gameobject.GetComponent <MeshRenderer>().enabled = false;
            }

            feedbackmodel = new List <FeedbackModel>();
            //passwordmodel = new PasswordModel(new List<String>() { "POS1", "POS2", "POS3", "POS4" }, 4);
            userPassword.Clear();
            if (trials <= 7)
            {
                // rotate back to original position

                trials++;
                newtrial = false;
            }
            else if (trials == 8)
            {
                GameObject.Find("tiger_idle").transform.Rotate(0, 90, 0);
                trials++;
                newtrial = false;
            }
            else if (trials == 9)
            {
                GameObject.Find("tiger_idle").transform.Rotate(0, 270, 0);
                trials++;
                newtrial = false;
            }
            else if (trials == 10)
            {
                GameObject.Find("tiger_idle").transform.Rotate(0, 180, 0);
                trials++;
                newtrial = false;
            }
            else
            {
                SceneManager.LoadScene(sceneName: "playground");
            }
        }
        // show 3D model and start recording (see DataHandler)
        if (Input.GetKeyDown(KeyCode.R))
        {
            newtrial = true;
            //Debug.Log("lets go");
            GameObject.Find("Tiger_Mesh").GetComponent <SkinnedMeshRenderer>().enabled = true;
            GameObject.Find("Collider").SetActive(true);
        }
        //current_time += Time.deltaTime;
        if (feedbackmodel.Count >= 0)
        {
            for (int i = 0; i <= feedbackmodel.Count - 1; i++)
            {
                feedbackmodel[i].Time -= Time.deltaTime;
                if (feedbackmodel[i].Time <= 0)
                {
                    feedbackmodel[i].Gameobject.GetComponent <MeshRenderer>().enabled = false;
                    feedbackmodel.RemoveAt(i);
                }
            }
        }

        //if (triggerScript.getStatusTriggerLeft())
        //{
        //Debug.Log("rotate graphical password");
        //  GameObject.Find("tiger_idle").transform.Rotate(0, 90, 0);
        // }


        if (_eyeTracker.Connected)
        {
            // Reset any priviously set active object and remove its highlight
            if (_highlightInfo.HighlightedObject != null)
            {
                var renderer = _highlightInfo.HighlightedObject.GetComponent <MeshRenderer>();
                _highlightInfo.HighlightedObject      = null;
                _highlightInfo.OriginalObjectMaterial = null;
            }
            var latestHitObject = _gazeTrail.LatestHitObject;
            if (latestHitObject != null)
            {
                if (latestHitObject.gameObject != _highlightInfo.HighlightedObject &&
                    latestHitObject.name.StartsWith("POS") && triggerScript.getStatusTriggerRight())

                {
                    feedbackmodel.Add(new FeedbackModel(latestHitObject.gameObject, latestHitObject.gameObject.GetComponent <MeshRenderer>().material, feedback_time));
                    passwordmodel.backupInput(latestHitObject.gameObject.name);
                    // Debug.Log("selected via gaze and trigger");
                    MeshRenderer renderer = latestHitObject.gameObject.GetComponent <MeshRenderer>();
                    renderer.enabled  = true;
                    renderer.material = _highlightMaterial;

                    userPassword.Add(latestHitObject.name);
                    // Debug.Log(latestHitObject.name);

                    if (userPassword.Count == 4)
                    {
                        Debug.Log("recording stopped");

                        fw.StopRecording();
                        Debug.Log("ok count 4");
                        Debug.Log(userPassword[0]);
                        Debug.Log(userPassword[1]);
                        Debug.Log(userPassword[2]);
                        Debug.Log(userPassword[3]);

                        PINS = GameObject.FindGameObjectsWithTag("PIN");
                        if (passwordmodel.checkPassword(userPassword))
                        {
                            Debug.Log("correct");
                            for (int i = 0; i <= PINS.Length - 1; i++)
                            {
                                PINS[i].GetComponent <MeshRenderer>().enabled = true;

                                PINS[i].GetComponent <MeshRenderer>().material = _inputcorrect;
                            }
                        }
                        else
                        {
                            Debug.Log("feedback wrong");

                            for (int i = 0; i <= PINS.Length - 1; i++)
                            {
                                PINS[i].GetComponent <MeshRenderer>().enabled = true;

                                PINS[i].GetComponent <MeshRenderer>().material = _inputwrong;
                            }
                        }

                        passwordmodel.entryError(userPassword);
                        manouver_time -= Time.deltaTime;
                        if (manouver_time <= 0)
                        {
                            newtrial      = true;
                            manouver_time = 2;
                        }
                        // Debug.Log("new run");
                        //Debug.Log("number of errors " + passwordmodel.getErrors());
                        // Debug.Log(passwordmodel.checkPassword(userPassword));
                    }
                }
                _gazeTrail.ParticleColor = Color.blue;
            }
        }
    }
    private void Update()
    {
        if (m_GripAction.GetStateDown(m_Pose.inputSource))
        {
            trials++;

            foreach (MaterialHolder materialobj in materialholderList)
            {
                materialobj.Gameobject.GetComponent <MeshRenderer>().material = materialobj.Material;
            }
            Init();
        }

        if (Input.inputString == "e" ||
            Input.inputString == "m" ||
            Input.inputString == "s")
        {
            trials = 1;
            foreach (GameObject pin in GameObject.FindGameObjectsWithTag("PIN"))
            {
                pin.GetComponent <MeshRenderer>().enabled = true;
            }

            Canvas weakpw   = GameObject.Find("weakpw").GetComponent <Canvas>();
            Canvas mediumpw = GameObject.Find("mediumpw").GetComponent <Canvas>();
            Canvas strongpw = GameObject.Find("strongpw").GetComponent <Canvas>();


            // toggle display instruction
            //fullfw.StopRecording();
            fullmdfw.StopRecording();
            foreach (MaterialHolder materialobj in materialholderList)
            {
                materialobj.Gameobject.GetComponent <MeshRenderer>().material = materialobj.Material;
            }

            if (Input.inputString == "e")
            {
                weakpw.enabled   = true;
                mediumpw.enabled = false;
                strongpw.enabled = false;
                security         = "weak";
            }
            else if (Input.inputString == "m")
            {
                weakpw.enabled   = false;
                mediumpw.enabled = true;
                strongpw.enabled = false;
                security         = "medium";
            }
            else if (Input.inputString == "s")
            {
                weakpw.enabled   = false;
                mediumpw.enabled = false;
                strongpw.enabled = true;
                security         = "strong";
            }
            Init();
        }

        // track time
        inputtime     += Time.deltaTime;
        fullinputtime += Time.deltaTime;
        Vector3 origin = GameObject.Find("Camera").transform.position;

        //Debug.Log(origin);
        //Debug.Log("direction "+direction);
        var latestHitObject = _gazeTrail.LatestHitObject;

        if (latestHitObject != null && latestHitObject.name.StartsWith("POS") && m_GrabAction.GetStateDown(m_Pose.inputSource) && !stopped && GlobalHandler.modality == 0)
        {
            if (!started)
            { // when to start with recording by using dwell time?
                //fw.StartRecording();
                mdfw.StartRecording();
                started   = true;
                inputtime = 0;
            }
            mdfw.WriteToFileCsv(new DataModel(inputtime, latestHitObject.name));
            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, latestHitObject.name));

            passwordmodel.backupInput(latestHitObject.name);

            selectedPINS.Add(latestHitObject.name);
            if (selectedPINS.Count == 4)
            {
                passwordmodel.entryError(selectedPINS);
                if (passwordmodel.getErrors() == 0)
                {
                    mdfw.WriteToFileCsv(new DataModel(inputtime, security + " correct"));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " correct"));
                }
                else
                {
                    mdfw.WriteToFileCsv(new DataModel(inputtime, security + " incorrect"));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " incorrect"));
                }
                mdfw.WriteToFileCsv(new DataModel(inputtime, "trial: " + trials));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, "trial: " + trials));

                mdfw.StopRecording();
                fullmdfw.StopRecording();
                // fw.StopRecording();
                //fullfw.StopRecording();
            }
            feedbackElements.Add(new FeedbackModel(latestHitObject.gameObject, latestHitObject.gameObject.GetComponent <MeshRenderer>().material, feedbacktime));
            MeshRenderer renderer = latestHitObject.gameObject.GetComponent <MeshRenderer>();
            renderer.material = _pinhighlight;
        }
        else if (m_GrabAction.GetStateDown(m_Pose.inputSource) && !started && !stopped && current != null && GetNearestGameObject() != null && GlobalHandler.modality == 2)
        {
            //fw.StartRecording();
            //Debug.Log("recording started");
            started = true;
            mdfw.StartRecording();
            inputtime = 0;
            passwordmodel.backupInput(GetNearestGameObject().name);
            selectedPINS.Add(GetNearestGameObject().name);
            mdfw.WriteToFileCsv(new DataModel(inputtime, GetNearestGameObject().name));
            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, GetNearestGameObject().name));
            if (selectedPINS.Count == 4)
            {
                passwordmodel.entryError(selectedPINS);
                if (passwordmodel.getErrors() == 0)
                {
                    mdfw.WriteToFileCsv(new DataModel(inputtime, security + " correct"));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " correct"));
                }
                else
                {
                    mdfw.WriteToFileCsv(new DataModel(inputtime, security + " incorrect"));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " incorrect"));
                }
                mdfw.WriteToFileCsv(new DataModel(inputtime, "trial: " + trials));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, "trial: " + trials));

                mdfw.StopRecording();
                fullmdfw.StopRecording();
                // fw.StopRecording();
                //fullfw.StopRecording();
            }
            feedbackElements.Add(new FeedbackModel(GetNearestGameObject(), GetNearestGameObject().GetComponent <MeshRenderer>().material, feedbacktime));
            MeshRenderer renderer = GetNearestGameObject().GetComponent <MeshRenderer>();
            renderer.material = _pinhighlight;
            Userinput.Add(GetNearestGameObject());


            //call method Input();
            //Pickup();
        }


        //Up
        else if (m_GrabAction.GetStateDown(m_Pose.inputSource) && started && !stopped && current != null && GetNearestGameObject() != null && GlobalHandler.modality == 2)
        {
            passwordmodel.backupInput(GetNearestGameObject().name);
            feedbackElements.Add(new FeedbackModel(GetNearestGameObject(), GetNearestGameObject().GetComponent <MeshRenderer>().material, feedbacktime));
            MeshRenderer renderer = GetNearestGameObject().GetComponent <MeshRenderer>();
            renderer.material = _pinhighlight;
            Userinput.Add(GetNearestGameObject());
            selectedPINS.Add(GetNearestGameObject().name);
            mdfw.WriteToFileCsv(new DataModel(inputtime, GetNearestGameObject().name));
            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, GetNearestGameObject().name));
            if (selectedPINS.Count == 4)
            {
                passwordmodel.entryError(selectedPINS);
                if (passwordmodel.getErrors() == 0)
                {
                    mdfw.WriteToFileCsv(new DataModel(inputtime, security + " correct"));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " correct"));
                }
                else
                {
                    mdfw.WriteToFileCsv(new DataModel(inputtime, security + " incorrect"));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " incorrect"));
                }
                mdfw.WriteToFileCsv(new DataModel(inputtime, "trial: " + trials));
                fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, "trial: " + trials));
                mdfw.StopRecording();
                fullmdfw.StopRecording();
                //fw.StopRecording();
                // fullfw.StopRecording();
            }
        }
        else if (GameObject.Find("HeadPosePoint") != null)
        {
            Vector3 direction = GameObject.Find("HeadPosePoint").transform.forward;
            Debug.DrawRay(origin, direction * 10f, Color.red);
            Ray ray = new Ray(origin, direction);

            if (Physics.Raycast(ray, out RaycastHit raycastHit) && GlobalHandler.modality == 1)
            {
                if (m_GrabAction.GetStateDown(m_Pose.inputSource) && raycastHit.transform.tag == "PIN" && !stopped)
                {
                    Debug.Log("ok this is fine");

                    if (!started)
                    {
                        // fw.StartRecording();
                        mdfw.StartRecording();
                        started   = true;
                        inputtime = 0;
                    }

                    passwordmodel.backupInput(raycastHit.transform.name);
                    selectedPINS.Add(raycastHit.transform.name);
                    mdfw.WriteToFileCsv(new DataModel(inputtime, raycastHit.transform.name));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, raycastHit.transform.name));
                    if (selectedPINS.Count == 4)
                    {
                        passwordmodel.entryError(selectedPINS);
                        if (passwordmodel.getErrors() == 0)
                        {
                            mdfw.WriteToFileCsv(new DataModel(inputtime, security + " correct"));
                            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " correct"));
                        }
                        else
                        {
                            mdfw.WriteToFileCsv(new DataModel(inputtime, security + " incorrect"));
                            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " incorrect"));
                        }
                        mdfw.WriteToFileCsv(new DataModel(inputtime, "trial: " + trials));
                        fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, "trial: " + trials));

                        mdfw.StopRecording();
                        fullmdfw.StopRecording();
                        // fw.StopRecording();
                        // fullfw.StopRecording();
                    }
                    feedbackElements.Add(new FeedbackModel(raycastHit.collider.gameObject, raycastHit.collider.GetComponent <MeshRenderer>().material, feedbacktime));
                    MeshRenderer renderer = raycastHit.collider.gameObject.GetComponent <MeshRenderer>();
                    renderer.material = _pinhighlight;
                    Userinput.Add(raycastHit.transform.gameObject);
                }
                else if (m_GrabAction.GetStateDown(m_Pose.inputSource) && raycastHit.transform.tag == "PIN" && started && !stopped)
                {
                    //Debug.Log("HALLOOOOOOOOOOOOO");
                    selectedPINS.Add(raycastHit.transform.name);

                    passwordmodel.backupInput(raycastHit.transform.name);
                    feedbackElements.Add(new FeedbackModel(raycastHit.collider.gameObject, raycastHit.collider.GetComponent <MeshRenderer>().material, feedbacktime));
                    MeshRenderer renderer = raycastHit.collider.gameObject.GetComponent <MeshRenderer>();
                    renderer.material = _pinhighlight;
                    Userinput.Add(raycastHit.transform.gameObject);
                    mdfw.WriteToFileCsv(new DataModel(inputtime, raycastHit.transform.name));
                    fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, raycastHit.transform.name));
                    if (selectedPINS.Count == 4)
                    {
                        if (passwordmodel.getErrors() == 0)
                        {
                            mdfw.WriteToFileCsv(new DataModel(inputtime, security + " correct"));
                            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " correct"));
                        }
                        else
                        {
                            mdfw.WriteToFileCsv(new DataModel(inputtime, security + " incorrect"));
                            fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, security + " incorrect"));
                        }
                        passwordmodel.entryError(selectedPINS);

                        mdfw.WriteToFileCsv(new DataModel(inputtime, "trial: " + trials));
                        fullmdfw.WriteToFileCsv(new DataModel(fullinputtime, "trial: " + trials));

                        mdfw.StopRecording();
                        fullmdfw.StopRecording();
                        // fw.StopRecording();
                        // fullfw.StopRecording();
                    }
                }
            }
        }
        Debug.Log(selectedPINS);
        Debug.Log(passwordmodel.getErrors());
        if (passwordmodel.getErrors() == 0 && selectedPINS.Count == 4)
        {
            foreach (GameObject pin in GameObject.FindGameObjectsWithTag("PIN"))
            {
                pin.GetComponent <MeshRenderer>().material = _pincorrect;
            }
        }
        else if (selectedPINS.Count == 4)
        {
            foreach (GameObject pin in GameObject.FindGameObjectsWithTag("PIN"))
            {
                pin.GetComponent <MeshRenderer>().material = _pinwrong;
            }
        }
        if (feedbackElements != null)
        {
            foreach (FeedbackModel element in feedbackElements.ToArray())
            {
                element.Time -= Time.deltaTime;
                //Debug.Log("element time" + element.Time);
                if (element.Time <= 0 && selectedPINS.Count != 4)
                {
                    element.Gameobject.GetComponent <MeshRenderer>().material = element.Material;
                    feedbackElements.Remove(element);
                }
            }
        }


        _gazeTrail.ParticleColor = Color.blue;
    }