• R/O
  • SSH
  • HTTPS

mmdx: Commit


Commit MetaInfo

Revision853 (tree)
Zeit2011-06-12 20:36:15
Autorwilfrem

Log Message

箱ボーン組み込み途中まで。WritableVertexBufferの実装を忘れてたことを思い出した。

Ändern Zusammenfassung

Diff

--- branches/XNA4/MikuMikuDanceXNA/Model/MMDXBoxBoneManager.cs (nonexistent)
+++ branches/XNA4/MikuMikuDanceXNA/Model/MMDXBoxBoneManager.cs (revision 853)
@@ -0,0 +1,54 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using MikuMikuDance.Core.Model;
6+using MikuMikuDance.XNA.Misc;
7+using MikuMikuDance.Core.Misc;
8+using Microsoft.Xna.Framework;
9+
10+namespace MikuMikuDance.XNA.Model
11+{
12+ /// <summary>
13+ /// XBox向けボーンマネージャ拡張(vfetch対応)
14+ /// </summary>
15+ class MMDXBoxBoneManager : MMDBoneManager
16+ {
17+ VertexSkinning[] skinTransformsXBox;
18+ /// <summary>
19+ /// このプロパティは使えません。
20+ /// </summary>
21+ public override Microsoft.Xna.Framework.Matrix[] SkinTransforms
22+ {
23+ get
24+ {
25+ throw new InvalidOperationException();//この操作はさせない。
26+ }
27+ }
28+ /// <summary>
29+ /// スキニング行列(vfetch対応)
30+ /// </summary>
31+ public virtual VertexSkinning[] SkinTransformsXBox { get { return skinTransformsXBox; } }
32+
33+ public MMDXBoxBoneManager(List<MMDBone> bones, List<MMDIK> iks)
34+ : base(bones, iks)
35+ {
36+ skinTransformsXBox = new VertexSkinning[bones.Count];
37+ }
38+ /// <summary>
39+ /// スキニング行列の計算
40+ /// </summary>
41+ public override void CalcSkinTransform()
42+ {
43+ for (int i = 0; i < Count; ++i)
44+ {
45+ Matrix temp;
46+ Vector3 temp2;
47+ Matrix.Multiply(ref this[i].InverseBindPose, ref this[i].GlobalTransform, out temp);
48+ temp.Decompose(out temp2, out skinTransformsXBox[i].Rotation, out skinTransformsXBox[i].Translation);
49+ }
50+ //ここでスキニング行列を書き込む
51+
52+ }
53+ }
54+}
--- branches/XNA4/MikuMikuDanceXNA/Model/MMDModelPart.cs (revision 852)
+++ branches/XNA4/MikuMikuDanceXNA/Model/MMDModelPart.cs (revision 853)
@@ -18,8 +18,11 @@
1818 Effect effect;
1919 IEffectMatrices effectMartices;
2020 IEffectLights effectLights;
21-
2221 /// <summary>
22+ /// このパーツに関連付けられているモデル
23+ /// </summary>
24+ protected MMDXModel model;
25+ /// <summary>
2326 /// モデルのトライアングル数
2427 /// </summary>
2528 protected readonly int triangleCount;
@@ -92,6 +95,10 @@
9295 this.VertMap = vertMap;
9396
9497 }
98+ public void SetModel(MMDModel model)
99+ {
100+ this.model = (MMDXModel)model;
101+ }
95102 /// <summary>
96103 /// エフェクトにマトリックスを適用
97104 /// </summary>
--- branches/XNA4/MikuMikuDanceXNA/Model/MMDXModel.cs (revision 852)
+++ branches/XNA4/MikuMikuDanceXNA/Model/MMDXModel.cs (revision 853)
@@ -6,6 +6,7 @@
66 using MikuMikuDance.Core.Motion;
77 using MikuMikuDance.Core.Model.Physics;
88 using Microsoft.Xna.Framework;
9+using Microsoft.Xna.Framework.Graphics;
910
1011 namespace MikuMikuDance.XNA.Model
1112 {
@@ -14,6 +15,8 @@
1415 /// </summary>
1516 public class MMDXModel : MMDModel
1617 {
18+ DynamicVertexBuffer skinningVertex = null;
19+
1720 /// <summary>
1821 /// コンストラクタ
1922 /// </summary>
@@ -26,6 +29,7 @@
2629 public MMDXModel(List<IMMDModelPart> modelParts, MMDBoneManager boneManager, IMMDFaceManager faceManager, Dictionary<string, MMDMotion> attachedMotion, MMDRigid[] rigids, MMDJoint[] joints)
2730 : base(modelParts, boneManager, faceManager, attachedMotion, rigids, joints)
2831 {
32+ //スキニング行列を作成
2933
3034 }
3135 /// <summary>
--- branches/XNA4/MikuMikuDanceXNA/Model/MMDBoneManagerReader.cs (revision 852)
+++ branches/XNA4/MikuMikuDanceXNA/Model/MMDBoneManagerReader.cs (revision 853)
@@ -25,7 +25,11 @@
2525 List<MMDIK> iks = input.ReadObject<List<MMDIK>>();
2626 //ボーンインデックス→ボーンオブジェクト化
2727 SkinningHelpers.IKSetup(iks, bones);
28+#if !XBOX
2829 return new MMDBoneManager(bones, iks);
30+#else
31+ return new MMDXBoxBoneManager(bones, iks);
32+#endif
2933 }
3034
3135 }
--- branches/XNA4/MikuMikuDanceCore/Model/MMDBoneManager.cs (revision 852)
+++ branches/XNA4/MikuMikuDanceCore/Model/MMDBoneManager.cs (revision 853)
@@ -29,7 +29,7 @@
2929 /// <summary>
3030 /// スキニング行列
3131 /// </summary>
32- public Matrix[] SkinTransforms { get; private set; }
32+ public virtual Matrix[] SkinTransforms { get; private set; }
3333 /// <summary>
3434 /// コンストラクタ
3535 /// </summary>
--- branches/XNA4/MikuMikuDanceCore/Model/IMMDModelPart.cs (revision 852)
+++ branches/XNA4/MikuMikuDanceCore/Model/IMMDModelPart.cs (revision 853)
@@ -35,5 +35,10 @@
3535 /// </summary>
3636 /// <param name="faceManager"></param>
3737 void SetFace(IMMDFaceManager faceManager);
38+ /// <summary>
39+ /// モデル追加時に呼ばれる
40+ /// </summary>
41+ /// <param name="model">親モデル</param>
42+ void SetModel(MMDModel model);
3843 }
3944 }
--- branches/XNA4/MikuMikuDanceCore/Model/MMDModel.cs (revision 852)
+++ branches/XNA4/MikuMikuDanceCore/Model/MMDModel.cs (revision 853)
@@ -79,6 +79,8 @@
7979 boneManager.CalcGlobalTransform();
8080 this.physicsManager = new PhysicsManager(rigids, joints, this);
8181
82+ foreach (var part in modelParts)
83+ part.SetModel(this);
8284 Parts = new ReadOnlyCollection<IMMDModelPart>(modelParts);
8385 animationPlayer = new AnimationPlayer(boneManager, faceManager);
8486
Show on old repository browser