diff --git a/Assets/Gesture/Gesture.cs b/Assets/Gesture/Gesture.cs index 97727764dc543771d2c5441f8a708d9b77b6ab65..7fd8b282d34fa93071f05173618c81204d5af575 100644 --- a/Assets/Gesture/Gesture.cs +++ b/Assets/Gesture/Gesture.cs @@ -118,42 +118,14 @@ public class Gesture Debug.Log ("[VerifyNormalization] furthestDistance: " + furthestDistance); } - public void Load () - { - StreamReader reader = new StreamReader(directoryPath + name + ".txt"); - CSVOutputGrid csvGrid = CSVReader.SplitCsvGrid (reader.ReadToEnd ()); - string[,] csvStrings = csvGrid.grid; - //Debug.Log("csvStrings " + name + " length:" + csvGrid.linesLength); - - states = new List<GestureState>(); - for (int i = 0; i < csvGrid.linesLength; i++) - { - if (i < 2) //dont take 2 first lines into account - continue; - - if (csvStrings == null) - break; - - //we need timestamp, x, y, z of palm - string[] line = csvStrings[0,i].Split (' '); - - //for now we only save the left palm's coordinates - GestureState state = new GestureState (); - state.timestamp = float.Parse(line [0]); - state.position.x = float.Parse(line [1]); - state.position.y = float.Parse(line [2]); - state.position.z = float.Parse(line [3]); - state.rotation.x = float.Parse(line [4]); - state.rotation.y = float.Parse(line [5]); - state.rotation.z = float.Parse(line [6]); - state.rotation.w = float.Parse(line [7]); - states.Add (state); - - //Debug.Log(state); - } - reader.Close(); + public void Load() + { + states = GestureLoader.Load (FullPath ()); + } - //Debug.Log("Gesture " + name + " loaded."); + private string FullPath() + { + return directoryPath + name + ".txt"; } public override string ToString () diff --git a/Assets/Gesture/GestureLoader.cs b/Assets/Gesture/GestureLoader.cs new file mode 100644 index 0000000000000000000000000000000000000000..3bc7e5f9535b38c154475a45353c3d80fd2924fe --- /dev/null +++ b/Assets/Gesture/GestureLoader.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using System.IO; + +public class GestureLoader +{ + public static List<GestureState> Load (string fullpath) + { + StreamReader reader = new StreamReader(fullpath); + CSVOutputGrid csvGrid = CSVReader.SplitCsvGrid (reader.ReadToEnd ()); + string[,] csvStrings = csvGrid.grid; + + List<GestureState> states = new List<GestureState>(); + for (int i = 0; i < csvGrid.linesLength; i++) + { + if (i < 2) //dont take 2 first lines into account + continue; + + if (csvStrings == null) + break; + + //we need timestamp, x, y, z of palm + string[] line = csvStrings[0,i].Split (' '); + + //for now we only save the left palm's coordinates + GestureState state = new GestureState (); + state.timestamp = float.Parse(line [0]); + state.position.x = float.Parse(line [1]); + state.position.y = float.Parse(line [2]); + state.position.z = float.Parse(line [3]); + state.rotation.x = float.Parse(line [4]); + state.rotation.y = float.Parse(line [5]); + state.rotation.z = float.Parse(line [6]); + state.rotation.w = float.Parse(line [7]); + states.Add (state); + } + reader.Close(); + + return states; + } +} diff --git a/Assets/Gesture/GestureLoader.cs.meta b/Assets/Gesture/GestureLoader.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..cfe08277d5ba32efb79a536ea1a9bb169197b5e2 --- /dev/null +++ b/Assets/Gesture/GestureLoader.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 61939fbdd2bf91345bc9f441d1980429 +timeCreated: 1515598830 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: