public static MMDMotion2 bake(MMDMotion2 motion, MMDModel1 model) { //ボーン取得 MMDBoneManager boneManager = ModelConverter.BuildBoneManager(model); //ベイク前のモーションとベイク後のモーションを準備 MMDMotion beforeMotion = MotionConverter.Convert(motion); MMDMotion afterMotion = CreateAfterMotionPrototype(beforeMotion, boneManager); //アニメーションプレイヤーを作成 AnimationPlayer player = new AnimationPlayer(boneManager); player.SetMotion(beforeMotion); //ベイクしていく uint frameNo = 0; bool ExitFlag = false; while (!ExitFlag) { ExitFlag = !player.Update(); //ボーンのグローバル行列更新 boneManager.CalcGlobalTransform(); //IK更新 boneManager.CalcIK(); //ベイク boneManager.bake(frameNo, afterMotion); ++frameNo; } //元のMMDMotion2に直して返却 return(MotionConverter.Convert(afterMotion, motion.ModelName)); }