public MatrixIndexer(List <float[]> fFrames, BVHContent bvh) { for (int f = 0; f < fFrames.Count; f++) { indices.Add(new List <int>()); //Add new frame to collection. for (int b = 0; b < bvh.Skeleton.BoneCount; b++) { #region Set indices BVHNode bone = bvh[b]; FrameCalc fc = bone.calc_fc_from_frame(fFrames[f]); //get frame calc of current matrix. indices[indices.Count - 1].Add(get_index(fc, b, f)); //find index of matrix and add it to frame. #endregion } } #region Calculate matrices from frmCalcs matrices = new Matrix[frmCalcs.Count]; for (int i = 0; i < matrices.Length; i++) { matrices[i] = frmCalcs[i].calc_frame(); } #endregion frmCalcs = null;//Allows Garbage Collector to dispose }
/// <summary> /// Calculates a FrameCalc from a given frame. /// </summary> /// <param name="arr">Frame values.</param> /// <returns>FrameCalc of this node.</returns> public FrameCalc calc_fc_from_frame(float[] arr) { FrameCalc frame = new FrameCalc(this.Name, this.Offset); for (int i = 0; i < Channels.Length; i++) { BoneChannel bc = Channels[i]; frame.update_channel_values(bc.channel, arr[bc.pifl]); } return(frame); }
/// <summary> /// If f is not in collection, add it. /// </summary> /// <param name="f">Frame matrix information of one bone.</param> /// <returns>The index of the frame in collection.</returns> private int get_index(FrameCalc f, int boneid, int frame) { if (frame > 0) { if (frmCalcs[indices[frame - 1][boneid]] == f) { return(indices[frame - 1][boneid]); } } frmCalcs.Add(f); //not found in collection, so add. return(frmCalcs.Count - 1); }