カメラライトモーション実装中に見つけたバグを一旦コミット
モーションの回転の補完を間違えてX軸の補完にしていたのを修正
ベイク前のモーションを再生しないようなエンバグをしていたので修正
モーションの補間計算に使用していたニュートン法にミスがあったので修正。ついでに安全装置も付加
@@ -25,7 +25,7 @@ | ||
25 | 25 | //ボーンモーションデータの変換 |
26 | 26 | result.BoneMotions = new MMDBoneMotion[input.Motions.LongLength]; |
27 | 27 | if (result.BoneMotions.LongLength > int.MaxValue) |
28 | - throw new InvalidContentException("ボーンモーション数が多すぎます。MikuMikuDanceXNAは32bit符号付き整数最大値までしかモーション数をサポートしていません"); | |
28 | + throw new InvalidContentException("ボーンモーション数が多すぎます。MikuMikuDanceXNAは.NET Compact Frameworkの制限のため、32bit符号付き整数最大値までしかモーション数をサポートしていません"); | |
29 | 29 | for (long i = 0; i < result.BoneMotions.LongLength; i++) |
30 | 30 | { |
31 | 31 | result.BoneMotions[i] = new MMDBoneMotion(); |
@@ -33,7 +33,7 @@ | ||
33 | 33 | result.BoneMotions[i].FrameNo = input.Motions[i].FrameNo; |
34 | 34 | |
35 | 35 | 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++) | |
37 | 37 | { |
38 | 38 | BezierCurve curve = new BezierCurve(); |
39 | 39 | 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 @@ | ||
41 | 41 | result.BoneMotions[i].Curve[j] = curve; |
42 | 42 | } |
43 | 43 | |
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]; | |
48 | 44 | result.BoneMotions[i].Location = new Vector3(input.Motions[i].Location[0], input.Motions[i].Location[1], input.Motions[i].Location[2]); |
49 | 45 | 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]); |
50 | 46 | } |
@@ -51,7 +47,7 @@ | ||
51 | 47 | //表情モーションの変換 |
52 | 48 | result.FaceMotions = new MMDFaceMotion[input.FaceMotions.LongLength]; |
53 | 49 | if (result.FaceMotions.LongLength > int.MaxValue) |
54 | - throw new InvalidContentException("表情モーション数が多すぎます。MikuMikuDanceXNAは32bit符号付き整数最大値までしかモーション数をサポートしていません"); | |
50 | + throw new InvalidContentException("表情モーション数が多すぎます。MikuMikuDanceXNAは.NET Compact Frameworkの制限のため、32bit符号付き整数最大値までしかモーション数をサポートしていません"); | |
55 | 51 | for (long i = 0; i < input.FaceMotions.Length; i++) |
56 | 52 | { |
57 | 53 | result.FaceMotions[i] = new MMDFaceMotion(); |
@@ -60,8 +56,38 @@ | ||
60 | 56 | result.FaceMotions[i].FrameNo = input.FaceMotions[i].FrameNo; |
61 | 57 | float temp = input.FaceMotions[i].FrameNo; |
62 | 58 | } |
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 | + } | |
65 | 91 | //XNA用に変換したデータを返却 |
66 | 92 | return result; |
67 | 93 | } |