/// <summary>
        /// This is an experimental form of gesture detection. It will always attempt to
        /// detect a gesture while it is running. This would allow a user to constantly
        /// be inputting various gesture in a more natural way.
        /// </summary>
        void UpdateContinual()
        {
            state = VRGestureManagerState.Detecting;
            //Debug.Log("continuous on");
            if (Time.time > nextRenderTime)
            {
                Vector3 rightHandPoint = playerHand.position;

                nextRenderTime = Time.time + renderRateLimit / 1000;
                //myTrail.CapturePoint(rightHandPoint, rightCapturedLine, lengthOfLineRenderer);
                //IF currentCapturedLine is length greater than renderRateLimit v testRateLimit
                //  30 / 1000 = every 0.03 seconds
                // 100 / 1000 = every 0.10 seconds this will have only logged 3 points of data.
                // 500 / 1000 = every 0.5 second this will always have 16 points of data.
                int maxLineLength = (int)testRateLimit / (int)renderRateLimit;
                myTrail.CapturePoint(getLocalizedPoint(rightHandPoint), currentCapturedLine, maxLineLength);
            }
            //myTrail.RenderTrail(rightLineRenderer, rightCapturedLine);

            //On Release
            //@TODO: fix this magic number 14.
            if (Time.time > nextTestTime && currentCapturedLine.Count > GameObject.Find("Controller Manager").GetComponent <NewEarthController>().Magic)
            {
                Debug.Log("Frames performed: " + currentCapturedLine.Count);
                nextTestTime = Time.time + testRateLimit / 1000;
                LineCaught(currentCapturedLine);
                //currentRenderer.SetVertexCount(currentCapturedLine.Count);
                //currentRenderer.SetPositions(currentCapturedLine.ToArray());
            }
        }
        void Start()
        {
            if (stateInitial == VRGestureManagerState.ReadyToDetect)
            {
                BeginDetect("");
            }
            else if (FindObjectOfType <VRGestureUI>() == null)
            {
                Debug.LogError("Cannot find VRGestureUI in scene. Please add it or select Begin In Detect Mode in the VR Gesture Manager Settings");
            }


            state           = stateInitial;
            stateLast       = state;
            gestureToRecord = "";

            input = rig.GetInput(gestureHand);

            //create a new Trainer
            currentTrainer = new Trainer(Gestures, currentNeuralNet);

            currentCapturedLine = new List <Vector3>();
            if (displayGestureTrail)
            {
                myTrail = gameObject.AddComponent <GestureTrail>();
            }


            perpTransform        = new GameObject("Perpindicular Head").transform;
            perpTransform.parent = this.transform;
        }
 public void BeginTraining(Action <string> callback)
 {
     state          = VRGestureManagerState.Training;
     currentTrainer = new Trainer(gestureBank, currentNeuralNet);
     currentTrainer.TrainRecognizer();
     // finish training
     state = VRGestureManagerState.Idle;
     callback(currentNeuralNet);
 }
        void UpdateDetectWithButtons()
        {
            if (input.GetButtonUp(gestureButton))
            {
                state = VRGestureManagerState.ReadyToDetect;
                StopRecording();
            }

            if (input.GetButtonDown(gestureButton) && state == VRGestureManagerState.ReadyToDetect)
            {
                state = VRGestureManagerState.Detecting;
                StartRecording();
            }

            if (state == VRGestureManagerState.Detecting)
            {
                CapturePoint();
            }
        }
        void UpdateRecord()
        {
            if (input.GetButtonUp(gestureButton))
            {
                state = VRGestureManagerState.ReadyToRecord;
                StopRecording();
            }

            if (input.GetButtonDown(gestureButton) && state == VRGestureManagerState.ReadyToRecord)
            {
                state = VRGestureManagerState.Recording;
                StartRecording();
            }

            if (state == VRGestureManagerState.Recording)
            {
                CapturePoint();
            }
        }
 // Update is called once per frame
 void Update()
 {
     //Debug.Log("Frames performed: " + currentCapturedLine.Count);
     GetHand();
     stateLast = state;
     //get the position from the left anchor.
     //draw a point.
     if (rig != null)
     {
         if (state == VRGestureManagerState.ReadyToRecord ||
             state == VRGestureManagerState.EnteringRecord ||
             state == VRGestureManagerState.Recording)
         {
             UpdateRecord();
         }
         else if (state == VRGestureManagerState.Detecting ||
                  state == VRGestureManagerState.EnteringDetect ||
                  state == VRGestureManagerState.ReadyToDetect)
         {
             if (GameObject.Find("Controller Manager").GetComponent <NewEarthController>().Continuous == true)
             //if (on == true)
             {
                 UpdateContinual();
                 //Debug.Log("continuous on");
             }
             else
             {
                 //UpdateDetectWithButtons();
                 //LineCaught(currentCapturedLine);
                 state = VRGestureManagerState.ReadyToDetect;
                 StopRecording();
                 //Debug.Log("continuous off");
             }
         }
     }
 }
 public void EndTraining(Action <string> callback)
 {
     state = VRGestureManagerState.Idle;
     callback(currentNeuralNet);
 }
 public void BeginDetect(string ignoreThisString)
 {
     gestureToRecord   = "";
     state             = VRGestureManagerState.EnteringDetect;
     currentRecognizer = new GestureRecognizer(currentNeuralNet);
 }
 //This should be called directly from UIController via instance
 public void BeginReadyToRecord(string gesture)
 {
     currentTrainer  = new Trainer(gestureBank, currentNeuralNet);
     gestureToRecord = gesture;
     state           = VRGestureManagerState.EnteringRecord;
 }