public void CreateNewTrial(SelectionEventArgs args, GameObject target, int trialNr, DistanceZones zone = DistanceZones.Control, ReferenceFrame refFrame = ReferenceFrame.World) { Started = true; //If it receives the trial number as a parameter it uses that number, else it increases from the previous trial Vector3 lastTargetPos = Trial.Target == null ? Vector3.zero : Trial.LastTargetPosition; Trial = new TrialInformation(); Trial.RefFrame = refFrame; Trial.Zone = zone; Trial.Controller = Settings.ControllerType; Trial.TrialNro = trialNr; Trial.TrialWidth = target.transform.localScale.x; Trial.TrialDistance = (lastTargetPos - target.transform.position).magnitude; Trial.Target = target; Trial.LastTargetPosition = lastTargetPos; Trial.StartTime = System.DateTime.Now; if (args != null) { Trial.ControllerInitialPx = args.ControllerEvent.PointerPx; Trial.ControllerInitialPos = args.ControllerEvent.PointerPos; Trial.ControllerInitialQuat = args.ControllerEvent.PointerQuat; } Trial.CameraInitialPos = Camera.transform.position; Trial.CameraInitialQuat = Camera.transform.rotation; if (Settings.IsCursorBasedController) //Touch, Gyro, Head (gyro) { Vector2 origin = (Vector2)LeftEyeCamera.WorldToScreenPoint(lastTargetPos); Vector2 end = (Vector2)LeftEyeCamera.WorldToScreenPoint(target.transform.position); Trial.InitialDistanceToTarget = (end - origin).magnitude; Trial.InitialDistanceToTargetPxAdjusted = CalculateAdjustedDistance(origin, end, new Vector3(2f, 1.0f, 1.0f)); } else if (Settings.ControllerType == ControllerType.HandGesture) //Hand { Trial.InitialDistanceToTarget = (Trial.ControllerInitialPos - target.transform.position).magnitude; } else //IsRotationBasedController -- Raycast, Head { Trial.InitialDistanceToTarget = Vector3.Angle(Trial.ControllerInitialPos - lastTargetPos, Trial.ControllerInitialPos - target.transform.position); } }
public ExperimentControl(string name) { Started = false; ExperimentName = name; Trial = new TrialInformation(); }