private IEnumerator GenerateBonePoseFile()
        {
            yield return(null);

            var context = (Context)data;
            var model   = ModelReader.LoadMmdModel(context.ModelPath, new ModelReadConfig {
                GlobalToonPath = ""
            });
            var motion = new VmdReader().Read(context.MotionPath);

            Debug.Log("motion load finished" + motion.Length + " frames");
            var generator =
                BonePoseFileGenerator.GenerateAsync(model, motion, context.SavePath, 1.0f / 60.0f, 5.0f, 1.0f / 120.0f);

            _generator = generator;
            while (true)
            {
                var generatorStatus = generator.Status;
                if (generatorStatus == BonePoseFileGenerator.GenerateStatus.Failed ||
                    generatorStatus == BonePoseFileGenerator.GenerateStatus.Finished ||
                    generatorStatus == BonePoseFileGenerator.GenerateStatus.Canceled)
                {
                    break;
                }
                if (generatorStatus == BonePoseFileGenerator.GenerateStatus.CalculatingFrames)
                {
                    _tipText.text = "已计算" + generator.CalculatedFrames + "帧, 共" + generator.TotalFrames + "帧。 已完成"
                                    + 100L * generator.CalculatedFrames / generator.TotalFrames + "%";
                }
                yield return(null);
            }
            if (generator.Status == BonePoseFileGenerator.GenerateStatus.Finished)
            {
                MainSceneController.Instance.ChangeCurrentBonePoseFile(context.SavePath);
            }
            ClosePage();
            switch (generator.Status)
            {
            case BonePoseFileGenerator.GenerateStatus.Finished:
                ShowPage <OkDialog>(new OkDialog.Context
                {
                    Title = "提示",
                    Tip   =
                        "计算完成。现在可以流畅地播放了。以后如果需要再次播放同模型配同动作,选择模型、动作后可以再载入已保存的动作结果文件。记得在选择结果文件时可能需要先点“扫描”才能看到计算结果文件。",
                    OnOk = () => { OnceTipPage.ShowOnceTip(TipNames.WhereIsBonePoseFile); }
                });
                break;

            case BonePoseFileGenerator.GenerateStatus.Failed:
                ShowPage <OkDialog>(new OkDialog.Context
                {
                    Title = "提示",
                    Tip   = "计算发生错误。"
                });
                break;
            }
        }
Esempio n. 2
0
        protected void Start()
        {
            var model = new PmxReader().Read(ModelPath, new ModelReadConfig {
                GlobalToonPath = ""
            });

            Debug.Log("model load finished");
            var motion = new VmdReader().Read(MotionPath);

            Debug.Log("motion load finished" + motion.Length + " frames");
            var bonePoseFileGenerator =
                BonePoseFileGenerator.GenerateAsync(model, motion, BonePoseFileOutputPath);

            StartCoroutine(CheckGenerateStatus(bonePoseFileGenerator));
        }
Esempio n. 3
0
 private IEnumerator CheckGenerateStatus(BonePoseFileGenerator generator)
 {
     while (true)
     {
         var generatorStatus = generator.Status;
         var statusStr       = generatorStatus.ToString();
         if (generatorStatus == BonePoseFileGenerator.GenerateStatus.CalculatingFrames)
         {
             statusStr = statusStr + " " + generator.CalculatedFrames + "/" + generator.TotalFrames;
         }
         StatusText.text = statusStr;
         if (generatorStatus == BonePoseFileGenerator.GenerateStatus.Failed)
         {
             break;
         }
         if (generatorStatus == BonePoseFileGenerator.GenerateStatus.Finished)
         {
             StartPlay();
             break;
         }
         yield return(null);
     }
 }