Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //コンソールアプリ作りたいわけじゃないのでハードコーディングしとく
            string     InputPMD  = "miku.pmd";
            string     InputVMD  = "TrueMyHeart.vmd";
            string     OutputVMD = "tmh_bake.vmd";
            MMDModel1  model     = (MMDModel1)ModelManager.Read(InputPMD, MikuMikuDance.Model.CoordinateType.RightHandedCoordinate);
            MMDMotion2 motion    = (MMDMotion2)MotionManager.Read(InputVMD, MikuMikuDance.Motion.CoordinateType.RightHandedCoordinate);

            motion = IKBaker.bake(motion, model);
            MotionManager.Write(OutputVMD, motion);
        }
Ejemplo n.º 2
0
        private void startBake_Click(object sender, EventArgs e)
        {
            // 入力チェック
            if (!File.Exists(pmdFileName.Text))
            {
                MessageBox.Show(
                    "PMDファイルが見つかりません!:\n" + pmdFileName.Text,
                    "PMD読み込みエラー",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            if (!File.Exists(vmdFileName.Text))
            {
                MessageBox.Show(
                    "VMDファイルが見つかりません!:\n" + vmdFileName.Text,
                    "VMD読み込みエラー",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // saveVMDの上書き確認
            if (File.Exists(saveVmdName.Text))
            {
                var result = MessageBox.Show(
                    "VMDファイルが存在します。\n" + saveVmdName.Text + "\n上書きしてよろしいですか?",
                    "上書き確認",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question);

                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                // bakeでエラー出るっぽいので削除しておく
                File.Delete(saveVmdName.Text);
            }

            // Bake!
            try
            {
                MMDModel1  model  = (MMDModel1)ModelManager.Read(pmdFileName.Text, MikuMikuDance.Model.CoordinateType.RightHandedCoordinate);
                MMDMotion2 motion = (MMDMotion2)MotionManager.Read(vmdFileName.Text, MikuMikuDance.Motion.CoordinateType.RightHandedCoordinate);
                motion = IKBaker.bake(motion, model);
                MotionManager.Write(saveVmdName.Text, motion);

                MessageBox.Show(
                    "Bake完了",
                    "Baked!!");
            }
            catch
            {
                MessageBox.Show(
                    "Bake中にエラーが発生しました",
                    "未知のエラー",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
        }