diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index d6269101f9144981d0897b54cae05b2f2321761c..013493aaa3da0b437ef9b7f703ffdbf2d365db36 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -132,16 +132,15 @@ public class GameManager : MonoBehaviour Ball.SetActive(false); MaterialManager.instance.DeactivateTarg(); EyeTrackingCSV_Recorder.instance.EyeTrackingDataBuffer.Add(EyeTrackingCSV_Recorder.instance.CaptureStudyInfo(SysTimestampGameEnd, GameTimestampEnd, "GameEnd", 99)); - //ThrowCounter = 0; } - private void NewRound() //Method that handles everything needed to + private void NewRound() //Method that handles everything needed to initiate New Round for the next throw { oldTarg = ActiveTargetNr; ActionHandler.instance.lockedGazePoint = Vector3.zero; ActionHandler.instance.targetActButtonPress = false; if (first) - { + { //Also track Information of when either game started or new round starts. Ballmanager.instance.ready4nextRound = true; EyeTrackingCSV_Recorder.instance.EyeTrackingDataBuffer.Add(EyeTrackingCSV_Recorder.instance.CaptureStudyInfo(SysTimestampGamestart, GameTimestampstart, "GameStart", ActiveTargetNr)); first = false; @@ -158,7 +157,7 @@ public class GameManager : MonoBehaviour } } - public void BallhitTarget() + public void BallhitTarget() //When ball hit Target is called it Updates the GUI Fields Points, Throws etc. { UpdateGameValues(); @@ -169,11 +168,11 @@ public class GameManager : MonoBehaviour } else { - StudyEndText.SetActive(true); + StudyEndText.SetActive(true); //If Maximum throws this round is reached Activate the end of the Trial Text Message } } - public void SetThrowCounter(int incrby) + public void SetThrowCounter(int incrby) //Setter Methods for all GUI Values { ThrowCounter = ThrowCounter + incrby; Counter.wuerfe = ThrowCounter; @@ -189,7 +188,7 @@ public class GameManager : MonoBehaviour return ThrowCounter; } - private void UpdateGameValues() + private void UpdateGameValues() //Update the Scripts for displaying the Values set. { int PointsThisRound = ScoreCalc.instance.DistanceToPoints(ScoreCalc.instance.CalcDistancetoBullsEye(Ball.transform.position, ActiveTargetNr)); diff --git a/Assets/Scripts/GazeAssist.cs b/Assets/Scripts/GazeAssist.cs index 15215a2a37f8a7deb01955e27dfe874a6155c1ec..a4dc8861c6f0435fdbbc0e842c4453cf8cc37b46 100644 --- a/Assets/Scripts/GazeAssist.cs +++ b/Assets/Scripts/GazeAssist.cs @@ -58,7 +58,7 @@ public class GazeAssist : MonoBehaviour // Start is called before the first frame update void Start() { - initWeight(); + initWeight(); //initialize Values needed for Gaze detection and Assist Ball = GameManager.instance.Ball; BallRB = Ball.GetComponent<Rigidbody>(); GTBall = Ball.GetComponent<GazeThrowableObject>(); @@ -69,19 +69,19 @@ public class GazeAssist : MonoBehaviour // Update is called once per frame void Update() { - UpdateFocusedObject(); + UpdateFocusedObject(); //every frame the Tobii Method of updating the focusedobject in the Buffer is called to always have the exact eyetracking data. } - public void spawnGazeTargetBall() + public void spawnGazeTargetMarker() //Method that will spawn the Debuggig points for simulated motor throw Point { - GazeMarker.GetComponent<MeshRenderer>().enabled = true; + GazeMarker.GetComponent<MeshRenderer>().enabled = true; GazeMarker.GetComponent<Rigidbody>().isKinematic = true; GazeMarker.transform.position = PredictProjectileMovement(ActionHandler.instance.Ball.transform.position, ActionHandler.instance._velocityMotorThrow, 10f); //GazeMarker.GetComponent<BoxCollider>().enabled = true; } - public void spawnTobiiPoint() + public void spawnTobiiPoint() //Method that spawns the Debugging point for the fixated Point { Vector3 tr = calcGazeTargetPoint(); TobiiPoint.GetComponent<MeshRenderer>().enabled = true; @@ -89,7 +89,7 @@ public class GazeAssist : MonoBehaviour TobiiPoint.transform.position = tr; } - private void UpdateFocusedObject() + private void UpdateFocusedObject() //Method, thats checks wether tobii gathered new objects and gaze points or drops the elements after certain ammount of time { // Check whether Tobii XR has any focused objects. foreach (var focusedCandidate in TobiiXR.FocusedObjects) @@ -125,12 +125,10 @@ public class GazeAssist : MonoBehaviour public Vector3 CalcVelII(Vector3 Target) { - // think of it as top-down view of vectors: - // we don't care about the y-component(height) of the initial and target position. + //Top down view on 3d Vector for positioning Vector3 projectileXZPos = new Vector3(Ball.transform.position.x, 0.0f, Ball.transform.position.z); Vector3 targetXZPos = new Vector3(Target.x, 0.0f,Target.z); - // Vector3 targetXZPos = new Vector3(getweightetGazeBullseyeV3(_focusedGazeHitPoint, _motorThrowHitPoint).x, 0.0f, getweightetGazeBullseyeV3(_focusedGazeHitPoint, _motorThrowHitPoint).z); - + // rotate the object to face the target Ball.transform.LookAt(targetXZPos); @@ -141,7 +139,7 @@ public class GazeAssist : MonoBehaviour float H = Target.y - Ball.transform.position.y; // calculate the local space components of the velocity - // required to land the projectile on the target object + // required to land the projectile on the target point float Vz = Mathf.Sqrt(G * R * R / (2.0f * (H - R * tanAlpha))); float Vy = tanAlpha * Vz; @@ -153,7 +151,7 @@ public class GazeAssist : MonoBehaviour } - public void calcThrowAngle(Vector3 targetPos) + public void calcThrowAngle(Vector3 targetPos) //Method to assess the Angle of the Throw { Vector3 projectileXZPos = new Vector3(Ball.transform.position.x, 0.0f, Ball.transform.position.z); Vector3 targetXZPos = new Vector3(targetPos.x, 0.0f, targetPos.z); @@ -164,7 +162,7 @@ public class GazeAssist : MonoBehaviour _angle = alpha; } - public Vector3 calcGazeTargetPoint() + public Vector3 calcGazeTargetPoint() //Raycasting the pixelexact Point to spawn the debugging point. { int Layer = 1 << 8; RaycastHit hit; @@ -176,7 +174,7 @@ public class GazeAssist : MonoBehaviour return tr; } - public Vector3 getweightetGazeBullseyeV3(Vector3 GazePoint, Vector3 Motor) + public Vector3 getweightetGazeBullseyeV3(Vector3 GazePoint, Vector3 Motor) //Method that calculates the Weighted final Point, the ball should hit { Vector3 WeightetPoint; Debug.DrawLine(GazePoint, Motor, Color.cyan, 1000f); @@ -189,7 +187,7 @@ public class GazeAssist : MonoBehaviour return WeightetPoint; } - public Vector3 PredictProjectileMovement(Vector3 InitialPosition, Vector3 InitialVelocity, float TimeToExplode) + public Vector3 PredictProjectileMovement(Vector3 InitialPosition, Vector3 InitialVelocity, float TimeToExplode) //Method that simulates the actual motor throw of the Participant { Vector3 Position = InitialPosition; Vector3 Velocity = InitialVelocity; @@ -203,13 +201,10 @@ public class GazeAssist : MonoBehaviour Vector3 PreviousPosition = Position; Vector3 PreviousVelocity = Velocity; - //Position += Velocity * DeltaTime + 0.5f * GravitationalAcceleration * DeltaTime * DeltaTime; + //Formula to describe every point on trajectory after certain time Position += GravitationalAcceleration * DeltaTime * DeltaTime * 0.5f + Velocity * DeltaTime; Velocity += GravitationalAcceleration * DeltaTime; - - Debug.DrawLine(PreviousPosition, Position, Color.red, 1000f); - // Collision detection. // int Layer = 1 << 8; RaycastHit HitInfo; @@ -217,6 +212,7 @@ public class GazeAssist : MonoBehaviour { // Set the hit point as the new position. Position = HitInfo.point; + //set collision of ray with obj, as final Motor Throw hit point. _motorThrowHitPoint = Position; break; } @@ -227,7 +223,7 @@ public class GazeAssist : MonoBehaviour return Position; } - private float initWeight() + private float initWeight() //Method that evaluates what the initial weighting should be depending of chosen Condition. { switch (GameManager.instance.condition) { diff --git a/Assets/Scripts/GroundBallHandler.cs b/Assets/Scripts/GroundBallHandler.cs index 9ef70f1af4f1fefc615524e79a26895559ac17de..dac969e232dd878278c69b19fcd3b6f42c289e5d 100644 --- a/Assets/Scripts/GroundBallHandler.cs +++ b/Assets/Scripts/GroundBallHandler.cs @@ -18,14 +18,12 @@ public class GroundBallHandler : MonoBehaviour } - private void OnTriggerEnter(Collider Ball) + private void OnTriggerEnter(Collider Ball) //Wehen Ball hits the ground Plate, behave, like successful throw was completed. { Ballmanager.instance.Ballhit = true; Ballmanager.instance.BallCollider = Ball; GameManager.instance.BallhitTarget(); GetComponent<BoxCollider>().enabled = false; Ball.attachedRigidbody.isKinematic = true; - - Debug.Log("Ball Entered Ground Collider"); } } diff --git a/Assets/Scripts/MainStudy_Recorder.cs b/Assets/Scripts/MainStudy_Recorder.cs index faf2e55c80c88a36c3db09d85e804dd42124e8d8..d40d792939bae67f5c51717f3aacb8dfaefb2371 100644 --- a/Assets/Scripts/MainStudy_Recorder.cs +++ b/Assets/Scripts/MainStudy_Recorder.cs @@ -34,7 +34,6 @@ public class MainStudy_Recorder : MonoBehaviour private int counter = 0; public int ScoreperRound = 0; - //private string dateTimeFileName = DateTime.Now.ToString("dd/mm/yy_hh.mmtt"); private string dateTimeFileName; private string FilePath; @@ -51,7 +50,7 @@ public class MainStudy_Recorder : MonoBehaviour } - private void Start() + private void Start() //Initialize File Name and Path of Logging File. { dateTimeFileName = DateTime.Now.ToString("MM/dd/yyyy hh-mm tt"); dateTimeFileName = dateTimeFileName.Replace("/", "-"); @@ -63,7 +62,7 @@ public class MainStudy_Recorder : MonoBehaviour - async void WriteCSV(List<string> Buffer, string FileName) + async void WriteCSV(List<string> Buffer, string FileName) //Write the build string into the CSV to save the Data with an asynchronous Stream Writer. { string fn = Path.Combine(FilePath, FileName + ".csv"); @@ -73,9 +72,6 @@ public class MainStudy_Recorder : MonoBehaviour { if (counter == 0) { - //await sw.WriteLineAsync("UnixTimeStamp;Time since GameStart;Round;ActTarget;isTargActive?;Origin V3(x,y,z);Direction V3(x,y,z);GazeRay isValid;" + - // "TriggerState;BallPosition(x,y,z);BallLockedonTarget;GazeHitPoint;Gaze to Target Distance; Ball to Target Distance; ActualPoints MotorThrow; " + - // "ScoredPoints per Round;total Score;MotorThrow 2 Target Dist; Motor 2 Gaze Dist; MotorThrowHitPoint X ;Y ;Z ; weight;ExpCondition"); await sw.WriteLineAsync("UnixTime;GameTime;Cond;usedHand;BallsThrown;Round;Weight;Target;TargetActive?;GazeValid?;TriggerState;BallonTarget?;LockedGazetoTargDist;Gaze2Targ Dist;Ball2Targ Dist; Motor2Targ Dist;Motor2Gaze Dist;" + "PointsMotor;ScorethisRound;TotalScore;MotorHitPoint X; Y;Z; Ball X;Y;Z;LockedGazePointX;Y;Z;GazeHitPointX;Y;Z;rayOriginX;Y;Z;rayDirectionX;Y;Z"); @@ -93,29 +89,22 @@ public class MainStudy_Recorder : MonoBehaviour } - public string CaptureEyeTrackingData() + public string CaptureEyeTrackingData() //Colllect all necessary Data Points from other Scripts ect. { - // var gazeRay = TobiiXR.EyeTrackingData.GazeRay; + rayOrigin = TobiiXR.EyeTrackingData.GazeRay.Origin; rayDirection = TobiiXR.EyeTrackingData.GazeRay.Direction; - // float Convergence = TobiiXR.EyeTrackingData.ConvergenceDistance; - // var isLeftEyeBlinking = TobiiXR.EyeTrackingData.IsLeftEyeBlinking; - //var isRightEyeBlinking = TobiiXR.EyeTrackingData.IsRightEyeBlinking; - string SystemTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); string GameTime = Time.time.ToString(); string rayOriginStr = V3toString(rayOrigin); string rayDirectionStr = V3toString(rayDirection); string gazeValidity = TobiiXR.EyeTrackingData.GazeRay.IsValid.ToString(); - // string leftEyeBlinking = isLeftEyeBlinking.ToString(); - // string rightEyeBlinking = isRightEyeBlinking.ToString(); string GazeRayhitPoint = V3toString(EyeTracking_GazeDetect.instance.GazeRayHitPoint(TobiiXR.EyeTrackingData.GazeRay.Origin, TobiiXR.EyeTrackingData.GazeRay.Direction)); string GazeTargetDist = EyeTracking_GazeDetect.instance.GazeToTargetDist(GameManager.instance.ActiveTargetNr).ToString(); string BallTargetDist = EyeTracking_GazeDetect.instance.BallToTargetDist(GameManager.instance.ActiveTargetNr).ToString(); string MotorTargetDist = dist(GazeAssist.instance._motorThrowHitPoint, EyeTracking_GazeDetect.instance.resolveTargetIDtoV3(GameManager.instance.ActiveTargetNr)); string MotorGazeDist = dist(GazeAssist.instance._focusedGazeHitPoint, GazeAssist.instance._motorThrowHitPoint); string MotorHitPoint = V3toString(GazeAssist.instance._motorThrowHitPoint); - //string GazeHitPoint = V3toString(GazeAssist.instance._focusedGazeHitPoint); string weight = GazeAssist.instance._gazeWeighting.ToString(); string actualPoints = calcMotorScore(GazeAssist.instance._motorThrowHitPoint).ToString(); string scoredPoints = ScoreperRound.ToString(); @@ -126,7 +115,6 @@ public class MainStudy_Recorder : MonoBehaviour string round = GameManager.instance.ThrowCounter.ToString(); string ActTarget = resolveTargetID(GameManager.instance.ActiveTargetNr); string tarActbool = ActionHandler.instance.targetActButtonPress.ToString(); - //string gazeAveraged = V3toString(GazeAssist.instance.calcGazeTargetPoint()); string ballsThrown = ActionHandler.instance.ballsThrown.ToString(); string triggerstate = ActionHandler.instance.isTriggerpressed.ToString(); string BallPos = V3toString(Ball.transform.position); @@ -134,10 +122,6 @@ public class MainStudy_Recorder : MonoBehaviour string lockedGazePoint = V3toString(ActionHandler.instance.lockedGazePoint); string lockedGazeDisttoTarg = dist(ActionHandler.instance.lockedGazePoint, EyeTracking_GazeDetect.instance.resolveTargetIDtoV3(GameManager.instance.ActiveTargetNr)); - // string FrameDataBuffer = $"{SystemTime};{GameTime};{round};{ActTarget};{tarActbool};{rayOriginStr};{rayDirectionStr};{gazeValidity};" + - // $"{triggerstate};{BallPos};{BallState};{GazeRayhitPoint};{GazeTargetDist};{BallTargetDist};{actualPoints};{ScoreperRound};{totalScore};" + - // $"{MotorTargetDist};{MotorGazeDist};{MotorHitPoint};{weight};{condition}"; - string FrameDataBuffer = $"{SystemTime};{GameTime};{condition};{hand};{ballsThrown};{round};{weight};{ActTarget};{tarActbool};{gazeValidity};{triggerstate};{BallState};" + $"{lockedGazeDisttoTarg};{GazeTargetDist};{BallTargetDist};{MotorTargetDist};{MotorGazeDist};{actualPoints};{ScoreperRound};{totalScore};" + $"{MotorHitPoint};{BallPos};{lockedGazePoint};{GazeRayhitPoint};{rayOriginStr};{rayDirectionStr};"; @@ -150,13 +134,13 @@ public class MainStudy_Recorder : MonoBehaviour return FrameDataBuffer; } - private string dist(Vector3 A, Vector3 B) + private string dist(Vector3 A, Vector3 B) //Helper Method to calc distances between two Vectors { float dist = Vector3.Distance(A, B); return dist.ToString(); } - public string worldtoScreenCoord(Vector3 Origin, Vector3 Direction, float convergence, Camera cam) + public string worldtoScreenCoord(Vector3 Origin, Vector3 Direction, float convergence, Camera cam) //Method for translate Eyetracking info to Screen Position 2 D Coordinates. { if (TobiiXR.EyeTrackingData.ConvergenceDistanceIsValid && TobiiXR.EyeTrackingData.GazeRay.IsValid) @@ -173,13 +157,13 @@ public class MainStudy_Recorder : MonoBehaviour } } - public string V3toString(Vector3 vec) + public string V3toString(Vector3 vec) //Helper to build string from Vector { string formattedVec = (vec.x + ";" + vec.y + ";" + vec.z); return formattedVec; } - void tempSaveEyeTrackingData() + void tempSaveEyeTrackingData() //Tempsave Method that saves the data out of the Main Buffer. { List<string> TempList = new List<string>(); @@ -190,25 +174,22 @@ public class MainStudy_Recorder : MonoBehaviour EyeTrackingDataBuffer.Clear(); Task.Factory.StartNew(() => WriteCSV(TempList, $"{dateTimeFileName.Replace(" ", "_")} Data_MAIN_"+ GameManager.instance.condition +"_Subj_" + RecordingController.Instance.SubjectID)); - - //WriteCSV(TempList, $"{dateTimeFileName.Replace( " ", "_" )} EyeTrackingData_All"); - } - private void Update() + private void Update() { - EyeTrackingDataBuffer.Add(CaptureEyeTrackingData()); + EyeTrackingDataBuffer.Add(CaptureEyeTrackingData());//Call to caputre Data every frame. if (Time.frameCount % interval == 0) { - tempSaveEyeTrackingData(); + tempSaveEyeTrackingData(); //tempsave every Intervall set globally. } } - public string CaptureStudyInfo(string Systime, string gameTime, string StartEndNewRound, int taregtID) + public string CaptureStudyInfo(string Systime, string gameTime, string StartEndNewRound, int taregtID) { string target = resolveTargetID(taregtID); string StudyInfo = $"{Systime};{gameTime};{StartEndNewRound};{target}"; @@ -243,14 +224,13 @@ public class MainStudy_Recorder : MonoBehaviour return ScoreCalc.instance.DistanceToPoints(dist); } - public void SaveTrackingData() + public void SaveTrackingData() //save the data collected. { WriteCSV(EyeTrackingDataBuffer, $"{dateTimeFileName.Replace(" ", "_")} Data_MAIN_" + GameManager.instance.condition + "_Subj_" + RecordingController.Instance.SubjectID); } - void OnApplicationQuit() + void OnApplicationQuit() //Before quitting Appl. Save the data. { - //tempSaveEyeTrackingData SaveTrackingData(); counter += 1; } diff --git a/Assets/Scripts/MaterialManager.cs b/Assets/Scripts/MaterialManager.cs index 4f0f9a3caf6af681467ac78f0fbc610c8a1f12c2..7290ff5a53b931bcbe731e4d313ba18fd7b39b36 100644 --- a/Assets/Scripts/MaterialManager.cs +++ b/Assets/Scripts/MaterialManager.cs @@ -9,13 +9,12 @@ public class MaterialManager : MonoBehaviour public GameObject TargetRight; public GameObject TargetMiddle; public GameObject TargetPodest; - // public BallManager BallManager; public Material BWMaterial; public Material ColMaterial; private Renderer T1Renderer; - private Renderer T2Renderer; + private Renderer T2Renderer; //References to Target Renderers private Renderer T3Renderer; public List<Renderer> TargetRenderer; @@ -33,7 +32,7 @@ public class MaterialManager : MonoBehaviour instance = this; } - TargetRenderer = new List<Renderer> + TargetRenderer = new List<Renderer> //Create List of the Renderers { TargetLeft.GetComponent<Renderer>(), TargetMiddle.GetComponent<Renderer>(), @@ -44,14 +43,12 @@ public class MaterialManager : MonoBehaviour T2Renderer = TargetRight.GetComponent<Renderer>(); T3Renderer = TargetMiddle.GetComponent<Renderer>(); - // BallManager = TargetPodest.GetComponent<BallManager>(); - - DeactivateTarg(); + DeactivateTarg(); //On start make all Targets B/W isTargActive = false; } - public void ChangeBWMaterial(int TargNr) + public void ChangeBWMaterial(int TargNr) //Method, that changes material of certain target to BW { Renderer TargRenderer = TargetRenderer[TargNr]; if (isTargActive == true) @@ -62,7 +59,7 @@ public class MaterialManager : MonoBehaviour } - public void ChangeColorMaterial(int TargNr) + public void ChangeColorMaterial(int TargNr) //Method that changes Target Material by ID to Coloured { Renderer TargRenderer = TargetRenderer[TargNr]; if (isTargActive == false) @@ -74,14 +71,14 @@ public class MaterialManager : MonoBehaviour } - public void NewMaterial4nextRound(int oldTargnr, int newTargNr) + public void NewMaterial4nextRound(int oldTargnr, int newTargNr) //Next round behaviour of Targets. { DeactivateTarg(); ChangeColorMaterial(newTargNr); } - public void DeactivateTarg() + public void DeactivateTarg() //Method to deactivate targets { T1Renderer.material = BWMaterial; T2Renderer.material = BWMaterial; @@ -89,7 +86,7 @@ public class MaterialManager : MonoBehaviour isTargActive = false; } - public void printTargets(int i) + public void printTargets(int i) //Helper to print id of Target that gets activated. { Debug.Log(TargetRenderer[i]); } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index f5f0ea65daefa3f5b7fb4a43a92aba23c1f9e9de..df30692a48e83373c7d22d508a36d96009c9fda7 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -24,11 +24,11 @@ public class PlayerController : MonoBehaviour { if (_grabbedThrowable != null) { - _currentGrabbedLocation = _grabbedThrowable.transform.position; + _currentGrabbedLocation = _grabbedThrowable.transform.position; //If grabbed Obj not null, save Position } } - public void HoldGameObj (GameObject throwableObj) + public void HoldGameObj (GameObject throwableObj) //Method that sets the Throwable Obj. and Parent relationship etc. { Throwable throwable = throwableObj.GetComponent<Throwable>(); if (throwable != null) @@ -40,7 +40,7 @@ public class PlayerController : MonoBehaviour } } - public void ReleaseGameObj() + public void ReleaseGameObj() //Method for releasing the Game Obj. { if (_grabbedThrowable != null) { diff --git a/Assets/Scripts/ScoreCalc.cs b/Assets/Scripts/ScoreCalc.cs index d48cd65b4ea38d344056fe41298db31c57c44859..c107a434465b6cafbf92278a1b1c5ba2695590e0 100644 --- a/Assets/Scripts/ScoreCalc.cs +++ b/Assets/Scripts/ScoreCalc.cs @@ -33,7 +33,6 @@ public class ScoreCalc : MonoBehaviour { TotalScore = 0; - //Debug.Log("BE DISTANCE:" + Vector3.Distance(Measure.transform.position, BullsEyeRight.transform.position)); } // Update is called once per frame @@ -42,7 +41,7 @@ public class ScoreCalc : MonoBehaviour } - public float CalcDistancetoBullsEye(Vector3 BallPos, int TargetID) + public float CalcDistancetoBullsEye(Vector3 BallPos, int TargetID) // Method that calculates the distance of the Ball Position on Taret tothe BullsEye { switch (TargetID) { @@ -65,7 +64,7 @@ public class ScoreCalc : MonoBehaviour } } - public int DistanceToPoints(float dist) + public int DistanceToPoints(float dist) //Method that calculates the Points reached this throw via Distance { if (0f < dist && dist < 0.2450001f) { @@ -89,7 +88,7 @@ public class ScoreCalc : MonoBehaviour } } - public int sumScore(int points) + public int sumScore(int points) //Method to summ up the calculated scores { TotalScore += points; return TotalScore; diff --git a/Assets/Scripts/ThrowCountDisplayer.cs b/Assets/Scripts/ThrowCountDisplayer.cs index 8264eb6b027acb185b64dcb5fa3ab60c82716d80..7302f445c1fa8916bf2d29b1979d080eebe00ed0 100644 --- a/Assets/Scripts/ThrowCountDisplayer.cs +++ b/Assets/Scripts/ThrowCountDisplayer.cs @@ -7,19 +7,12 @@ public class Counter : MonoBehaviour public Text CounterText; public static int wuerfe; - void Start() + void Start() //Initialize Number of throws for Startup { wuerfe = 0; } - /* - public void increment() - { - wuerfe++; - } - */ - - void OnGUI() + void OnGUI() //Apply Number of throws to GUI Element { CounterText.text = wuerfe.ToString(); } diff --git a/Assets/Scripts/Throwable.cs b/Assets/Scripts/Throwable.cs index 63d5143edd642cae06e3e4484555dc8c27c66325..079e8c2109ee02b766e4657149f847e4ac80fafe 100644 --- a/Assets/Scripts/Throwable.cs +++ b/Assets/Scripts/Throwable.cs @@ -16,8 +16,4 @@ public class Throwable : MonoBehaviour { } - - - - } diff --git a/Assets/Scripts/VorstudieRec.cs b/Assets/Scripts/VorstudieRec.cs index b8874bf780ed4fbbbba7efd0f8ab960f0c1bee67..a03a6307f91b775f40ae4207f430de4220fbab83 100644 --- a/Assets/Scripts/VorstudieRec.cs +++ b/Assets/Scripts/VorstudieRec.cs @@ -13,7 +13,7 @@ public class VorstudieRec : MonoBehaviour { //string FilePath; public List<string> EyeTrackingDataBuffer = new List<string>(); - + //References to the Objects, that shall be recordeds public Camera cam; public GameObject Ball; @@ -31,7 +31,7 @@ public class VorstudieRec : MonoBehaviour // Use this for initialization void Start() { - counter = 0; + counter = 0; //Initializing values and References at startup dateTimeFileName = DateTime.Now.ToString("MM/dd/yyyy hh-mm tt"); dateTimeFileName = dateTimeFileName.Replace("/", "-"); FilePath = Application.dataPath; @@ -40,7 +40,7 @@ public class VorstudieRec : MonoBehaviour } - async void WriteCSV(List<string> Buffer, string FileName) + async void WriteCSV(List<string> Buffer, string FileName) //Function that writes the built string into the csv via Async Stream Writer { string fn = Path.Combine(FilePath, FileName + ".csv"); @@ -61,7 +61,7 @@ public class VorstudieRec : MonoBehaviour } } - public string CaptureEyeTrackingData() + public string CaptureEyeTrackingData() //Collect data needed for the Logging file and Buildt a string ofit { var gazeRay = TobiiXR.EyeTrackingData.GazeRay; rayOrigin = TobiiXR.EyeTrackingData.GazeRay.Origin; @@ -85,9 +85,6 @@ public class VorstudieRec : MonoBehaviour string ActTarget = resolveTargetID(GameManager.instance.ActiveTargetNr); string tarActbool = ActionHandler.instance.targetActButtonPress.ToString(); string gazeatBullsEye = GazeOnBullsEye(); - // string gazeAveraged = V3toString(EyeTracking_GazeDetect.instance.avgV3); - // string avgDistGaze = EyeTracking_GazeDetect.instance.finalaverageGazeDist.ToString(); - string FrameDataBuffer = $"{SystemTime};{GameTime};{round};{tarActbool};{ActTarget};{gazeValidity};{triggerstate};" + $"{BallPos};{BallState};{GazeRayhitPoint};{GazeTargetDist};" + @@ -101,13 +98,13 @@ public class VorstudieRec : MonoBehaviour return FrameDataBuffer; } - public string V3toString(Vector3 vec) + public string V3toString(Vector3 vec) //Translates a Vector to a String { string formattedVec = (vec.x + ";" + vec.y + ";" + vec.z); return formattedVec; } - void tempSaveEyeTrackingData() + void tempSaveEyeTrackingData() //Temporarily save Data Blocks from Main Buffer { List<string> TempList = new List<string>(); @@ -118,15 +115,12 @@ public class VorstudieRec : MonoBehaviour EyeTrackingDataBuffer.Clear(); Task.Factory.StartNew(() => WriteCSV(TempList, $"{dateTimeFileName.Replace(" ", "_")} {RecordingController.Instance.ExperimentName.ToString()}_Part_{RecordingController.Instance.SubjectID.ToString()}")); - - // WriteCSV(TempList, $"{dateTimeFileName.Replace(" ", "_")} {RecordingController.Instance.ExperimentName.ToString()}_Part_{RecordingController.Instance.SubjectID.ToString()}"); - } // Update is called once per frame void Update() { - EyeTrackingDataBuffer.Add(CaptureEyeTrackingData()); + EyeTrackingDataBuffer.Add(CaptureEyeTrackingData()); //Call Tempsave Function every x Time Interval if (Time.frameCount % interval == 0) { @@ -136,7 +130,7 @@ public class VorstudieRec : MonoBehaviour } - public string resolveTargetID(int targetNr) + public string resolveTargetID(int targetNr) //Translate Target ID into readable Text for Logging { switch (targetNr) { @@ -158,19 +152,18 @@ public class VorstudieRec : MonoBehaviour } } - public void SaveTrackingData() + public void SaveTrackingData() //Main Save Function { WriteCSV(EyeTrackingDataBuffer, $"{dateTimeFileName.Replace(" ", "_")} {RecordingController.Instance.ExperimentName.ToString()}_Part_{RecordingController.Instance.SubjectID.ToString()}"); } - void OnApplicationQuit() + void OnApplicationQuit() //Before closing App, save the Data { - //tempSaveEyeTrackingData SaveTrackingData(); counter += 1; } - public string GazeOnBullsEye() + public string GazeOnBullsEye() //Check if Gaze Point Distance is within BullsEye Circle { if (EyeTracking_GazeDetect.instance.GazeToTargetDist(GameManager.instance.ActiveTargetNr) <= 0.2450001f) { diff --git a/Assets/Scripts/gameTimeDisplayer.cs b/Assets/Scripts/gameTimeDisplayer.cs index ceb0aa855def6086878646c702b5b31ffbffd5ed..139bcdf2784e17f000e1b6cb672775fe6015bb44 100644 --- a/Assets/Scripts/gameTimeDisplayer.cs +++ b/Assets/Scripts/gameTimeDisplayer.cs @@ -7,7 +7,7 @@ public class scri : MonoBehaviour public Text Zeit; public float startTime = 0; public int stageTime = 0; - private int min; + private int min; //Initialize times and vlues needed to Display Game Time in Scene private int sec; public bool gameFinished = false; public bool gameStarted = false; @@ -21,22 +21,20 @@ public class scri : MonoBehaviour void Update() { - if (gameStarted && startcount == 0) + if (gameStarted && startcount == 0) //Start Time counter { startcount += 1; - //Debug.Log("enter gameStarted"); - startTime = Time.time; + startTime = Time.time; } - else if (gameStarted && startcount != 0 && !gameFinished) + else if (gameStarted && startcount != 0 && !gameFinished) //refresh time display for secs and mins { stageTime = (int)(Time.time - startTime); - //Debug.Log("enter gameStarted + running"); min = Mathf.FloorToInt(stageTime / 60); sec = Mathf.FloorToInt(stageTime % 60); } } - void OnGUI() + void OnGUI() //put time calculated on the display in the scene { Zeit.text = min.ToString() + ":" + sec.ToString("00"); } diff --git a/Assets/Scripts/pointsDisplay.cs b/Assets/Scripts/pointsDisplay.cs index dd001cf26f1bccd42d56ab0884a8a390d4976e5e..c089e9f5fd9395eed558c17fbb909eaaa0ef88f9 100644 --- a/Assets/Scripts/pointsDisplay.cs +++ b/Assets/Scripts/pointsDisplay.cs @@ -7,12 +7,12 @@ public class points : MonoBehaviour public Text PointsText; public static int Points; - void Start() + void Start() //Initialize Points to Zero for Display in scene { Points = 0; } - void OnGUI() + void OnGUI() //Display the Points String that was set. { PointsText.text = Points.ToString(); }