/// <summary> /// Writes a multistroke gesture to an XML file /// </summary> public static void WriteGesture(PDollarGestureRecognizer.Point[] points, string gestureName, string fileName) { using (StreamWriter sw = new StreamWriter(fileName)) { sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"); sw.WriteLine("<Gesture Name = \"{0}\">", gestureName); int currentStroke = -1; for (int i = 0; i < points.Length; i++) { if (points[i].StrokeID != currentStroke) { if (i > 0) sw.WriteLine("\t</Stroke>"); sw.WriteLine("\t<Stroke>"); currentStroke = points[i].StrokeID; } sw.WriteLine("\t\t<Point X = \"{0}\" Y = \"{1}\" T = \"0\" Pressure = \"0\" />", points[i].X, points[i].Y ); } sw.WriteLine("\t</Stroke>"); sw.WriteLine("</Gesture>"); } }
public void Cast(string gestureClass, PDollarGestureRecognizer.Gesture gesture, LineRenderer line) { Debug.Log ("Cast " + gestureClass + "!"); switch (gestureClass) { case("Circle"): float maxX = float.MinValue; float minX = float.MaxValue; float maxY = float.MinValue; float minY = float.MaxValue; foreach(PDollarGestureRecognizer.Point point in gesture.Points){ if(point.X > maxX){ maxX = point.X; } if(point.X < minX){ minX = point.X; } if(point.Y > maxY){ maxY = point.Y; } if(point.Y < minY){ minY = point.Y; } } Vector3 center = new Vector3((maxX + minX)/2, 1, (maxY + minY)/2); line.SetVertexCount (33); line.SetPosition (32, center); Debug.Log (center); break; case("line"): break; case("X"): break; } }