public static SkeletonBone[] cloneSkeleton( ref SkeletonBone[] bone ) { int size = bone.Length; SkeletonBone[] b = new HBP.SkeletonBone[size]; for(int i=0 ; i<size ; ++i) { b[i].posx = bone[i].posx; b[i].posy = bone[i].posy; b[i].posz = bone[i].posz; b[i].m11 = bone[i].m11; b[i].m12 = bone[i].m12; b[i].m13 = bone[i].m13; b[i].m21 = bone[i].m21; b[i].m22 = bone[i].m22; b[i].m23 = bone[i].m23; b[i].m31 = bone[i].m31; b[i].m32 = bone[i].m32; b[i].m33 = bone[i].m33; b[i].id = bone[i].id; } return b; }
public void Initialize_from_file(string path) { TextAsset txt_file = (TextAsset)Resources.Load(path, typeof(TextAsset)); StringReader reader = null; reader = new StringReader(txt_file.text); //TextReader txt_file = Resources.Load(path.ToString()) as TextAsset; //TextReader txt_file = new StringReader(path.ToString()); /*****************************************************************************************************/ // ITI Parse data from TEXT files to reference and recorded motion lists /*****************************************************************************************************/ // TODO SWITCH //motion = new List<HBP.SkeletonBone[]>(); numberFrames = 0; // Parse the file try { while (reader.ReadLine() != null) { HBP.SkeletonBone[] n_Bone = new HBP.SkeletonBone[_joint_number]; for (int i = 1; i < _joint_number + 1; i++) { n_Bone[i - 1] = new HBP.SkeletonBone(); string t_line = reader.ReadLine(); string[] t_values = t_line.Split(' '); ///////////////// Data parsing to HBP.SkeletonBone n_Bone[i - 1].posx = float.Parse(t_values[1]); n_Bone[i - 1].posy = float.Parse(t_values[2]); n_Bone[i - 1].posz = float.Parse(t_values[3]); n_Bone[i - 1].m11 = float.Parse(t_values[4]); n_Bone[i - 1].m12 = float.Parse(t_values[5]); n_Bone[i - 1].m13 = float.Parse(t_values[6]); n_Bone[i - 1].m21 = float.Parse(t_values[7]); n_Bone[i - 1].m22 = float.Parse(t_values[8]); n_Bone[i - 1].m23 = float.Parse(t_values[9]); n_Bone[i - 1].m31 = float.Parse(t_values[10]); n_Bone[i - 1].m32 = float.Parse(t_values[11]); n_Bone[i - 1].m33 = float.Parse(t_values[12]); n_Bone[i - 1].id = Marshal.StringToBSTR(t_values[0]); } // Add new frame in the list // TODO SWITCH //motion.Add(n_Bone); numberFrames++; ///// parse empty lines for (int j = 0; j < 1; j++) { reader.ReadLine(); } } } catch { Debug.Log("There was a problem during import of external animation"); } Debug.Log("Number of frames: "+numberFrames); }