Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (!answered)
        {
            deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
            float fps = 1.0f / deltaTime;
            //Debug.Log(fps);
            fpsColl.Add(fps);
        }

        // Can't do it at start or I'd have a race condition
        if (runCount == 0)
        {
            currRes = Pop(resolutions);
            if (leftEye != null && rightEye != null)
            {
                leftEye.SetResolution(currRes);
                rightEye.SetResolution(currRes);
            }
            // sets
            sw.WriteLine("\t\t\t{");
            sw.WriteLine("\t\t\t\t\"resolution\" : \"" + currRes.x.ToString() + "/" + currRes.y.ToString() + "\",");
            sw.WriteLine("\t\t\t\t\"runs\" : [");
            runCount++;
            // not ready to start yet
            leftEye.SetBlackening(true);
            rightEye.SetBlackening(true);
        }

        if (!readyToStart)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                begin        = System.DateTime.Now;
                readyToStart = true;
                leftEye.SetBlackening(false);
                rightEye.SetBlackening(false);

                //timeout = false;
                //timer = Timeout((float)timeLimit);
                //StartCoroutine(timer);

                controlCam.transform.Find("Canvas").Find("Text").GetComponent <Text>().text = "";
            }
        }
        else
        {
            // Time's up

            /*
             * if(timeout && !answered) {
             *      end = System.DateTime.Now;
             *      elapsed = (end - begin).ToString();
             *      string[] tmp = elapsed.Split(':');
             *      elapsed = tmp[1] + ":" + tmp[2].Substring(0, 6);
             *
             *      leftEye.SetBlackening(true);
             *      rightEye.SetBlackening(true);
             *
             *      //StopCoroutine(timer);
             * }*/

            // "Answer button". Can compare to zero because of dead zone.
            if (Input.GetAxis("Confirm") != 0 && !answered)
            {
                answered = true;
                end      = System.DateTime.Now;
                elapsed  = (end - begin).ToString();
                string[] tmp = elapsed.Split(':');
                elapsed = tmp[1] + ":" + tmp[2].Substring(0, 6);
                controlCam.transform.Find("Canvas").Find("Text").GetComponent <Text>().text = "Press Y if CORRECT,\nN if WRONG";

                leftEye.SetBlackening(true);
                rightEye.SetBlackening(true);
            }

            // To change the resolution: get the script and add a counter in module. Possibly group words under resolution.
            // HOWEVER, first I need some more props.
            if (((Input.GetKeyDown(KeyCode.Y) || Input.GetKeyDown(KeyCode.N)) && answered))
            {
                //begin = System.DateTime.Now;
                answered = false;
                // item
                sw.WriteLine("\t\t\t\t\t{");
                sw.WriteLine("\t\t\t\t\t\t\"name\" : \"" + targetText.text + "\",");
                sw.WriteLine("\t\t\t\t\t\t\"result\" : \"" + (Input.GetKeyDown(KeyCode.Y) ? "CORRECT" : "WRONG") + "\",");
                sw.WriteLine("\t\t\t\t\t\t\"elapsed\" : \"" + elapsed + "\",");
                sw.WriteLine("\t\t\t\t\t\t\"angle\" : \"" + fixedAngle + "\"");
                if ((runCount) % (runsPerRes * runsPerAngle) != 0)
                {
                    sw.WriteLine("\t\t\t\t\t},");
                }
                else
                {
                    sw.WriteLine("\t\t\t\t\t}");
                }
                elapsed = "";

                if (words.Count > 0)
                {
                    // Create a new item
                    if ((runCount) % (runsPerRes * runsPerAngle) == 0 && resolutions.Count > 0)
                    {
                        Debug.Log(currRes);
                        Debug.Log(fpsColl.Average());
                        fpsColl = new List <float>();

                        currRes = Pop(resolutions);
                        if (leftEye != null && rightEye != null)
                        {
                            leftEye.SetResolution(currRes);
                            rightEye.SetResolution(currRes);
                        }
                        fixedAngle = initAngle;
                        // runs
                        sw.WriteLine("\t\t\t\t]");
                        // sets
                        sw.WriteLine("\t\t\t},");
                        // set
                        sw.WriteLine("\t\t\t{");
                        sw.WriteLine("\t\t\t\t\"resolution\" : \"" + currRes.x.ToString() + "/" + currRes.y.ToString() + "\",");
                        sw.WriteLine("\t\t\t\t\"runs\" : [");
                    }
                    else if ((runCount) % runsPerAngle == 0)
                    {
                        fixedAngle += 1;
                    }
                    Debug.Log(runCount);
                    runCount++;

                    readyToStart = false;
                    controlCam.transform.Find("Canvas").Find("Text").GetComponent <Text>().text = "Press Space to start";

                    string s = Pop(words);
                    targetText.text = s;
                    ScaleTextToAngle(targetText, s, fixedAngle);
                }
                else
                {
                    Debug.Log(currRes);
                    Debug.Log(fpsColl.Average());
                    fpsColl = new List <float>();
                    Quit();
                }
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        // Can't do it at start or I'd have a race condition
        if (runCount == 0)
        {
            currRes = Pop(resolutions);
            if (leftEye != null && rightEye != null)
            {
                leftEye.SetResolution(currRes);
                rightEye.SetResolution(currRes);
            }
            // sets
            sw.WriteLine("\t\t\t{");
            sw.WriteLine("\t\t\t\t\"resolution\" : \"" + currRes.x.ToString() + "/" + currRes.y.ToString() + "\",");
            sw.WriteLine("\t\t\t\t\"runs\" : [");
            runCount++;
            // not ready to start yet
            leftEye.SetBlackening(true);
            rightEye.SetBlackening(true);
        }

        if (!readyToStart)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                begin        = System.DateTime.Now;
                readyToStart = true;
                leftEye.SetBlackening(false);
                rightEye.SetBlackening(false);

                controlCam.transform.Find("Canvas").Find("Text").GetComponent <Text>().text = "";
            }
        }
        else
        {
            if (!answered)
            {
                deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
                float fps = 1.0f / deltaTime;
                fpsColl.Add(fps);
            }
            // "Answer button". Can compare to zero because of dead zone.
            if (Input.GetAxis("Confirm") != 0 && !answered)
            {
                answered = true;
                end      = System.DateTime.Now;
                elapsed  = (end - begin).ToString();
                string[] tmp = elapsed.Split(':');
                elapsed = tmp[1] + ":" + tmp[2].Substring(0, 6);
                controlCam.transform.Find("Canvas").Find("Text").GetComponent <Text>().text = "Press Y if CORRECT,\nN if WRONG";

                leftEye.SetBlackening(true);
                rightEye.SetBlackening(true);
            }

            // To change the resolution: get the script and add a counter in module. Possibly group items under resolution.
            // HOWEVER, first I need some more props.
            if ((Input.GetKeyDown(KeyCode.Y) || Input.GetKeyDown(KeyCode.N)) && answered)
            {
                //begin = System.DateTime.Now;
                answered = false;
                // item
                sw.WriteLine("\t\t\t\t\t{");
                sw.WriteLine("\t\t\t\t\t\t\"name\" : \"" + instantiated.name.Split('(')[0] + "\",");
                sw.WriteLine("\t\t\t\t\t\t\"result\" : \"" + (Input.GetKeyDown(KeyCode.Y) ? "CORRECT" : "WRONG") + "\",");
                sw.WriteLine("\t\t\t\t\t\t\"elapsed\" : \"" + elapsed + "\"");
                if ((runCount) % runsPerRes != 0)
                {
                    sw.WriteLine("\t\t\t\t\t},");
                }
                else
                {
                    sw.WriteLine("\t\t\t\t\t}");
                }
                elapsed = "";

                if (items.Count > 0)
                {
                    // Create a new item
                    if ((runCount) % runsPerRes == 0 && resolutions.Count > 0)
                    {
                        Debug.Log(currRes);
                        Debug.Log(fpsColl.Average());
                        fpsColl = new List <float>();

                        currRes = Pop(resolutions);

                        if (leftEye != null && rightEye != null)
                        {
                            leftEye.SetResolution(currRes);
                            rightEye.SetResolution(currRes);
                        }
                        // runs
                        sw.WriteLine("\t\t\t\t]");
                        // sets
                        sw.WriteLine("\t\t\t},");
                        // set
                        sw.WriteLine("\t\t\t{");
                        sw.WriteLine("\t\t\t\t\"resolution\" : \"" + currRes.x.ToString() + "/" + currRes.y.ToString() + "\",");
                        sw.WriteLine("\t\t\t\t\"runs\" : [");
                    }
                    runCount++;

                    readyToStart = false;
                    controlCam.transform.Find("Canvas").Find("Text").GetComponent <Text>().text = "Press Space to start";

                    Destroy(instantiated.gameObject);
                    Transform t = Pop(items);
                    instantiated = Instantiate(t, new Vector3(0.0f, 0.0f, 0.0f), t.rotation);
                    ScaleToAngle(instantiated, fixedAngle);
                    pivot.rotation = Quaternion.identity;
                }
                else
                {
                    Debug.Log(currRes);
                    Debug.Log(fpsColl.Average());
                    fpsColl = new List <float>();
                    Quit();
                }
            }
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case Test_3FStates.PREPARATION:
            // Possibly allow to rotate the object or rotate it automatically

            if ((StaticValues.runCount) % StaticValues.runsPerRes == 0 && StaticValues.resolutions.Count > 0 && !resUpdated)
            {
                currRes = Pop(StaticValues.resolutions);
                if (leftEye != null && rightEye != null)
                {
                    leftEye.SetResolution(currRes);
                    rightEye.SetResolution(currRes);
                }
                if (StaticValues.runCount > 0)
                {
                    // runs
                    StaticValues.sw.WriteLine("\t\t\t\t]");
                    // set
                    StaticValues.sw.WriteLine("\t\t\t},");
                }
                StaticValues.sw.WriteLine("\t\t\t{");
                StaticValues.sw.WriteLine("\t\t\t\t\"resolution\" : \"" + currRes.x.ToString() + "/" + currRes.y.ToString() + "\",");
                StaticValues.sw.WriteLine("\t\t\t\t\"runs\" : [");
                resUpdated = true;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                state = Test_3FStates.SIMULATION;
                begin = System.DateTime.Now;
                controlCam.transform.Find("Canvas").Find("lower").GetComponent <Text>().text = "";
                controlCam.transform.parent.GetComponent <Pivot_rotate>().active             = false;
                VRController.GetComponent <RigidbodyFirstPersonController>().enabled         = true;
                leftEye.SetBlackening(false);
                rightEye.SetBlackening(false);
            }
            break;

        case Test_3FStates.SIMULATION:
            if (Input.GetAxis("Confirm") != 0)
            {
                controlCam.transform.Find("Canvas").Find("lower").GetComponent <Text>().text = "Press Y if CORRECT,\nN if WRONG";
                end     = System.DateTime.Now;
                elapsed = (end - begin).ToString();
                string[] tmp = elapsed.Split(':');
                elapsed = tmp[1] + ":" + tmp[2].Substring(0, 6);

                leftEye.SetBlackening(true);
                rightEye.SetBlackening(true);
                state = Test_3FStates.EVALUATION;
            }
            break;

        case Test_3FStates.EVALUATION:
            if (Input.GetKeyDown(KeyCode.Y) || Input.GetKeyDown(KeyCode.N))
            {
                state = Test_3FStates.PREPARATION;

                controlCam.transform.Find("Canvas").Find("lower").GetComponent <Text>().text = "Press Space to start";

                StaticValues.sw.WriteLine("\t\t\t\t\t{");
                // Child 2 is the instantiated clone
                StaticValues.sw.WriteLine("\t\t\t\t\t\t\"name\" : \"" + targ.name.Split('(')[0] + "\",");
                StaticValues.sw.WriteLine("\t\t\t\t\t\t\"result\" : \"" + (Input.GetKeyDown(KeyCode.Y) ? "CORRECT" : "WRONG") + "\",");
                StaticValues.sw.WriteLine("\t\t\t\t\t\t\"elapsed\" : \"" + elapsed + "\"");
                if ((StaticValues.runCount) % StaticValues.runsPerRes != 0)
                {
                    StaticValues.sw.WriteLine("\t\t\t\t\t},");
                }
                else
                {
                    StaticValues.sw.WriteLine("\t\t\t\t\t}");
                }
                elapsed = "";
                Quit();
            }
            break;
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeSinceLevelLoad < 0.1f)
        {
            // Doing it on start has weird effects.
            leftEye  = VRController.Find("Fove Interface").Find("FOVE Eye (Left)").GetComponent <applyShader>();
            rightEye = VRController.Find("Fove Interface").Find("FOVE Eye (Right)").GetComponent <applyShader>();
            leftEye.SetBlackening(true);
            rightEye.SetBlackening(true);
        }
        switch (state)
        {
        case Test_3FStates.PREPARATION:
            // Possibly allow to rotate the object or rotate it automatically

            if (StaticValues.configurations.Count == StaticValues.resolutions.Count * StaticValues.angles.Count)
            {
                StaticValues.sw.WriteLine("\t\t\t{");
                // This is for doing multiple iterations WITHOUT a pause in the middle
                //StaticValues.sw.WriteLine("\t\t\t\t\"iteration\" : \"" + (StaticValues.runCount+1).ToString() + "\",");
                // This is with a pause in the middle, adding the iteration by hand.
                StaticValues.sw.WriteLine("\t\t\t\t\"iteration\" : \"" + StaticValues.iterVal + "\",");
                StaticValues.iterVal++;
                StaticValues.sw.WriteLine("\t\t\t\t\"runs\" : [");
            }

            if (StaticValues.configurations.Count > 0 && !resUpdated)
            {
                Vector3 tmp = Pop(StaticValues.configurations);
                currRes = new Vector2(tmp.x, tmp.y);

                if (leftEye != null && rightEye != null)
                {
                    leftEye.SetResolution(currRes);
                    leftEye.SetViewingAngle(tmp.z);
                    rightEye.SetResolution(currRes);
                    rightEye.SetViewingAngle(tmp.z);
                }
                StaticValues.sw.WriteLine("\t\t\t\t\t{");
                StaticValues.sw.WriteLine("\t\t\t\t\t\t\"resolution\" : \"" + currRes.x.ToString() + "/" + currRes.y.ToString() + "\",");
                StaticValues.sw.WriteLine("\t\t\t\t\t\t\"angle\" : \"" + tmp.z.ToString() + "\",");
                resUpdated = true;

                Debug.Log((StaticValues.runCount + 1).ToString() + " - " + (12 - StaticValues.configurations.Count).ToString());
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                state = Test_3FStates.SIMULATION;
                begin = System.DateTime.Now;
                controlCam.transform.Find("Canvas").Find("lower").GetComponent <Text>().text = "";
                controlCam.transform.parent.GetComponent <Pivot_rotate>().active             = false;
                VRController.GetComponent <CameraOnAStick>().enabled = true;
                leftEye.SetBlackening(false);
                rightEye.SetBlackening(false);
            }
            break;

        case Test_3FStates.SIMULATION:
            // The examinator takes the time, confirming the answer once the correct one is reached.
            //deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
            //float fps = 1.0f / deltaTime;
            //Debug.Log(fps);

            if (Input.GetKeyDown(KeyCode.Space))
            {
                controlCam.transform.Find("Canvas").Find("lower").GetComponent <Text>().text = "Enter the accuracy";

                /*
                 * infield = controlCam.transform.Find("Canvas").Find("accuracy").GetComponent<InputField>();
                 * infield.gameObject.SetActive(true);
                 * infield.ActivateInputField();
                 * infield.Select();
                 */

                end     = System.DateTime.Now;
                elapsed = (end - begin).ToString();
                string[] tmp = elapsed.Split(':');
                elapsed = tmp[1] + ":" + tmp[2].Substring(0, 6);

                leftEye.SetBlackening(true);
                rightEye.SetBlackening(true);
                state = Test_3FStates.EVALUATION;
            }
            break;

        case Test_3FStates.EVALUATION:
            controlCam.transform.Find("Canvas").Find("lower").GetComponent <Text>().text = "Press Space to start";

            // Child 2 is the instantiated clone
            StaticValues.sw.WriteLine("\t\t\t\t\t\t\"name\" : \"" + targ.name.Split('(')[0] + "\",");
            //StaticValues.sw.WriteLine("\t\t\t\t\"result\" : \"" + (infield.GetComponent<InputEditor>().written) + "\",");
            StaticValues.sw.WriteLine("\t\t\t\t\t\t\"elapsed\" : \"" + elapsed + "\"");
            if (StaticValues.configurations.Count == 0)
            {
                StaticValues.sw.WriteLine("\t\t\t\t\t}");
                StaticValues.sw.WriteLine("\t\t\t\t]");                         //sets
                if (StaticValues.runCount == runs - 1)
                {
                    StaticValues.sw.WriteLine("\t\t\t}");                             //experiments
                }
                else
                {
                    StaticValues.sw.WriteLine("\t\t\t},");                             //experiments
                }
            }
            else
            {
                StaticValues.sw.WriteLine("\t\t\t\t\t},");
            }
            elapsed = "";
            Quit();
            break;
        }
    }