/// <summary> /// Play a sound while pointing, and update the statePointing variable. /// </summary> public void PlaySoundWhilePointing() { SoundManager.PlaySound(clipPointing, leftHand.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).transform.GetChild(0) .position); statePointing = simpleStateMachine.IdleAction; }
/// <summary> /// Update all that is related to the user input (the pointing line and the clicks). /// </summary> public void UpdateUserInputs() { if (statePointing != simpleStateMachine.Idle) { HandleClicks(); } if (statePointing == simpleStateMachine.Action) { PlaySoundWhilePointing(); } if (mvtRecognition.LaunchComparisonPointing( idlePointing.Bvh.Root.Children[2].Children[0].Children[0].Children[0].Children[2].Children[0].Children[0] .Children[0], idlePointing.Bvh, new[] { "Thumb" }, degreeOfMarginPointing, 0)) { if (statePointing == simpleStateMachine.Idle) { statePointing = simpleStateMachine.Action; } else { statePointing = simpleStateMachine.IdleAction; } DrawLineUsedToInteract(); } else { //Debug.Log("Hand not pointing"); statePointing = simpleStateMachine.Idle; lineMenu.gameObject.SetActive(false); } if (Input.GetKeyDown(KeyCode.Space)) { if (mvtRecognition.RecordingScore) { Debug.Log("CSV file created at the following location: " + Path.Combine(Application.persistentDataPath, "scores.csv")); exportToCsv(mvtRecognition.listOfMvts); } else { foreach (var mvt in mvtRecognition.listOfMvts) { mvt.ClrScoreRecord(); } mvtRecognition.TimeSinceStartRecord = 0f; Debug.Log("Recording started!"); } mvtRecognition.RecordingScore = !mvtRecognition.RecordingScore; } }
/// <summary> /// Handle the visual effects of the clicks. /// </summary> public void HandleClicks() { switch (stateConfirm) { case simpleStateMachine.Idle: if (mvtRecognition.LaunchComparisonPointing( BVHactivating.Bvh.Root.Children[2].Children[0].Children[0].Children[0].Children[2].Children[0] .Children[0].Children[0].Children[0], BVHactivating.Bvh, new string[0], degreeOfMarginValidating, 0)) { SoundManager.PlaySound(clipConfirm, leftHand.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).transform .GetChild(0).position); stateConfirm = simpleStateMachine.Action; lineMenu.endColor = Color.green; } break; case simpleStateMachine.Action: stateConfirm = simpleStateMachine.IdleAction; break; case simpleStateMachine.IdleAction: if (mvtRecognition.LaunchComparisonPointing( BVHactivating.Bvh.Root.Children[2].Children[0].Children[0].Children[0].Children[2].Children[0] .Children[0].Children[0].Children[0], BVHactivating.Bvh, new string[0], degreeOfMarginValidating, 1)) { stateConfirm = simpleStateMachine.Idle; lineMenu.endColor = Color.white; } break; default: throw new ArgumentOutOfRangeException(); } }