// Use this for initialization - Creates a "virtual" game object.
 public static DataFarmer GetInstance()
 {
     if (me == null)
     {
         me = new DataFarmer();
     }
     return(me);
 }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        GameObject cube = GameObject.FindGameObjectWithTag("Interactable Object");

        if (player != null && cube != null)
        {
            if (cube != null)
            {
                Transform transform = cube.GetComponent <Transform>();
                int[]     angles    =
                {
                    (int)Math.Abs(Math.Round(Vector3.Angle(player.transform.forward, transform.right)) - 90.0),
                    (int)Math.Abs(Math.Round(Vector3.Angle(player.transform.forward, transform.up)) - 90.0),
                    (int)Math.Abs(Math.Round(Vector3.Angle(player.transform.forward, transform.forward)) - 90.0),
                };
                int max         = angles.Max();
                int visibleSide = NOSIDE;
                // basic idea: is the cube face angled towards us enough for us to see it?
                // we also want to check if the player's head is rotated up or to the side too far
                if (max > thresholdAngle)
                {
                    visibleSide = angles.ToList().IndexOf(max);
                }

                if (visibleSide != previousSide)
                {
                    // the last Vector3 is a placeholder for the cumulative movement of the head and hand controllers
                    DataFarmer.GetInstance().Save(
                        new DFFixation(
                            angles[UP], angles[FORWARD], angles[RIGHT],
                            dirStrings[visibleSide],
                            ps.DisplacementsToString()
                            )
                        );
                    previousSide = visibleSide;
                }
                if (detailedLogging)
                {
                    Debug.Log(
                        "correct answer is " + ps.GetCategory() + " " + ps.GetCube()
                        + "\nright " + player.transform.forward[RIGHT]
                        + " up " + player.transform.forward[UP]
                        + "\n" + dirStrings[UP] + " " + angles[UP]
                        + ", " + dirStrings[RIGHT] + " " + angles[RIGHT]
                        + ", " + dirStrings[FORWARD] + " " + angles[FORWARD]
                        + "\n" + dirStrings[visibleSide] + " is facing you");
                }
                measurements++;
            }
        }
    }
 void Start()
 {
     Debug.Log("new dress!");
     rend         = GetComponent <Renderer>();
     rend.enabled = true;
     Debug.Log(name);
     if (DataFarmer.GetInstance().CubeLists.IsEmpty())
     {
         throw new MissingComponentException("Missing needed cube map arrangements in CubeArrangements!");
     }
     else
     {
         rend.materials = createSet();
     }
 }
Exemple #4
0
    // class DataStructure
    // Update is called once per frame
    void Update()
    {
        framecount++;
        if (framecount % 100 == 0)
        {
            distanceTravelled += Vector3.Distance(transform.position, previousPosition);
            DataFarmer.GetInstance().Save(new DFPositionRotation(transform.position, transform.rotation, distanceTravelled));
            previousPosition = transform.position;
        }

        // Grab Vector3 Coordinates and Convert into string
        HMDxPos_string    = transform.position.x + " ";
        HMDyPos_string    = transform.position.y + " ";
        HMDzPos_string    = transform.position.z + " ";
        HMDxRotate_string = transform.rotation.x + " ";
        HMDyRotate_string = transform.rotation.y + " ";
        HMDzRotate_string = transform.rotation.z + " ";
        ObjUnderReticle   = " ";

        // Debug.Log(xstring + ystring + zstring);

        // Declare the array and insert elements on each update:

        var array = new List <string>();

        array.Add(HMDxPos_string);
        array.Add(HMDyPos_string);
        array.Add(HMDzPos_string);
        array.Add(HMDxRotate_string);
        array.Add(HMDyRotate_string);
        array.Add(HMDzRotate_string);
        var array2string = string.Join(Environment.NewLine, array.ToArray());

        String pattern = @"\s ";

        String[] data2csv = Regex.Split(array2string, pattern);
        //foreach (var element in data2csv)
        // Debug.Log(data2csv);


        string csv2file = String.Join(", ", data2csv);

        // Debug.Log(csv2file);

        // Add increment to Data Threshold Counter
        writetofile++;

        if (writetofile == DataCacheThreshhold)
        {
            // File.WriteAllLines(@"C:\Users\CSLUser\Desktop\WriteLines.csv", array.ConvertAll(Convert.ToString));
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"C:\Users\CSLUser\Desktop\WriteLines.csv", true))
            {
                // Adds array to data file on desktop
                file.WriteLine(csv2file);
            }
            // Declare that data has been sent to file
            Debug.Log("Data Cache Threshold has been reached");

            //Reset Data Threshold Counter
            writetofile = 0;
        }
    }
 // this is mainly used when we get the answer during a trial to make code simpler
 public DataFarmer GetDataFarmer()
 {
     return(DataFarmer.GetInstance());
 }