// Use this for initialization void Start() { dir = @"C:\Users\tjdub\Documents\";//Directory.GetCurrentDirectory(); mypath = Path.Combine(dir, "WordsFileTest.json"); // mypath = @"C:\Users\tjdub\Documents\"; //myText = GameObject.Find("pText"); //myText.GetComponent<TextMesh>().text = ""; myAnalyzer.PointPatternSet = PointManager.ReadFile(mypath); option1.GetComponent <Text>().text = ""; option2.GetComponent <Text>().text = ""; option3.GetComponent <Text>().text = ""; option4.GetComponent <Text>().text = ""; trascribedText.GetComponent <Text>().text = ""; }
// void savePattern(string word) { Point[] mypoints = new Point[setPattern.Count]; mypoints = setPattern.ToArray(); PointPattern pa = new PointPattern(); pa.Name = word; pa.Points = mypoints; setPattern.Clear(); PointManager.AddInput(path, pa); Debug.Log("shoooo"); }
// Update is called once per frame void Update() { float step = 2.0f * Time.deltaTime; // mycoroutine = move(p); //move(p); // move2(p); // transform.position = Vector3.MoveTowards(transform.position, p, step); //transform.position = Vector3.MoveTowards(transform.position, t, step); // string mystring = currentWord; mycoroutine = move2(); //char[] chars = mystring.ToCharArray(); // int l = chars.Length; // transform.position = h; if (!start) { getWord(); //target = p; start = true; count = 0; findTarget(count); // yield return new WaitForSeconds(5); // StopAllCoroutines(); // StartCoroutine(mycoroutine); transform.position = target; } // Debug.Log("Current word is " + currentWord[count]+ target); transform.position = Vector3.MoveTowards(transform.position, target, step); Debug.Log(transform.position + " and " + target); Debug.Log(Vector3.Distance(transform.position, target)); //set points point.X = transform.position.x; //xpos;// mycursor.transform.position.x; point.Y = transform.position.y; // setPattern.Add(point); if ((Vector3.Distance(transform.position, target) < 0.2f)) { // Swap the position of the cylinder. //x.transform.position *= -1.0f; // yield return new WaitForSeconds(5); Debug.Log("h"); //switch (mystring[count]) //{ // case 'h': // target = h; // // transform.position = Vector3.MoveTowards(transform.position, h, step); // Debug.Log("h"); // break; // case 'i': // target = i; // Debug.Log("i"); // break; // case 'e': // target = e; // Debug.Log("e"); // break; // default: // break; //} if (count > currentWord.Length - 1) { start = false; Point[] mypoints = new Point[setPattern.Count]; mypoints = setPattern.ToArray(); PointPattern pa = new PointPattern(); pa.Name = mycurrentWord; pa.Points = mypoints; setPattern.Clear(); PointManager.AddInput(path, pa); } if (start) { findTarget(count); } count++; } //if (count >= currentWord.Length) //{ // start = false; //} // mycoroutine = move(chars, count, l); //StartCoroutine(mycoroutine); // //foreach (char c in mystring) //{ // switch (c) { // case 'h': // target = h; // // transform.position = Vector3.MoveTowards(transform.position, h, step); // Debug.Log("h"); // break; // case 'i': // target = i; // Debug.Log("i"); // break; // case 'e': // target = e; // Debug.Log("e"); // break; // default: // break; // } // move(target); //} }
// Update is called once per frame void Update() { /*check force*/ string cmd = CheckForRecievedData(); try { print(cmd); // print("tafe"); if (cmd.StartsWith("F")) //Got a force { // print("hey"); force = ParseFSRData(cmd); print(force); if (force > 300 && force < 490) //positoon soft touch { positioning = true; gettingPoints = false; } else if (force > 500) { positioning = false; gettingPoints = true; //while start //while (typing) //{ //p.X = mycursor.transform.position.x; //p.Y = mycursor.transform.position.y; // }//end while } else { gettingPoints = false; positioning = false; } } // else { force = 0; typing = false; positioning = false; } } catch (System.Exception) { Debug.Log("hie"); } /*position*/ if (positioning) { this.GetComponent <Renderer>().material.SetColor("_Color", Color.red); this.GetComponent <TrailRenderer>().widthMultiplier = 0.0f; this.GetComponent <TrailRenderer>().time = 0.01f; xpos = Input.GetAxis("Mouse X"); ypos = Input.GetAxis("Mouse Y"); displac.x = xpos * 0.3f; displac.y = ypos * 0.3f; displac.z = 0f; //float minX = -5.5f; //float maxX = 5.5f; //float minY = -2.4f; //float maxY = 2.4f; // displac.x = Mathf.Clamp(displac.x, minX, maxX); //displac.y = Mathf.Clamp(displac.y, minY, maxY); Vector3 position = this.transform.position; if (this.transform.position.x + displac.x < -5.5) { position.x = -5.5f; } else if (this.transform.position.x + displac.x > 5.5) { position.x = 5.5f; } else { position.x += displac.x; } if (this.transform.position.y + displac.y < -2.4) { position.y = -2.4f; } else if (this.transform.position.y + displac.y > 2.4) { position.y = 2.4f; } else { position.y += displac.y; } // position.y += displac.y; position.z += displac.z; try { this.transform.position = position; } catch (System.Exception) { } } /*get points */ if (gettingPoints) { this.GetComponent <Renderer>().material.SetColor("_Color", Color.green); this.GetComponent <TrailRenderer>().widthMultiplier = 0.1f; this.GetComponent <TrailRenderer>().time = 2f; xpos = Input.GetAxis("Mouse X"); ypos = Input.GetAxis("Mouse Y"); displac.x = xpos * 0.3f; displac.y = ypos * 0.3f; displac.z = 0f; Vector3 position = this.transform.position; if (this.transform.position.x + displac.x < -5.5) { position.x = -5.5f; } else if (this.transform.position.x + displac.x > 5.5) { position.x = 5.5f; } else { position.x += displac.x; } if (this.transform.position.y + displac.y < -2.4) { position.y = -2.4f; } else if (this.transform.position.y + displac.y > 2.4) { position.y = 2.4f; } else { position.y += displac.y; } // position.y += displac.y; position.z += displac.z; try { this.transform.position = position; } catch (System.Exception) { } p.X = this.transform.position.x; //xpos;// mycursor.transform.position.x; p.Y = this.transform.position.y; // ypos;// mycursor.transform.position.y; setPattern.Add(p); // drawingPattern[i] = p; i = i + 1; Debug.Log(i); } /*write word to json file*/ if (!gettingPoints && setPattern.Count > 0) { //change list to array Point[] mypoints = new Point[setPattern.Count]; mypoints = setPattern.ToArray(); PointPattern pa = new PointPattern(); pa.Name = "myword"; pa.Points = mypoints; setPattern.Clear(); PointManager.AddInput(path, pa); Debug.Log("shoooo"); } // Create a Point Pattern object // This is dependent on your inputs // Im using a default constructor in this case, Debug.Log("yes yebo"); //var pattern = new PointPattern(); //pattern.Name = "Falesto"; //pattern.Points = new Point[] { new Point { X = 100, Y = 300 }, new Point { X = 400, Y = 300 } }; //PointManager.AddInput(path, pattern); // Point Mannager is a static class with static methods. //PointManager.AddInput(path, pattern); // PointManager.ReadFile(path); }
float maxY = -1.56f; //2.4f; // public GameObject mycursor; // Use this for initialization void Start() { myempty.Name = "word"; myempty.Probability = 0; positioning = false; typing = false; /* metrics files*/ myf = string.Format(keyboard + "-metrics-{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now); //change date format g = string.Format(keyboard + "-events-{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now); myfilename = @"C:\Users\tjdub\Documents\" + myf + ".tsv"; eventfile = @"C:\Users\tjdub\Documents\" + g + ".tsv"; dir = @"C:\Users\tjdub\Documents\";//Directory.GetCurrentDirectory(); mypath = Path.Combine(dir, "File.json"); // mypath = @"C:\Users\tjdub\Documents\"; //myText = GameObject.Find("pText"); //myText.GetComponent<TextMesh>().text = ""; myAnalyzer.PointPatternSet = PointManager.ReadFile(mypath); phraseNumber = 0; backspace_counter = 0; ttext.GetComponent <Text>().text = ""; showTextToTranscribe(); //create file with headings /* string headings = String.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\r\n", * "TOTALPHRASES", "PHRASENUMBER", "PT", "TT", "PTLENGTH", "TTLENGHT", "WPM", "ER", "MSDER", "CER", "UCER", "TER", "BSPACE"); * * using (FileStream fs = File.Create(myfilename)) * { * Byte[] info = new UTF8Encoding(true).GetBytes(headings); * // Add some information to the file. * fs.Write(info, 0, info.Length); * }*/ //create eventfile /* string intro = "[]"; * * using (FileStream fs1 = File.Create(eventfile)) * { * Byte[] info = new UTF8Encoding(true).GetBytes(intro); * // Add some information to the file. * fs1.Write(info, 0, info.Length); * } * */ // for the fsr Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; f = string.Format("fsr_" + unixTimestamp); filename = @"C:\Users\tjdub\Documents\FSR_MPU9250\" + f + ".tsv"; string headings2 = String.Format("{0}\t{1}\t{2}\t\r\n", "FSR", "X", "Y"); using (FileStream fs = File.Create(filename)) { Byte[] info = new UTF8Encoding(true).GetBytes(headings2); // Add some information to the file. fs.Write(info, 0, info.Length); } stream.ReadTimeout = 50; stream.Open(); //end fsr }