Пример #1
0
        public static Core.Motion Load(string dataPath)
        {
            Core.Motion motion = new Core.Motion();

            int readPoseCount = 0;

            using (var reader = new System.IO.StreamReader(dataPath))
            {
                Dictionary <string, Vector3> Js = new Dictionary <string, Vector3>();
                int currentFrame = 0;

                while (true)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    int frame = parseLine(line, Js);
                    if (frame >= 0)
                    {
                        var pose = ToPose(currentFrame, Js);
                        if (pose != null)
                        {
                            while (motion.Poses.Count < currentFrame)
                            {
                                motion.AddPose(pose);
                            }
                            readPoseCount++;
                        }
                        Js.Clear();
                        currentFrame = frame;
                    }
                }

                var finalPose = ToPose(currentFrame, Js);
                if (finalPose != null)
                {
                    while (motion.Poses.Count < currentFrame)
                    {
                        motion.AddPose(finalPose);
                    }
                    readPoseCount++;
                }

                Debug.LogFormat("read {0} poses | max frame no = {1}", readPoseCount, motion.Poses.Count);

                return(motion);
            }
        }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     motion_ = CMUMotionLoader.Load(DataPath);
 }