• R/O
  • SSH
  • HTTPS

mmdx: Commit


Commit MetaInfo

Revision80 (tree)
Zeit2010-03-21 19:47:40
Autorwilfrem

Log Message

カメラライトモーション実装中に見つけたバグを一旦コミット
モーションの回転の補完を間違えてX軸の補完にしていたのを修正
ベイク前のモーションを再生しないようなエンバグをしていたので修正
モーションの補間計算に使用していたニュートン法にミスがあったので修正。ついでに安全装置も付加

Ändern Zusammenfassung

Diff

--- trunk/MMDImporter/Motion/MMDMotionProcessor.cs (revision 79)
+++ trunk/MMDImporter/Motion/MMDMotionProcessor.cs (revision 80)
@@ -25,7 +25,7 @@
2525 //ボーンモーションデータの変換
2626 result.BoneMotions = new MMDBoneMotion[input.Motions.LongLength];
2727 if (result.BoneMotions.LongLength > int.MaxValue)
28- throw new InvalidContentException("ボーンモーション数が多すぎます。MikuMikuDanceXNAは32bit符号付き整数最大値までしかモーション数をサポートしていません");
28+ throw new InvalidContentException("ボーンモーション数が多すぎます。MikuMikuDanceXNAは.NET Compact Frameworkの制限のため、32bit符号付き整数最大値までしかモーション数をサポートしていません");
2929 for (long i = 0; i < result.BoneMotions.LongLength; i++)
3030 {
3131 result.BoneMotions[i] = new MMDBoneMotion();
@@ -33,7 +33,7 @@
3333 result.BoneMotions[i].FrameNo = input.Motions[i].FrameNo;
3434
3535 result.BoneMotions[i].Curve = new BezierCurve[4];
36- for (int j = 0; j < 3; j++)
36+ for (int j = 0; j < result.BoneMotions[i].Curve.Length; j++)
3737 {
3838 BezierCurve curve = new BezierCurve();
3939 curve.v1 = new Vector2((float)input.Motions[i].Interpolation[0][0][j] / 128f, (float)input.Motions[i].Interpolation[0][1][j] / 128f);
@@ -41,10 +41,6 @@
4141 result.BoneMotions[i].Curve[j] = curve;
4242 }
4343
44- //for (int j1 = 0; j1 < input.Motions[i].Interpolation.Length; j1++)
45- // for (int j2 = 0; j2 < input.Motions[i].Interpolation[j1].Length; j2++)
46- // for (int j3 = 0; j3 < input.Motions[i].Interpolation[j1][j2].Length; j3++)
47- // result.BoneMotions[i].Interpolation[j1][j2][j3] = input.Motions[i].Interpolation[j1][j2][j3];
4844 result.BoneMotions[i].Location = new Vector3(input.Motions[i].Location[0], input.Motions[i].Location[1], input.Motions[i].Location[2]);
4945 result.BoneMotions[i].Quatanion = new Quaternion(input.Motions[i].Quatanion[0], input.Motions[i].Quatanion[1], input.Motions[i].Quatanion[2], input.Motions[i].Quatanion[3]);
5046 }
@@ -51,7 +47,7 @@
5147 //表情モーションの変換
5248 result.FaceMotions = new MMDFaceMotion[input.FaceMotions.LongLength];
5349 if (result.FaceMotions.LongLength > int.MaxValue)
54- throw new InvalidContentException("表情モーション数が多すぎます。MikuMikuDanceXNAは32bit符号付き整数最大値までしかモーション数をサポートしていません");
50+ throw new InvalidContentException("表情モーション数が多すぎます。MikuMikuDanceXNAは.NET Compact Frameworkの制限のため、32bit符号付き整数最大値までしかモーション数をサポートしていません");
5551 for (long i = 0; i < input.FaceMotions.Length; i++)
5652 {
5753 result.FaceMotions[i] = new MMDFaceMotion();
@@ -60,8 +56,38 @@
6056 result.FaceMotions[i].FrameNo = input.FaceMotions[i].FrameNo;
6157 float temp = input.FaceMotions[i].FrameNo;
6258 }
63- //ライト、カメラモーションは後で実装
64-
59+ //カメラモーションの変換
60+ result.CameraMotions = new MMDCameraMotion[input.CameraMotions.LongLength];
61+ if (result.CameraMotions.LongLength > int.MaxValue)
62+ throw new InvalidContentException("カメラモーション数が多すぎます。MikuMikuDanceXNAは.NET Compact Frameworkの制限のため、32bit符号付き整数最大値までしかモーション数をサポートしていません");
63+ for (long i = 0; i < input.CameraMotions.Length; i++)
64+ {
65+ result.CameraMotions[i] = new MMDCameraMotion();
66+ result.CameraMotions[i].FrameNo = input.CameraMotions[i].FrameNo;
67+ result.CameraMotions[i].Length = input.CameraMotions[i].Length;
68+ result.CameraMotions[i].Location = MMDMath.VectorFromArray(input.CameraMotions[i].Location);
69+ result.CameraMotions[i].Quatanion = Quaternion.CreateFromYawPitchRoll(input.CameraMotions[i].Rotate[1], input.CameraMotions[i].Rotate[0], input.CameraMotions[i].Rotate[2]);
70+ result.CameraMotions[i].ViewAngle = MathHelper.ToRadians(input.CameraMotions[i].ViewingAngle);
71+ result.CameraMotions[i].Curve = new BezierCurve[6];
72+ for (int j = 0; j < result.CameraMotions[i].Curve.Length; j++)
73+ {
74+ BezierCurve curve = new BezierCurve();
75+ curve.v1 = new Vector2((float)input.CameraMotions[i].Interpolation[j][0] / 128f, (float)input.CameraMotions[i].Interpolation[j][2] / 128f);
76+ curve.v2 = new Vector2((float)input.CameraMotions[i].Interpolation[j][1] / 128f, (float)input.CameraMotions[i].Interpolation[j][3] / 128f);
77+ result.CameraMotions[i].Curve[j] = curve;
78+ }
79+ }
80+ //ライトモーションの変換
81+ result.LightMotions = new MMDLightMotion[input.LightMotions.LongLength];
82+ if (result.LightMotions.LongLength > int.MaxValue)
83+ throw new InvalidContentException("ライトモーション数が多すぎます。MikuMikuDanceXNAは.NET Compact Frameworkの制限のため、32bit符号付き整数最大値までしかモーション数をサポートしていません");
84+ for (long i = 0; i < input.LightMotions.Length; i++)
85+ {
86+ result.LightMotions[i] = new MMDLightMotion();
87+ result.LightMotions[i].FrameNo = input.LightMotions[i].FrameNo;
88+ result.LightMotions[i].Color = MMDMath.VectorFromArray(input.LightMotions[i].Color);
89+ result.LightMotions[i].Location = MMDMath.VectorFromArray(input.LightMotions[i].Location);
90+ }
6591 //XNA用に変換したデータを返却
6692 return result;
6793 }
Show on old repository browser