示例#1
0
        public IDanceMotion CreateDanceMotion(string[] bones)
        {
            IDanceMotion result;

            using (StreamReader streamReader = new StreamReader(this.fileName))
            {
                result = DanceMotionFactoryFromCSV.ReadMotion(streamReader, Path.GetFileNameWithoutExtension(this.fileName));
            }
            return(result);
        }
示例#2
0
        private static DanceMotion ReadMotion(TextReader reader, string name)
        {
            string[] array     = DanceMotionFactoryFromCSV.SplitByComma(reader.ReadLine());
            int      beatCount = int.Parse(array[0]);

            string[] tags  = array.Skip(1).ToArray <string>();
            string[] bones = reader.ReadLine().Split(new char[]
            {
                ','
            }, StringSplitOptions.RemoveEmptyEntries);
            List <DancePose> list = new List <DancePose>();

            for (string text = reader.ReadLine(); text != null; text = reader.ReadLine())
            {
                try
                {
                    BoneState[] items = (
                        from str in text.Split(new char[]
                    {
                        ','
                    }, StringSplitOptions.RemoveEmptyEntries)
                        select str.Split(new char[]
                    {
                        ' '
                    }, StringSplitOptions.RemoveEmptyEntries) into tokens
                        select Array.ConvertAll <string, float>(tokens, (string s) => float.Parse(s)) into value
                        select new CtQuaternion(value[0], value[1], value[2], value[3]) into quaternion
                        select new BoneState(quaternion)).ToArray <BoneState>();
                    list.Add(new DancePose(bones, items));
                }
                catch
                {
                }
            }
            return(new DanceMotion(name, beatCount, list.ToArray(), null)
            {
                Tags = tags
            });
        }