• R/O
  • SSH
  • HTTPS

mmdx: Commit


Commit MetaInfo

Revision67 (tree)
Zeit2010-03-20 19:47:19
Autorwilfrem

Log Message

モーションの適応をAnimationPlayerからNormalMotionTrackに移動

Ändern Zusammenfassung

Diff

--- trunk/MikuMikuDanceXNA/Motion/AnimationPlayer.cs (revision 66)
+++ trunk/MikuMikuDanceXNA/Motion/AnimationPlayer.cs (revision 67)
@@ -148,45 +148,7 @@
148148 {
149149 if (mmdMotion[i].Type == TrackType.NormalTrack)
150150 {
151- NormalMotionTrack track = (NormalMotionTrack)mmdMotion[i];
152- //現在の再生フレームを更新
153- //InnerUpdate(mmdMotion[i].motion, mmdMotion[i].GetFrame(FramePerSecond));
154- decimal NowFrame = track.GetFrame(FramePerSecond);
155-#if TRACE
156- if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
157- mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-MotionToBone", Color.BlueViolet);
158-#endif
159- //モーションのボーンリストを取得
160- List<string> motionBones = track.motion.GetBoneList();
161- //リストにあるボーンの位置を順番に更新
162- foreach (var bone in motionBones)
163- {
164- if (mmdModel.BoneManager.ContainsBone(bone))
165- {//存在しないボーンへのモーションは無視……
166- int boneIndex = mmdModel.BoneManager.IndexOf(bone);
167- QuatTransform move = track.motion.GetBoneTransform(bone, NowFrame);
168- //ボーン処理
169- mmdModel.BoneManager[boneIndex].BoneTransform = move * mmdModel.BoneManager[boneIndex].BoneData.BindPose;
170- }
171- }
172-#if TRACE
173- if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
174- {
175- mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-MotionToBone");
176- mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-Face", Color.BlueViolet);
177- }
178-#endif
179- //フェイスモーションの処理
180- List<string> faces = track.motion.GetFaceList();
181- //リストにあるフェイスのデータを順番に処理
182- foreach (var face in faces)
183- {
184- mmdModel.FaceManager.SetFace(face, track.motion.GetFaceRate(face, NowFrame));
185- }
186-#if TRACE
187- if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
188- mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-Face");
189-#endif
151+ mmdNMotion[i].ApplyMotion(mmdModel);
190152 }
191153 }
192154 }
--- trunk/MikuMikuDanceXNA/Motion/NormalMotionTrack.cs (revision 66)
+++ trunk/MikuMikuDanceXNA/Motion/NormalMotionTrack.cs (revision 67)
@@ -3,6 +3,9 @@
33 using System.Linq;
44 using System.Text;
55 using System.Diagnostics;
6+using MikuMikuDance.XNA.Model;
7+using MikuMikuDance.XNA.Model.ModelData;
8+using Microsoft.Xna.Framework.Graphics;
69
710 namespace MikuMikuDance.XNA.Motion
811 {
@@ -60,5 +63,47 @@
6063 }
6164 return frame % (decimal)motion.MaxFrame;
6265 }
66+
67+ public void ApplyMotion(MMDModel mmdModel)
68+ {
69+ //現在の再生フレームを更新
70+ //InnerUpdate(mmdMotion[i].motion, mmdMotion[i].GetFrame(FramePerSecond));
71+ decimal NowFrame = GetFrame(mmdModel.Player.FramePerSecond);
72+#if TRACE
73+ if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
74+ mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-MotionToBone", Color.BlueViolet);
75+#endif
76+ //モーションのボーンリストを取得
77+ List<string> motionBones = motion.GetBoneList();
78+ //リストにあるボーンの位置を順番に更新
79+ foreach (var bone in motionBones)
80+ {
81+ if (mmdModel.BoneManager.ContainsBone(bone))
82+ {//存在しないボーンへのモーションは無視……
83+ int boneIndex = mmdModel.BoneManager.IndexOf(bone);
84+ QuatTransform move = motion.GetBoneTransform(bone, NowFrame);
85+ //ボーン処理
86+ mmdModel.BoneManager[boneIndex].BoneTransform = move * mmdModel.BoneManager[boneIndex].BoneData.BindPose;
87+ }
88+ }
89+#if TRACE
90+ if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
91+ {
92+ mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-MotionToBone");
93+ mmdModel.mmdXNA.TimeRular.BeginMark(2, "Anime-Face", Color.BlueViolet);
94+ }
95+#endif
96+ //フェイスモーションの処理
97+ List<string> faces = motion.GetFaceList();
98+ //リストにあるフェイスのデータを順番に処理
99+ foreach (var face in faces)
100+ {
101+ mmdModel.FaceManager.SetFace(face, motion.GetFaceRate(face, NowFrame));
102+ }
103+#if TRACE
104+ if (mmdModel.mmdXNA.TimeRular != null && mmdModel.UseTimeRular)
105+ mmdModel.mmdXNA.TimeRular.EndMark(2, "Anime-Face");
106+#endif
107+ }
63108 }
64109 }
--- trunk/MikuMikuDanceXNA/Motion/MotionTrack.cs (revision 66)
+++ trunk/MikuMikuDanceXNA/Motion/MotionTrack.cs (revision 67)
@@ -3,6 +3,7 @@
33 using System.Diagnostics;
44 using System.Linq;
55 using System.Text;
6+using MikuMikuDance.XNA.Model;
67
78 namespace MikuMikuDance.XNA.Motion
89 {
@@ -24,6 +25,7 @@
2425 void Stop();
2526 decimal GetFrame(decimal FramePerSecond);
2627
28+ void ApplyMotion(MMDModel model);
2729 TrackType Type { get; }
2830 }
2931 }
Show on old repository browser