From 5c9c0f5214283fe572ebd520bac3e05737aa24e1 Mon Sep 17 00:00:00 2001 From: Chris Midkiff Date: Wed, 28 Nov 2018 19:09:50 -0500 Subject: [PATCH] we done with data entry BITCH! --- Assets/Scripts/ExperimentController.cs | 79 +++++++++++++++++++++----- ProjectSettings/ProjectSettings.asset | 2 +- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/ExperimentController.cs b/Assets/Scripts/ExperimentController.cs index e3a1393..ecd1685 100644 --- a/Assets/Scripts/ExperimentController.cs +++ b/Assets/Scripts/ExperimentController.cs @@ -1,4 +1,5 @@ -using System; +using Assets.Scripts; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; @@ -15,8 +16,20 @@ public class ExperimentController : MonoBehaviour { List dots = new List(); Stopwatch stopwatch = new Stopwatch(); GameObject playerCamera; + DataSet dataSet = new DataSet(); + string platform; // Use this for initialization void Start () { +#if UNITY_ANDROID + platform = "cardboard"; +#endif +#if UNITY_EDITOR + platform = "mouse"; +#endif +#if UNITY_STANDALONE_WIN + platform = "rift"; +#endif + //FOR THE LOVE OF GOD FUCKING DELETE THIS, SERIOUSLY CHRIS DON'T YOU DARE FORGET string fuck = "ewoidHJpYWxzIiA6IFsKICBbIkxlZnRMb25nIiwiUmlnaHRNZWRpdW0iLCJMZWZ0U2hvcnQiLCJVcE1lZGl1bSIsIlVwTG9uZyIsIlJpZ2h0U2hvcnQiXSwKICBbIlVwU2hvcnQiLCJSaWdodExvbmciLCJMZWZ0TWVkaXVtIiwiUmlnaHRNZWRpdW0iLCJMZWZ0TG9uZyIsIlVwTG9uZyJdLAogIFsiUmlnaHRTaG9ydCIsIlVwTWVkaXVtIiwiTGVmdE1lZGl1bSIsIkxlZnRTaG9ydCIsIlJpZ2h0TG9uZyIsIlVwU2hvcnQiXSwKICBbIkxlZnRMb25nIiwiUmlnaHRNZWRpdW0iLCJMZWZ0U2hvcnQiLCJVcE1lZGl1bSIsIlVwTG9uZyIsIlJpZ2h0U2hvcnQiXSwKICBbIlVwU2hvcnQiLCJSaWdodExvbmciLCJMZWZ0TWVkaXVtIiwiUmlnaHRNZWRpdW0iLCJMZWZ0TG9uZyIsIlVwTG9uZyJdLAogIFsiUmlnaHRTaG9ydCIsIlVwTWVkaXVtIiwiTGVmdE1lZGl1bSIsIkxlZnRTaG9ydCIsIlJpZ2h0TG9uZyIsIlVwU2hvcnQiXSwKICBbIkxlZnRMb25nIiwiUmlnaHRNZWRpdW0iLCJMZWZ0U2hvcnQiLCJVcE1lZGl1bSIsIlVwTG9uZyIsIlJpZ2h0U2hvcnQiXSwKICBbIlVwU2hvcnQiLCJSaWdodExvbmciLCJMZWZ0TWVkaXVtIiwiUmlnaHRNZWRpdW0iLCJMZWZ0TG9uZyIsIlVwTG9uZyJdLAogIFsiUmlnaHRTaG9ydCIsIlVwTWVkaXVtIiwiTGVmdE1lZGl1bSIsIkxlZnRTaG9ydCIsIlJpZ2h0TG9uZyIsIlVwU2hvcnQiXQpdLAoicGFydGljaXBhbnRJZCIgOiAxLAoiaW5wdXRNZXRob2QiIDogImNhcmRib2FyZCIKfQo="; byte[] decodedBytes = Convert.FromBase64String(fuck); @@ -52,16 +65,34 @@ public class ExperimentController : MonoBehaviour { stopwatch.Stop(); double time = stopwatch.Elapsed.TotalSeconds; stopwatch.Reset(); - + double angle = Vector3.Angle(nextDot.transform.position, playerCamera.transform.position); + double distance = Vector3.Distance(nextDot.transform.position, startDot.transform.position); + SaveSample(angle, distance, time, false); + } + if (trialDotIndex < participant.trials[trialIndex].Length) + { + + nextDot = FindDot(participant.trials[trialIndex][trialDotIndex]); + trialDotIndex++; + Show(nextDot); + Hide(startDot); + } + else if(trialIndex < participant.trials.Length) + { + // NEXT TRIAL SHIT + trialIndex++; + trialDotIndex = 0; + dataSet.SaveDataSet(); + dataSet.Samples.Clear(); + nextDot = FindDot(participant.trials[trialIndex][trialDotIndex]); + Show(nextDot); + Hide(startDot); } else { - stopwatch.Start(); + dataSet.SaveDataSet(); } - nextDot = FindDot(participant.trials[trialIndex][trialDotIndex]); - trialDotIndex++; - Show(nextDot); - Hide(startDot); + stopwatch.Start(); } @@ -71,11 +102,12 @@ public class ExperimentController : MonoBehaviour { stopwatch.Stop(); double time = stopwatch.Elapsed.TotalSeconds; stopwatch.Reset(); - double angle = Vector3.Angle(nextDot.transform.position, playerCamera.transform.position); - double arcDistance = angle * (float)(Math.PI / 180) * 10; + double distance = Vector3.Distance(nextDot.transform.position, startDot.transform.position); + SaveSample(angle, distance, time, true); Hide(nextDot); Show(startDot); + stopwatch.Start(); } @@ -101,17 +133,36 @@ public class ExperimentController : MonoBehaviour { } } - // Update is called once per frame - void Update () { - - } + void SaveSample(double angle, double distance, double time, bool direction) + { + Sample sample = new Sample(); + sample.Angle = angle; + sample.Distance = distance; + sample.Time = time; + sample.Direction = direction; + sample.DotName = nextDot.name; + sample.DotIndex = trialDotIndex; + sample.TrialIndex = trialIndex + 1; + sample.ParticipantID = participant.participantId; + sample.Platform = platform; + TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); + sample.Timestamp = (long)t.TotalMilliseconds; + dataSet.Samples.Add(sample); + } GameObject FindDot(string name) { - foreach(GameObject dot in dots) + foreach (GameObject dot in dots) { if (dot.name == name) return dot; } return null; } + + // Update is called once per frame + void Update () { + + } + + } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 8a3ea09..a08eab7 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -13,7 +13,7 @@ PlayerSettings: useOnDemandResources: 0 accelerometerFrequency: 60 companyName: DefaultCompany - productName: Defuckulate + productName: FittsVR defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}