表情をベイク時に退避できてなかったので退避
@@ -11,7 +11,7 @@ | ||
11 | 11 | { |
12 | 12 | MMDModel model; |
13 | 13 | Vector4[] FaceTranslations;//頂点番号ごとの移動量 |
14 | - Dictionary<string, float> FaceRates;//適応中の表情リスト | |
14 | + internal Dictionary<string, float> FaceRates;//適応中の表情リスト | |
15 | 15 | Dictionary<string, int> FaceDictionary;//表情辞書 |
16 | 16 | int baseIndex; |
17 | 17 | //中からのみ |
@@ -150,7 +150,7 @@ | ||
150 | 150 | { |
151 | 151 | //現在の再生フレームを更新 |
152 | 152 | mmdMotion[i].UpdateFrame(mmdModel.Player.FramePerSecond); |
153 | - mmdMotion[i].ApplyMotion(mmdModel, ref BoneUpdated); | |
153 | + mmdMotion[i].ApplyMotion(mmdModel.BoneManager, mmdModel.FaceManager, ref BoneUpdated); | |
154 | 154 | } |
155 | 155 | } |
156 | 156 |
@@ -236,6 +236,8 @@ | ||
236 | 236 | { |
237 | 237 | PopedBones[i] = mmdModel.BoneManager[i].BoneTransform; |
238 | 238 | } |
239 | + Dictionary<string, float> PopedFaces = mmdModel.FaceManager.FaceRates; | |
240 | + mmdModel.FaceManager.FaceRates = new Dictionary<string, float>(); | |
239 | 241 | //ベイク |
240 | 242 | for (int Frame = 0; Frame < NumFrame; Frame++) |
241 | 243 | { |
@@ -242,7 +244,7 @@ | ||
242 | 244 | Array.Clear(BoneUpdated, 0, BoneUpdated.Length); |
243 | 245 | //現在の再生フレームをセットし更新 |
244 | 246 | normal.NowFrame = Frame; |
245 | - normal.ApplyMotion(mmdModel, ref BoneUpdated); | |
247 | + normal.ApplyMotion(mmdModel.BoneManager, mmdModel.FaceManager, ref BoneUpdated); | |
246 | 248 | |
247 | 249 | //IKボーンの処理前にモデルのワールド座標系更新 |
248 | 250 | mmdModel.BoneManager.UpdateWorldTransforms(); |
@@ -276,6 +278,7 @@ | ||
276 | 278 | { |
277 | 279 | mmdModel.BoneManager[i].BoneTransform = PopedBones[i]; |
278 | 280 | } |
281 | + mmdModel.FaceManager.FaceRates = PopedFaces; | |
279 | 282 | mmdModel.BoneManager.Update(); |
280 | 283 | } |
281 | 284 |
@@ -74,7 +74,7 @@ | ||
74 | 74 | } |
75 | 75 | NowFrame = frame % (decimal)Poses.GetLength(0); |
76 | 76 | } |
77 | - public void ApplyMotion(MMDModel mmdModel, ref bool[] BoneUpdated) | |
77 | + public void ApplyMotion(MMDBoneManager mmdBone, MMDFaceManager mmdFace, ref bool[] BoneUpdated) | |
78 | 78 | { |
79 | 79 | int Frame = (int)Math.Round(NowFrame); |
80 | 80 | if (Frame >= Poses.GetLength(0)) |
@@ -82,13 +82,13 @@ | ||
82 | 82 | for (int i = 0; i < Poses.GetLength(1); i++) |
83 | 83 | { |
84 | 84 | //計算済みトランスフォームを設定 |
85 | - mmdModel.BoneManager[Poses[Frame, i].BoneIndex].BoneTransform = Poses[Frame, i].Poses; | |
85 | + mmdBone[Poses[Frame, i].BoneIndex].BoneTransform = Poses[Frame, i].Poses; | |
86 | 86 | //IK計算済みなので、BoneUpdatedはOnにしない |
87 | 87 | } |
88 | 88 | for (int i = 0; i < Faces.GetLength(1); i++) |
89 | 89 | { |
90 | 90 | //保存済みFaceを設定 |
91 | - mmdModel.FaceManager.SetFace(Faces[Frame, i].FaceName, Faces[Frame, i].Rate); | |
91 | + mmdFace.SetFace(Faces[Frame, i].FaceName, Faces[Frame, i].Rate); | |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -66,7 +66,7 @@ | ||
66 | 66 | NowFrame = frame % (decimal)(motion.MaxFrame + 1); |
67 | 67 | } |
68 | 68 | |
69 | - public void ApplyMotion(MMDModel mmdModel, ref bool[] BoneUpdated) | |
69 | + public void ApplyMotion(MMDBoneManager mmdBone, MMDFaceManager mmdFace, ref bool[] BoneUpdated) | |
70 | 70 | { |
71 | 71 | //モーションのボーンリストを取得 |
72 | 72 | List<string> motionBones = motion.GetBoneList(); |
@@ -73,12 +73,12 @@ | ||
73 | 73 | //リストにあるボーンの位置を順番に更新 |
74 | 74 | foreach (var bone in motionBones) |
75 | 75 | { |
76 | - if (mmdModel.BoneManager.ContainsBone(bone)) | |
76 | + if (mmdBone.ContainsBone(bone)) | |
77 | 77 | {//存在しないボーンへのモーションは無視…… |
78 | - int boneIndex = mmdModel.BoneManager.IndexOf(bone); | |
78 | + int boneIndex = mmdBone.IndexOf(bone); | |
79 | 79 | QuatTransform move = motion.GetBoneTransform(bone, NowFrame); |
80 | 80 | //ボーン処理 |
81 | - mmdModel.BoneManager[boneIndex].BoneTransform = move * mmdModel.BoneManager[boneIndex].BoneData.BindPose; | |
81 | + mmdBone[boneIndex].BoneTransform = move * mmdBone[boneIndex].BoneData.BindPose; | |
82 | 82 | //UpdateフラグをOn |
83 | 83 | BoneUpdated[boneIndex] = true; |
84 | 84 | } |
@@ -88,7 +88,7 @@ | ||
88 | 88 | //リストにあるフェイスのデータを順番に処理 |
89 | 89 | foreach (var face in faces) |
90 | 90 | { |
91 | - mmdModel.FaceManager.SetFace(face, motion.GetFaceRate(face, NowFrame)); | |
91 | + mmdFace.SetFace(face, motion.GetFaceRate(face, NowFrame)); | |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -26,7 +26,7 @@ | ||
26 | 26 | |
27 | 27 | decimal NowFrame { get; set; } |
28 | 28 | long MaxFrame { get; } |
29 | - void ApplyMotion(MMDModel model, ref bool[] BoneUpdated); | |
29 | + void ApplyMotion(MMDBoneManager mmdBone, MMDFaceManager mmdFace, ref bool[] BoneUpdated); | |
30 | 30 | TrackType Type { get; } |
31 | 31 | |
32 | 32 | void UpdateFrame(decimal FramePerSecond); |