Violet Vreath is Shooter Game for Windows XP+(個人制作シューティングゲーム)
Revisión | 926de641be76de2d50310867f7597135322313d8 (tree) |
---|---|
Tiempo | 2020-01-11 01:48:24 |
Autor | gecchi <gecchi@XPS8...> |
Commiter | gecchi |
SkinMeshアニメーション勉強中・・・
@@ -23,7 +23,8 @@ public: | ||
23 | 23 | D3DXHANDLE _h_specular; |
24 | 24 | D3DXHANDLE _h_specular_power; |
25 | 25 | D3DXHANDLE _h_posCam; |
26 | - D3DXHANDLE _ah_matWorld[30]; | |
26 | + D3DXHANDLE _ah_matBone[30]; | |
27 | + D3DXHANDLE _ah_matBoneOffset[30]; | |
27 | 28 | |
28 | 29 | public: |
29 | 30 | /** |
@@ -19,11 +19,13 @@ class SkinAniMeshModel : public Model { | ||
19 | 19 | |
20 | 20 | public: |
21 | 21 | /** 頂点のFVF */ |
22 | - static DWORD FVF; | |
23 | 22 | struct VERTEX : public Model::VERTEX_3D_BASE { |
24 | 23 | float index; // psizeではなくてはなくて頂点番号として使用。何フレーム目かするために使用。 |
25 | 24 | DWORD color; // 頂点の色(オブジェクトのマテリアルカラーとして使用) |
26 | 25 | float tu, tv; // テクスチャ座標 |
26 | + | |
27 | + float infl_weight[4]; // 頂点重み | |
28 | + byte infl_bone_idx[4]; | |
27 | 29 | }; |
28 | 30 | struct INDEXPARAM { |
29 | 31 | UINT MaterialNo; |
@@ -38,6 +40,8 @@ public: | ||
38 | 40 | WORD* _paIndexBuffer_data; |
39 | 41 | /** インデックスバッファ番号に対応する頂点バッファのフレームメッシュ番号 */ |
40 | 42 | int* _paIndexBuffer_frame_no; |
43 | + /** シェーダー入力頂点フォーマット */ | |
44 | + LPDIRECT3DVERTEXDECLARATION9 _pVertexDeclaration; | |
41 | 45 | /** 頂点バッファ(全フレームのメッシュ分) */ |
42 | 46 | LPDIRECT3DVERTEXBUFFER9 _pVertexBuffer; |
43 | 47 | /** インデックスバッファ(全フレームのメッシュ分) */ |
@@ -61,7 +65,7 @@ public: | ||
61 | 65 | |
62 | 66 | /** _pFrameRoot を巡ってフレームを直列化したもの、要素番号はフレームインデックスと呼称する */ |
63 | 67 | std::vector<SkinAniMeshFrame*> _vecAllBoneFrame; |
64 | - /** _pFrameRoot を巡ってメッシュコンテナがある描画対象フレームを直列化したもの、要素番号はただの連番 */ | |
68 | + /** _pFrameRoot を巡って描画対象があるフレームを直列化したもの、要素番号はただの連番 */ | |
65 | 69 | std::vector<SkinAniMeshFrame*> _vecDrawBoneFrame; |
66 | 70 | |
67 | 71 |
@@ -12,7 +12,7 @@ namespace GgafDx { | ||
12 | 12 | class SkinAniMeshFrame : public BoneAniMeshFrame { |
13 | 13 | public: |
14 | 14 | D3DXMATRIX _bone_offset_matrix; // ボーンオフセット行列 |
15 | - D3DXMATRIX _conbined_matrix; // 合成行列 | |
15 | + D3DXMATRIX _combined_matrix; // 合成行列 | |
16 | 16 | }; |
17 | 17 | |
18 | 18 | } |
@@ -29,7 +29,7 @@ SkinAniMeshEffect::SkinAniMeshEffect(const char* prm_effect_name) : Effect(prm_e | ||
29 | 29 | checkDxException(hr, D3D_OK, "SetFloat(g_zf) に失敗しました。"); |
30 | 30 | //シェーダーハンドル |
31 | 31 | _h_matView = _pID3DXEffect->GetParameterByName( nullptr, "g_matView" ); |
32 | -// _h_matWorld = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld" ); | |
32 | +// _h_matBone = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone" ); | |
33 | 33 | _h_specular = _pID3DXEffect->GetParameterByName( nullptr, "g_specular" ); |
34 | 34 | _h_specular_power = _pID3DXEffect->GetParameterByName( nullptr, "g_specular_power" ); |
35 | 35 | _h_posCam = _pID3DXEffect->GetParameterByName( nullptr, "g_posCam_World" ); |
@@ -39,36 +39,68 @@ SkinAniMeshEffect::SkinAniMeshEffect(const char* prm_effect_name) : Effect(prm_e | ||
39 | 39 | |
40 | 40 | //シェーダーハンドル |
41 | 41 | _h_matView = _pID3DXEffect->GetParameterByName( nullptr, "g_matView" ); |
42 | - _ah_matWorld[0] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld001" ); | |
43 | - _ah_matWorld[1] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld002" ); | |
44 | - _ah_matWorld[2] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld003" ); | |
45 | - _ah_matWorld[3] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld004" ); | |
46 | - _ah_matWorld[4] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld005" ); | |
47 | - _ah_matWorld[5] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld006" ); | |
48 | - _ah_matWorld[6] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld007" ); | |
49 | - _ah_matWorld[7] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld008" ); | |
50 | - _ah_matWorld[8] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld009" ); | |
51 | - _ah_matWorld[9] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld010" ); | |
52 | - _ah_matWorld[10] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld011" ); | |
53 | - _ah_matWorld[11] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld012" ); | |
54 | - _ah_matWorld[12] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld013" ); | |
55 | - _ah_matWorld[13] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld014" ); | |
56 | - _ah_matWorld[14] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld015" ); | |
57 | - _ah_matWorld[15] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld016" ); | |
58 | - _ah_matWorld[16] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld017" ); | |
59 | - _ah_matWorld[17] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld018" ); | |
60 | - _ah_matWorld[18] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld019" ); | |
61 | - _ah_matWorld[19] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld020" ); | |
62 | - _ah_matWorld[20] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld021" ); | |
63 | - _ah_matWorld[21] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld022" ); | |
64 | - _ah_matWorld[22] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld023" ); | |
65 | - _ah_matWorld[23] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld024" ); | |
66 | - _ah_matWorld[24] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld025" ); | |
67 | - _ah_matWorld[25] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld026" ); | |
68 | - _ah_matWorld[26] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld027" ); | |
69 | - _ah_matWorld[27] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld028" ); | |
70 | - _ah_matWorld[28] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld029" ); | |
71 | - _ah_matWorld[29] = _pID3DXEffect->GetParameterByName( nullptr, "g_matWorld030" ); | |
42 | + _ah_matBone[0] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone001" ); | |
43 | + _ah_matBone[1] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone002" ); | |
44 | + _ah_matBone[2] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone003" ); | |
45 | + _ah_matBone[3] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone004" ); | |
46 | + _ah_matBone[4] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone005" ); | |
47 | + _ah_matBone[5] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone006" ); | |
48 | + _ah_matBone[6] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone007" ); | |
49 | + _ah_matBone[7] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone008" ); | |
50 | + _ah_matBone[8] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone009" ); | |
51 | + _ah_matBone[9] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone010" ); | |
52 | + _ah_matBone[10] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone011" ); | |
53 | + _ah_matBone[11] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone012" ); | |
54 | + _ah_matBone[12] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone013" ); | |
55 | + _ah_matBone[13] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone014" ); | |
56 | + _ah_matBone[14] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone015" ); | |
57 | + _ah_matBone[15] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone016" ); | |
58 | + _ah_matBone[16] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone017" ); | |
59 | + _ah_matBone[17] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone018" ); | |
60 | + _ah_matBone[18] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone019" ); | |
61 | + _ah_matBone[19] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone020" ); | |
62 | + _ah_matBone[20] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone021" ); | |
63 | + _ah_matBone[21] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone022" ); | |
64 | + _ah_matBone[22] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone023" ); | |
65 | + _ah_matBone[23] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone024" ); | |
66 | + _ah_matBone[24] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone025" ); | |
67 | + _ah_matBone[25] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone026" ); | |
68 | + _ah_matBone[26] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone027" ); | |
69 | + _ah_matBone[27] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone028" ); | |
70 | + _ah_matBone[28] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone029" ); | |
71 | + _ah_matBone[29] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBone030" ); | |
72 | + | |
73 | + _ah_matBoneOffset[0] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset001" ); | |
74 | + _ah_matBoneOffset[1] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset002" ); | |
75 | + _ah_matBoneOffset[2] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset003" ); | |
76 | + _ah_matBoneOffset[3] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset004" ); | |
77 | + _ah_matBoneOffset[4] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset005" ); | |
78 | + _ah_matBoneOffset[5] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset006" ); | |
79 | + _ah_matBoneOffset[6] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset007" ); | |
80 | + _ah_matBoneOffset[7] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset008" ); | |
81 | + _ah_matBoneOffset[8] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset009" ); | |
82 | + _ah_matBoneOffset[9] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset010" ); | |
83 | + _ah_matBoneOffset[10] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset011" ); | |
84 | + _ah_matBoneOffset[11] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset012" ); | |
85 | + _ah_matBoneOffset[12] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset013" ); | |
86 | + _ah_matBoneOffset[13] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset014" ); | |
87 | + _ah_matBoneOffset[14] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset015" ); | |
88 | + _ah_matBoneOffset[15] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset016" ); | |
89 | + _ah_matBoneOffset[16] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset017" ); | |
90 | + _ah_matBoneOffset[17] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset018" ); | |
91 | + _ah_matBoneOffset[18] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset019" ); | |
92 | + _ah_matBoneOffset[19] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset020" ); | |
93 | + _ah_matBoneOffset[20] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset021" ); | |
94 | + _ah_matBoneOffset[21] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset022" ); | |
95 | + _ah_matBoneOffset[22] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset023" ); | |
96 | + _ah_matBoneOffset[23] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset024" ); | |
97 | + _ah_matBoneOffset[24] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset025" ); | |
98 | + _ah_matBoneOffset[25] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset026" ); | |
99 | + _ah_matBoneOffset[26] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset027" ); | |
100 | + _ah_matBoneOffset[27] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset028" ); | |
101 | + _ah_matBoneOffset[28] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset029" ); | |
102 | + _ah_matBoneOffset[29] = _pID3DXEffect->GetParameterByName( nullptr, "g_matBoneOffset030" ); | |
103 | + | |
72 | 104 | } |
73 | 105 | |
74 | 106 | void SkinAniMeshEffect::setParamPerFrame() { |
@@ -16,7 +16,8 @@ | ||
16 | 16 | #include "jp/ggaf/dx/util/BoneAniMeshAllocHierarchy.h" |
17 | 17 | #include "jp/ggaf/dx/util/BoneAniMeshFrame.h" |
18 | 18 | |
19 | -#define MAX_FRAME_WORLD_MATRIX (25) //2以上でないとブレイクしないのでダメ | |
19 | +//DefaultBoneAniMeshEffect.fx と 定数を一致させる事 | |
20 | +#define BoneAniMeshModel_MAX_BONE_WORLD_MATRIX (4) //2以上でないとブレイクしないのでダメ | |
20 | 21 | |
21 | 22 | using namespace GgafDx; |
22 | 23 | DWORD BoneAniMeshModel::FVF = (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_PSIZE | D3DFVF_DIFFUSE | D3DFVF_TEX1); |
@@ -94,7 +95,7 @@ HRESULT BoneAniMeshModel::draw(FigureActor* prm_pActor_target, int prm_draw_set_ | ||
94 | 95 | ///////////////////////////////////////////// |
95 | 96 | for (int i = 0; i < _index_param_num; i++) { |
96 | 97 | const INDEXPARAM& idxparam = _paIndexParam[i]; |
97 | - for (int j = 0; j < MAX_FRAME_WORLD_MATRIX; j++) { | |
98 | + for (int j = 0; j < BoneAniMeshModel_MAX_BONE_WORLD_MATRIX; j++) { | |
98 | 99 | if (it_1 != _vecDrawBoneFrame.end()) { |
99 | 100 | hr = pID3DXEffect->SetMatrix(pBoneAniMeshEffect->_ah_matWorld[j], &((*it_1)->_world_trans_matrix)); |
100 | 101 | ++it_1; |
@@ -349,7 +350,7 @@ void BoneAniMeshModel::restore() { | ||
349 | 350 | pVtx->nz = 0.0f; |
350 | 351 | } |
351 | 352 | // float index |
352 | - pVtx->index = (i % MAX_FRAME_WORLD_MATRIX); | |
353 | + pVtx->index = i; | |
353 | 354 | |
354 | 355 | //DWORD color ; //頂点カラー |
355 | 356 | pVtx->color = D3DCOLOR_ARGB(255,255,255,255); //頂点カラー |
@@ -442,8 +443,9 @@ void BoneAniMeshModel::restore() { | ||
442 | 443 | int faceNoCnt; |
443 | 444 | for (faceNoCnt = 0; faceNoCnt < _nFaces; faceNoCnt++) { |
444 | 445 | frame_no = _paIndexBuffer_frame_no[faceNoCnt*3 + 0]; //faceNoCnt(面番号)に対する頂点の属するフレームメッシュ通し番号 |
445 | - if (frame_no == 0 && prev_frame_no != 0) { | |
446 | -// _TRACE_("BREAK! frame_no="<<frame_no); | |
446 | +// _TRACE_("frame_no="<<frame_no<<" prev_frame_no="<<prev_frame_no); | |
447 | + if ((frame_no % BoneAniMeshModel_MAX_BONE_WORLD_MATRIX) == 0 && frame_no != prev_frame_no) { | |
448 | +// _TRACE_("BREAK!"); | |
447 | 449 | prev_faceNoCnt_break = faceNoCnt_break; |
448 | 450 | faceNoCnt_break = faceNoCnt; |
449 | 451 |
@@ -16,11 +16,10 @@ | ||
16 | 16 | #include "jp/ggaf/dx/util/SkinAniMeshAllocHierarchy.h" |
17 | 17 | #include "jp/ggaf/dx/util/SkinAniMeshContainer.h" |
18 | 18 | #include "jp/ggaf/dx/util/SkinAniMeshFrame.h" |
19 | - | |
20 | -#define MAX_FRAME_WORLD_MATRIX (25) //2以上でないとブレイクしないのでダメ | |
19 | +//DefaultSkinAniMeshEffect.fx と 定数を一致させる事 | |
20 | +#define SkinAniMeshModel_MAX_BONE_WORLD_MATRIX (5) //2以上でないとブレイクしないのでダメ | |
21 | 21 | |
22 | 22 | using namespace GgafDx; |
23 | -DWORD SkinAniMeshModel::FVF = (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_PSIZE | D3DFVF_DIFFUSE | D3DFVF_TEX1); | |
24 | 23 | |
25 | 24 | SkinAniMeshModel::SkinAniMeshModel(const char* prm_model_name) : Model(prm_model_name) { |
26 | 25 | _pAllocHierarchy = nullptr; |
@@ -30,6 +29,7 @@ SkinAniMeshModel::SkinAniMeshModel(const char* prm_model_name) : Model(prm_model | ||
30 | 29 | _anim_ticks_per_second = 4800; //restoreSkinAniMeshModel で上書きされる場合がある。 |
31 | 30 | _paVtxBuffer_data = nullptr; |
32 | 31 | _paIndexBuffer_data = nullptr; |
32 | + _pVertexDeclaration = nullptr; | |
33 | 33 | _pVertexBuffer = nullptr; |
34 | 34 | _pIndexBuffer = nullptr; |
35 | 35 | _index_param_num = 0; |
@@ -61,8 +61,8 @@ HRESULT SkinAniMeshModel::draw(FigureActor* prm_pActor_target, int prm_draw_set_ | ||
61 | 61 | ((MassModel*)pModelLastDraw)->resetStreamSourceFreq(); |
62 | 62 | } |
63 | 63 | //頂点バッファとインデックスバッファを設定 |
64 | + pDevice->SetVertexDeclaration( _pVertexDeclaration); //頂点フォーマット | |
64 | 65 | pDevice->SetStreamSource(0, _pVertexBuffer, 0, _size_vertex_unit); |
65 | - pDevice->SetFVF(SkinAniMeshModel::FVF); | |
66 | 66 | pDevice->SetIndices(_pIndexBuffer); |
67 | 67 | hr = pID3DXEffect->SetFloat(pSkinAniMeshEffect->_h_tex_blink_power, _power_blink); |
68 | 68 | checkDxException(hr, D3D_OK, "SetFloat(_h_tex_blink_power) に失敗しました。"); |
@@ -95,9 +95,9 @@ HRESULT SkinAniMeshModel::draw(FigureActor* prm_pActor_target, int prm_draw_set_ | ||
95 | 95 | ///////////////////////////////////////////// |
96 | 96 | for (int i = 0; i < _index_param_num; i++) { |
97 | 97 | const INDEXPARAM& idxparam = _paIndexParam[i]; |
98 | - for (int j = 0; j < MAX_FRAME_WORLD_MATRIX; j++) { | |
98 | + for (int j = 0; j < SkinAniMeshModel_MAX_BONE_WORLD_MATRIX; j++) { | |
99 | 99 | if (it_1 != _vecDrawBoneFrame.end()) { |
100 | - hr = pID3DXEffect->SetMatrix(pSkinAniMeshEffect->_ah_matWorld[j], &((*it_1)->_world_trans_matrix)); | |
100 | + hr = pID3DXEffect->SetMatrix(pSkinAniMeshEffect->_ah_matBone[j], &((*it_1)->_world_trans_matrix)); | |
101 | 101 | ++it_1; |
102 | 102 | } else { |
103 | 103 | break; |
@@ -321,82 +321,6 @@ void SkinAniMeshModel::restore() { | ||
321 | 321 | |
322 | 322 | ID3DXMesh* pMesh = pMeshContainer->MeshData.pMesh; |
323 | 323 | |
324 | - | |
325 | - | |
326 | - | |
327 | - | |
328 | - ///////////// | |
329 | - | |
330 | - _TRACE_("draw_frsme["<<i<<"]: idx="<<_vecDrawBoneFrame[i]->_frame_index<<", name="<<_vecDrawBoneFrame[i]->Name<<""); | |
331 | - _TRACE_("pMeshContainer->_dwMaxInfleNum = "<<pMeshContainer->_dwMaxInfleNum); | |
332 | - _TRACE_("pMeshContainer->_dwBoneCombNum = "<<pMeshContainer->_dwBoneCombNum); | |
333 | - | |
334 | - D3DXBONECOMBINATION* paBoneCombination = | |
335 | - (D3DXBONECOMBINATION*)(pMeshContainer->_pBoneCombinationTable->GetBufferPointer()); | |
336 | - for (UINT bc_idx = 0; bc_idx < pMeshContainer->_dwBoneCombNum; ++bc_idx) { //bc_idxはメッシュサブセットID | |
337 | - D3DXBONECOMBINATION* pBoneCombination = &(paBoneCombination[bc_idx]); | |
338 | - _TRACE_("paBoneCombination["<<bc_idx<<"] = "<< | |
339 | - " AttribId="<<pBoneCombination->AttribId<< | |
340 | - " FaceStart="<<pBoneCombination->FaceStart<< | |
341 | - " FaceCount="<<pBoneCombination->FaceCount<< | |
342 | - " VertexStart="<<pBoneCombination->VertexStart<< | |
343 | - " VertexCount="<<pBoneCombination->VertexCount<< | |
344 | - "" | |
345 | - ); | |
346 | - DWORD infl_id; | |
347 | - for ( infl_id = 0; infl_id < pMeshContainer->_dwMaxInfleNum; ++infl_id) { // | |
348 | - DWORD bone_id = pBoneCombination->BoneId[infl_id]; | |
349 | - _TRACE_("paBoneCombination["<<bc_idx<<"].BoneId["<<infl_id<<"]="<<bone_id); | |
350 | - } | |
351 | - } | |
352 | - | |
353 | - | |
354 | - | |
355 | -// _TRACE_("こここ"); | |
356 | -// | |
357 | -// D3DXBONECOMBINATION* pBoneCombination = | |
358 | -// (D3DXBONECOMBINATION*)(pMeshContainer->_pBoneCombinationTable->GetBufferPointer()); | |
359 | -// for (UINT bc_idx = 0; bc_idx < pMeshContainer->_dwBoneCombNum; ++bc_idx) { //bc_idxはメッシュサブセットID | |
360 | -// DWORD infl_id; | |
361 | -// for ( infl_id = 0; infl_id < pMeshContainer->_dwMaxInfleNum; ++infl_id) { // | |
362 | -// DWORD bone_id = pBoneCombination[bc_idx].BoneId[infl_id]; | |
363 | -// if (bone_id != UINT_MAX) { | |
364 | -// //IDが有効 | |
365 | -//// pDev->setTtanceform(D3DTS_WORLDMATRIX(infl_id), &m_mBoneToWorld[bone_id]); | |
366 | -// } else { | |
367 | -//// break; | |
368 | -// } | |
369 | -// } | |
370 | -// //頂点ブレンド数設定 | |
371 | -// //pDev->setRenderstate(D3DRS_VERTEXBLEND, pMeshContainer->_dwMaxInfleNum -1); | |
372 | -// | |
373 | -// //属性の設定、どのマテリアを使うか | |
374 | -//// const D3DXMATERIAL& mat = pMeshContainer->pMaterials[ pBoneCombination[bc_idx].AttribId ]; | |
375 | -//// pDev->SetMaterial(&mat.MatD3D); | |
376 | -//// pDev->SetTexture(0, GetTexture( mat.pTextureFilename)); | |
377 | -//// pMeshContainer->Mesh.pMesh->DrawSubset(bc_idx); | |
378 | -// } | |
379 | - | |
380 | - | |
381 | - | |
382 | - | |
383 | - | |
384 | - | |
385 | - | |
386 | - | |
387 | - | |
388 | - | |
389 | - | |
390 | - | |
391 | - | |
392 | - ////////////// | |
393 | - | |
394 | - | |
395 | - | |
396 | - | |
397 | - | |
398 | - | |
399 | - | |
400 | 324 | pMesh->GetDeclaration( e ); |
401 | 325 | int offset_position = getOffsetFromElem( e, D3DDECLUSAGE_POSITION ); |
402 | 326 | int offset_normal = getOffsetFromElem( e, D3DDECLUSAGE_NORMAL ); |
@@ -430,7 +354,7 @@ void SkinAniMeshModel::restore() { | ||
430 | 354 | pVtx->nz = 0.0f; |
431 | 355 | } |
432 | 356 | // float index |
433 | - pVtx->index = (i % MAX_FRAME_WORLD_MATRIX); | |
357 | + pVtx->index = i; | |
434 | 358 | |
435 | 359 | //DWORD color ; //頂点カラー |
436 | 360 | pVtx->color = D3DCOLOR_ARGB(255,255,255,255); //頂点カラー |
@@ -445,6 +369,11 @@ void SkinAniMeshModel::restore() { | ||
445 | 369 | pVtx->tv = 0.0f; |
446 | 370 | } |
447 | 371 | // _TRACE_("["<<i<<"]["<<j<<"]:pVtx->index="<<pVtx->index<<" Vertex=("<<(pVtx->x)<<","<<(pVtx->y)<<","<<(pVtx->z)<<") Normal=("<<(pVtx->nx)<<","<<(pVtx->ny)<<","<<(pVtx->nz)<<") texcoordl=("<<(pVtx->tu)<<","<<(pVtx->tv)<<")"); |
372 | + | |
373 | + for (int k = 0; k < 4; k++) { | |
374 | + pVtx->infl_weight[k] = 1.0f; | |
375 | + pVtx->infl_bone_idx[k] = 0xFF; | |
376 | + } | |
448 | 377 | v_cnt ++; |
449 | 378 | } |
450 | 379 | pVb->Unlock(); |
@@ -505,6 +434,106 @@ void SkinAniMeshModel::restore() { | ||
505 | 434 | pMeshContainer->MeshData.pMesh = nullptr; |
506 | 435 | } |
507 | 436 | |
437 | + | |
438 | + | |
439 | + //skin情報のためにもっかいループ | |
440 | + for (int i = 0; i < draw_frame_num; i++) { | |
441 | + | |
442 | + SkinAniMeshContainer* pMeshContainer = (SkinAniMeshContainer*)(_vecDrawBoneFrame[i]->pMeshContainer); | |
443 | + if (pMeshContainer == nullptr) { | |
444 | + continue; | |
445 | + } | |
446 | + ///////////// | |
447 | + _TRACE_("draw_frsme["<<i<<"]: idx="<<_vecDrawBoneFrame[i]->_frame_index<<", name="<<_vecDrawBoneFrame[i]->Name<<""); | |
448 | + _TRACE_("pMeshContainer->_dwMaxInfleNum = "<<pMeshContainer->_dwMaxInfleNum); | |
449 | + _TRACE_("pMeshContainer->_dwBoneCombNum = "<<pMeshContainer->_dwBoneCombNum); | |
450 | + LPD3DXSKININFO pSkinInfo = pMeshContainer->pSkinInfo; | |
451 | + D3DXBONECOMBINATION* paBoneCombination = | |
452 | + (D3DXBONECOMBINATION*)(pMeshContainer->_pBoneCombinationTable->GetBufferPointer()); | |
453 | + for (UINT bc_idx = 0; bc_idx < pMeshContainer->_dwBoneCombNum; ++bc_idx) { //bc_idxはメッシュサブセットID | |
454 | + D3DXBONECOMBINATION* pBoneCombination = &(paBoneCombination[bc_idx]); | |
455 | + _TRACE_("paBoneCombination["<<bc_idx<<"] = "<< | |
456 | + " AttribId="<<pBoneCombination->AttribId<< | |
457 | + " FaceStart="<<pBoneCombination->FaceStart<< | |
458 | + " FaceCount="<<pBoneCombination->FaceCount<< | |
459 | + " VertexStart="<<pBoneCombination->VertexStart<< | |
460 | + " VertexCount="<<pBoneCombination->VertexCount<< | |
461 | + "" | |
462 | + ); | |
463 | + DWORD infl_id; | |
464 | + for ( infl_id = 0; infl_id < pMeshContainer->_dwMaxInfleNum; ++infl_id) { // | |
465 | + DWORD bone_id = pBoneCombination->BoneId[infl_id]; | |
466 | + DWORD NumVertices = pSkinInfo->GetNumBoneInfluences(bone_id); | |
467 | + | |
468 | + _TRACE_("paBoneCombination["<<bc_idx<<"].BoneId["<<infl_id<<"]="<<bone_id<<" NumVertices="<<NumVertices); | |
469 | + | |
470 | + if (NumVertices > 0) { | |
471 | + // Get the bone influcences | |
472 | + DWORD *Vertices = new DWORD[NumVertices]; | |
473 | + float *Weights = new float[NumVertices]; | |
474 | + pSkinInfo->GetBoneInfluence(bone_id, Vertices, Weights); | |
475 | + for (int v = 0; v < NumVertices; v++) { | |
476 | + SkinAniMeshModel::VERTEX* pVtx = &(_paVtxBuffer_data[Vertices[v]]); | |
477 | + bool is_exist = false; | |
478 | + for (int k = 0; k < 4; k++) { | |
479 | + if (pVtx->infl_bone_idx[k] == (byte)bone_id) { | |
480 | + is_exist = true; | |
481 | + break; | |
482 | + } | |
483 | + } | |
484 | + if (is_exist == false) { | |
485 | + for (int k = 0; k < 4; k++) { | |
486 | + if (pVtx->infl_bone_idx[k] == 0xFF) { | |
487 | + pVtx->infl_bone_idx[k] = (byte)bone_id; | |
488 | + pVtx->infl_weight[k] = Weights[v]; | |
489 | + break; | |
490 | + } | |
491 | + } | |
492 | + } | |
493 | + } | |
494 | + | |
495 | + _TRACE_N_("Vertices="); | |
496 | + for (int v = 0; v < NumVertices; v++) { | |
497 | + _TRACE_N_("\t"<<Vertices[v]<<""); | |
498 | + } | |
499 | + _TRACE_N_("\n"); | |
500 | + _TRACE_N_("Weights="); | |
501 | + for (int v = 0; v < NumVertices; v++) { | |
502 | + _TRACE_N_("\t"<<Weights[v]<<""); | |
503 | + } | |
504 | + _TRACE_N_("\n"); | |
505 | + } | |
506 | + } | |
507 | + } | |
508 | + | |
509 | + | |
510 | +// _TRACE_("こここ"); | |
511 | +// | |
512 | +// D3DXBONECOMBINATION* pBoneCombination = | |
513 | +// (D3DXBONECOMBINATION*)(pMeshContainer->_pBoneCombinationTable->GetBufferPointer()); | |
514 | +// for (UINT bc_idx = 0; bc_idx < pMeshContainer->_dwBoneCombNum; ++bc_idx) { //bc_idxはメッシュサブセットID | |
515 | +// DWORD infl_id; | |
516 | +// for ( infl_id = 0; infl_id < pMeshContainer->_dwMaxInfleNum; ++infl_id) { // | |
517 | +// DWORD bone_id = pBoneCombination[bc_idx].BoneId[infl_id]; | |
518 | +// if (bone_id != UINT_MAX) { | |
519 | +// //IDが有効 | |
520 | +//// pDev->setTtanceform(D3DTS_WORLDMATRIX(infl_id), &m_mBoneToWorld[bone_id]); | |
521 | +// } else { | |
522 | +//// break; | |
523 | +// } | |
524 | +// } | |
525 | +// //頂点ブレンド数設定 | |
526 | +// //pDev->setRenderstate(D3DRS_VERTEXBLEND, pMeshContainer->_dwMaxInfleNum -1); | |
527 | +// | |
528 | +// //属性の設定、どのマテリアを使うか | |
529 | +//// const D3DXMATERIAL& mat = pMeshContainer->pMaterials[ pBoneCombination[bc_idx].AttribId ]; | |
530 | +//// pDev->SetMaterial(&mat.MatD3D); | |
531 | +//// pDev->SetTexture(0, GetTexture( mat.pTextureFilename)); | |
532 | +//// pMeshContainer->Mesh.pMesh->DrawSubset(bc_idx); | |
533 | +// } | |
534 | + | |
535 | + ////////////// | |
536 | + } | |
508 | 537 | //////////////////////////////////////////////// |
509 | 538 | //描画時(DrawIndexedPrimitive)のパラメータリスト作成 |
510 | 539 | std::vector<SkinAniMeshModel::INDEXPARAM> param_tmp; |
@@ -523,7 +552,7 @@ void SkinAniMeshModel::restore() { | ||
523 | 552 | int faceNoCnt; |
524 | 553 | for (faceNoCnt = 0; faceNoCnt < _nFaces; faceNoCnt++) { |
525 | 554 | frame_no = _paIndexBuffer_frame_no[faceNoCnt*3 + 0]; //faceNoCnt(面番号)に対する頂点の属するフレームメッシュ通し番号 |
526 | - if (frame_no == 0 && prev_frame_no != 0) { | |
555 | + if ((frame_no % SkinAniMeshModel_MAX_BONE_WORLD_MATRIX) == 0 && frame_no != prev_frame_no) { | |
527 | 556 | // _TRACE_("BREAK! frame_no="<<frame_no); |
528 | 557 | prev_faceNoCnt_break = faceNoCnt_break; |
529 | 558 | faceNoCnt_break = faceNoCnt; |
@@ -588,11 +617,17 @@ void SkinAniMeshModel::restore() { | ||
588 | 617 | } |
589 | 618 | _size_vertices = _size_vertex_unit * _nVertices; |
590 | 619 | |
591 | -// _TRACE_("まとめ!"); | |
592 | -// for (int i = 0; i < _nVertices; i++) { | |
593 | -// SkinAniMeshModel::VERTEX* pVtx = &(_paVtxBuffer_data[i]); //書き込む1頂点の開始アドレス | |
594 | -// _TRACE_("["<<i<<"]:Vertex=("<<(pVtx->x)<<","<<(pVtx->y)<<","<<(pVtx->z)<<") Normal=("<<(pVtx->nx)<<","<<(pVtx->ny)<<","<<(pVtx->nz)<<")"); | |
595 | -// } | |
620 | + _TRACE_("まとめ!"); | |
621 | + for (int i = 0; i < _nVertices; i++) { | |
622 | + SkinAniMeshModel::VERTEX* pVtx = &(_paVtxBuffer_data[i]); //書き込む1頂点の開始アドレス | |
623 | + _TRACE_("["<<i<<"]:"<< | |
624 | + " Vertex=("<<(pVtx->x)<<","<<(pVtx->y)<<","<<(pVtx->z)<<")"<< | |
625 | + " infl_bone_idx=("<<(int)(pVtx->infl_bone_idx[0])<<","<<(int)(pVtx->infl_bone_idx[1])<<","<<(int)(pVtx->infl_bone_idx[2])<<","<<(int)(pVtx->infl_bone_idx[3])<<")"<< | |
626 | + " infl_weight=("<<(pVtx->infl_weight[0])<<","<<(pVtx->infl_weight[1])<<","<<(pVtx->infl_weight[2])<<","<<(pVtx->infl_weight[3])<<")"<< | |
627 | + " Normal=("<<(pVtx->nx)<<","<<(pVtx->ny)<<","<<(pVtx->nz)<<")" | |
628 | + | |
629 | + ); | |
630 | + } | |
596 | 631 | // for (int i = 0; i < _nFaces; ++i) { |
597 | 632 | // _TRACE_("["<<i<<"]:Index=("<<(_paIndexBuffer_data[i*3+0])<<","<< |
598 | 633 | // (_paIndexBuffer_data[i*3+1])<<","<< |
@@ -602,6 +637,84 @@ void SkinAniMeshModel::restore() { | ||
602 | 637 | } //if (_paVtxBuffer_data == nullptr) |
603 | 638 | |
604 | 639 | |
640 | + | |
641 | + if (_pVertexDeclaration == nullptr) { | |
642 | + HRESULT hr; | |
643 | + int elemnum = 8; //D3DVERTEXELEMENT9 構造体の配列要素数 | |
644 | + D3DVERTEXELEMENT9* paVtxelem = NEW D3DVERTEXELEMENT9[elemnum]; | |
645 | + WORD st0_offset_next = 0; | |
646 | + //プライマリ部頂点フォーマット | |
647 | + //float x, y, z; // 頂点座標 | |
648 | + paVtxelem[0].Stream = 0; | |
649 | + paVtxelem[0].Offset = st0_offset_next; | |
650 | + paVtxelem[0].Type = D3DDECLTYPE_FLOAT3; | |
651 | + paVtxelem[0].Method = D3DDECLMETHOD_DEFAULT; | |
652 | + paVtxelem[0].Usage = D3DDECLUSAGE_POSITION; | |
653 | + paVtxelem[0].UsageIndex = 0; | |
654 | + st0_offset_next += sizeof(float)*3; | |
655 | + //float nx, ny, nz; // 法線 | |
656 | + paVtxelem[1].Stream = 0; | |
657 | + paVtxelem[1].Offset = st0_offset_next; | |
658 | + paVtxelem[1].Type = D3DDECLTYPE_FLOAT3; | |
659 | + paVtxelem[1].Method = D3DDECLMETHOD_DEFAULT; | |
660 | + paVtxelem[1].Usage = D3DDECLUSAGE_NORMAL; | |
661 | + paVtxelem[1].UsageIndex = 0; | |
662 | + st0_offset_next += sizeof(float)*3; | |
663 | + //float index; | |
664 | + paVtxelem[2].Stream = 0; | |
665 | + paVtxelem[2].Offset = st0_offset_next; | |
666 | + paVtxelem[2].Type = D3DDECLTYPE_FLOAT1; | |
667 | + paVtxelem[2].Method = D3DDECLMETHOD_DEFAULT; | |
668 | + paVtxelem[2].Usage = D3DDECLUSAGE_PSIZE; | |
669 | + paVtxelem[2].UsageIndex = 0; | |
670 | + st0_offset_next += sizeof(float)*1; | |
671 | + //DWORD color; // 頂点カラー | |
672 | + paVtxelem[3].Stream = 0; | |
673 | + paVtxelem[3].Offset = st0_offset_next; | |
674 | + paVtxelem[3].Type = D3DDECLTYPE_D3DCOLOR; | |
675 | + paVtxelem[3].Method = D3DDECLMETHOD_DEFAULT; | |
676 | + paVtxelem[3].Usage = D3DDECLUSAGE_COLOR; | |
677 | + paVtxelem[3].UsageIndex = 0; | |
678 | + st0_offset_next += sizeof(DWORD); | |
679 | + //float tu, tv; // テクスチャ座標 | |
680 | + paVtxelem[4].Stream = 0; | |
681 | + paVtxelem[4].Offset = st0_offset_next; | |
682 | + paVtxelem[4].Type = D3DDECLTYPE_FLOAT2; | |
683 | + paVtxelem[4].Method = D3DDECLMETHOD_DEFAULT; | |
684 | + paVtxelem[4].Usage = D3DDECLUSAGE_TEXCOORD; | |
685 | + paVtxelem[4].UsageIndex = 0; | |
686 | + st0_offset_next += sizeof(float)*2; | |
687 | + //float weight1, weight2, weight3, weight4; | |
688 | + paVtxelem[5].Stream = 0; | |
689 | + paVtxelem[5].Offset = st0_offset_next; | |
690 | + paVtxelem[5].Type = D3DDECLTYPE_FLOAT4; | |
691 | + paVtxelem[5].Method = D3DDECLMETHOD_DEFAULT; | |
692 | + paVtxelem[5].Usage = D3DDECLUSAGE_BLENDWEIGHT; | |
693 | + paVtxelem[5].UsageIndex = 0; | |
694 | + st0_offset_next += sizeof(float)*4; | |
695 | + // byte idx1, idx2, idx3, idx4 | |
696 | + paVtxelem[6].Stream = 0; | |
697 | + paVtxelem[6].Offset = st0_offset_next; | |
698 | + paVtxelem[6].Type = D3DDECLTYPE_UBYTE4; | |
699 | + paVtxelem[6].Method = D3DDECLMETHOD_DEFAULT; | |
700 | + paVtxelem[6].Usage = D3DDECLUSAGE_BLENDINDICES; | |
701 | + paVtxelem[6].UsageIndex = 0; | |
702 | + st0_offset_next += sizeof(byte)*4; | |
703 | + //D3DDECL_END() | |
704 | + paVtxelem[7].Stream = 0xFF; | |
705 | + paVtxelem[7].Offset = 0; | |
706 | + paVtxelem[7].Type = D3DDECLTYPE_UNUSED; | |
707 | + paVtxelem[7].Method = 0; | |
708 | + paVtxelem[7].Usage = 0; | |
709 | + paVtxelem[7].UsageIndex = 0; | |
710 | + | |
711 | + hr = God::_pID3DDevice9->CreateVertexDeclaration( paVtxelem, &(_pVertexDeclaration) ); | |
712 | + checkDxException(hr, D3D_OK, "God::_pID3DDevice9->CreateVertexDeclaration 失敗 model="<<(_model_name)); | |
713 | + //ストリーム数取得 hr = m_pDecl->GetDeclaration( m_pElement, &m_numElements); | |
714 | + GGAF_DELETEARR(paVtxelem); | |
715 | + } | |
716 | + | |
717 | + | |
605 | 718 | if (_papTextureConnection == nullptr) { |
606 | 719 | _papTextureConnection = NEW TextureConnection*[_num_materials]; |
607 | 720 | TextureManager* pTextureManager = pGOD->_pModelManager->_pModelTextureManager; |
@@ -617,7 +730,7 @@ void SkinAniMeshModel::restore() { | ||
617 | 730 | hr = God::_pID3DDevice9->CreateVertexBuffer( |
618 | 731 | _size_vertices, |
619 | 732 | D3DUSAGE_WRITEONLY, |
620 | - SkinAniMeshModel::FVF, | |
733 | + 0, //SkinAniMeshModel::FVF, | |
621 | 734 | D3DPOOL_DEFAULT, //D3DPOOL_DEFAULT |
622 | 735 | &(_pVertexBuffer), |
623 | 736 | nullptr); |
@@ -744,6 +857,7 @@ void SkinAniMeshModel::release() { | ||
744 | 857 | GGAF_DELETEARR(_papTextureConnection); //テクスチャの配列 |
745 | 858 | GGAF_RELEASE(_pVertexBuffer); |
746 | 859 | GGAF_RELEASE(_pIndexBuffer); |
860 | + GGAF_RELEASE(_pVertexDeclaration); | |
747 | 861 | _TRACE3_("_model_name=" << _model_name << " end"); |
748 | 862 | } |
749 | 863 |
@@ -37,8 +37,8 @@ HRESULT SkinAniMeshAllocHierarchy::CreateMeshContainer(THIS_ | ||
37 | 37 | if(pSkinInfo) { |
38 | 38 | pNewMC->pSkinInfo = pSkinInfo;// スキンをコピー |
39 | 39 | pNewMC->pSkinInfo->AddRef(); |
40 | - // ボーンの数を取得 | |
41 | 40 | DWORD bone_num = pSkinInfo->GetNumBones(); |
41 | + // 描画頂点に関係するボーンの数 = ボーンオフセット行列の数 | |
42 | 42 | pNewMC->_dwBoneOffsetMatrixNum = bone_num; |
43 | 43 | _TRACE_("pSkinInfo->GetNumBones() = "<<bone_num); |
44 | 44 | pNewMC->_paBoneOffsetMatrix = new D3DXMATRIX[bone_num]; |
@@ -55,20 +55,26 @@ HRESULT SkinAniMeshAllocHierarchy::CreateMeshContainer(THIS_ | ||
55 | 55 | //・ボーンの影響をうける範囲ごとに、メッシュをサブセットに分割 |
56 | 56 | //・頂点情報にブレンド加重値を付与 |
57 | 57 | //・ボーンに合わせて頂点を移動 |
58 | - DWORD Options = D3DXMESH_SYSTEMMEM|D3DXMESHOPT_VERTEXCACHE; | |
58 | +// DWORD Options = D3DXMESH_SYSTEMMEM|D3DXMESHOPT_VERTEXCACHE; | |
59 | + LPD3DXBUFFER pVertexRemap; | |
59 | 60 | hr = pNewMC->pSkinInfo->ConvertToBlendedMesh( |
60 | 61 | pMeshData->pMesh, //[in] LPD3DXMESH pMesh, 入力メッシュ |
61 | - Options, //[in] DWORD Options, 未使用? | |
62 | + NULL, //[in] DWORD Options, 未使用? | |
62 | 63 | pAdjacency, //[in] CONST LPDWORD pAdjacencyIn, 入力メッシュ隣接面情報(配列?) |
63 | 64 | pNewMC->pAdjacency, //[out]LPDWORD pAdjacencyOut, 出力メッシュ隣接面情報 |
64 | 65 | NULL, //[out]DWORD *pFaceRemap, 面をどう並べ替えたかの情報、不要時NULL |
65 | - NULL, //[out]LPD3DXBUFFER *ppVertexRemap, 頂点をどう並べ替えたかの情報、不要時NULL | |
66 | + &(pVertexRemap), //[out]LPD3DXBUFFER *ppVertexRemap, 頂点をどう並べ替えたかの情報、不要時NULL | |
66 | 67 | &(pNewMC->_dwMaxInfleNum), //[out]DWORD *pMaxFaceInfl, 一つの頂点に影響を与えるボーンの数の最大値 |
67 | 68 | &(pNewMC->_dwBoneCombNum), //[out]DWORD *pNumBoneCombinations, ボーンコンビネーションの数 |
68 | 69 | &(pNewMC->_pBoneCombinationTable), //[out]LPD3DXBUFFER *ppBoneCombinationTable, ボーンコンビネーション情報、ボーンと頂点の対応表配列 |
69 | 70 | &(pNewMC->MeshData.pMesh) //[out]LPD3DXMESH *ppMesh 出力メッシュ情報、処理済みのメッシュが返ってくる |
70 | 71 | ); |
71 | 72 | checkDxException(hr, D3D_OK, "ConvertToBlendedMeshに失敗しました。"); |
73 | + //Remap処理、ターゲットの頂点バッファが外部的に順番変更された場合は、このメソッドを呼び出す必要があります。 | |
74 | + DWORD* d = (DWORD*)pVertexRemap->GetBufferPointer(); | |
75 | + pNewMC->pSkinInfo->Remap(pNewMC->MeshData.pMesh->GetNumVertices(),d); | |
76 | + pVertexRemap->Release(); | |
77 | + | |
72 | 78 | // ConvertToBlenderMesh関数で戻ってくる ID3DXBuffer には、 |
73 | 79 | // D3DXBONECOMBINATION構造体が NumBoneCombinations 個入っている。 |
74 | 80 | } else { |
@@ -93,7 +99,7 @@ D3DXFRAME* SkinAniMeshAllocHierarchy::createNewFrame() { | ||
93 | 99 | tmp->_frame_index = UINT_MAX; // 0 が有効なインデックスなので 0 で初期化したくなかった |
94 | 100 | D3DXMatrixIsIdentity(&(tmp->_world_trans_matrix)); //とりあえず単位行列 |
95 | 101 | D3DXMatrixIsIdentity(&(tmp->_bone_offset_matrix)); |
96 | - D3DXMatrixIsIdentity(&(tmp->_conbined_matrix)); | |
102 | + D3DXMatrixIsIdentity(&(tmp->_combined_matrix)); | |
97 | 103 | return tmp; |
98 | 104 | } |
99 | 105 |
@@ -93,4 +93,3 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | - |
@@ -15,7 +15,7 @@ namespace Mogera { | ||
15 | 15 | * @author Masatoshi Tsuge |
16 | 16 | */ |
17 | 17 | //class AniTest : public GgafLib::DefaultBoneAniMeshActor { |
18 | - class AniTest : public GgafLib::DefaultSkinAniMeshActor { | |
18 | +class AniTest : public GgafLib::DefaultSkinAniMeshActor { | |
19 | 19 | public: |
20 | 20 | /** |
21 | 21 | * コンストラクタ |
@@ -220,3 +220,5 @@ TrialAndErrScene::~TrialAndErrScene() { | ||
220 | 220 | } |
221 | 221 | |
222 | 222 | |
223 | + | |
224 | + |
@@ -6,6 +6,8 @@ | ||
6 | 6 | // date:2009/03/06 |
7 | 7 | //////////////////////////////////////////////////////////////////////////////// |
8 | 8 | |
9 | +#define BoneAniMeshModel_MAX_BONE_WORLD_MATRIX (4) | |
10 | + | |
9 | 11 | /** モデルのWorld変換行列(フレーム毎) */ |
10 | 12 | float4x4 g_matWorld001; |
11 | 13 | float4x4 g_matWorld002; |
@@ -89,8 +91,7 @@ OUT_VS VS_DefaultBoneAniMesh( | ||
89 | 91 | |
90 | 92 | ) { |
91 | 93 | OUT_VS out_vs = (OUT_VS)0; |
92 | - const int index = (int)prm_index; | |
93 | - | |
94 | + const int index = ((int)prm_index) % BoneAniMeshModel_MAX_BONE_WORLD_MATRIX; | |
94 | 95 | //頂点計算 |
95 | 96 | float4x4 matWorld; |
96 | 97 |
@@ -5,38 +5,71 @@ | ||
5 | 5 | // author : Masatoshi Tsuge |
6 | 6 | // date:2009/03/06 |
7 | 7 | //////////////////////////////////////////////////////////////////////////////// |
8 | - | |
8 | +#define SkinAniMeshModel_MAX_BONE_WORLD_MATRIX (5) | |
9 | 9 | /** モデルのWorld変換行列(フレーム毎) */ |
10 | -float4x4 g_matWorld001; | |
11 | -float4x4 g_matWorld002; | |
12 | -float4x4 g_matWorld003; | |
13 | -float4x4 g_matWorld004; | |
14 | -float4x4 g_matWorld005; | |
15 | -float4x4 g_matWorld006; | |
16 | -float4x4 g_matWorld007; | |
17 | -float4x4 g_matWorld008; | |
18 | -float4x4 g_matWorld009; | |
19 | -float4x4 g_matWorld010; | |
20 | -float4x4 g_matWorld011; | |
21 | -float4x4 g_matWorld012; | |
22 | -float4x4 g_matWorld013; | |
23 | -float4x4 g_matWorld014; | |
24 | -float4x4 g_matWorld015; | |
25 | -float4x4 g_matWorld016; | |
26 | -float4x4 g_matWorld017; | |
27 | -float4x4 g_matWorld018; | |
28 | -float4x4 g_matWorld019; | |
29 | -float4x4 g_matWorld020; | |
30 | -float4x4 g_matWorld021; | |
31 | -float4x4 g_matWorld022; | |
32 | -float4x4 g_matWorld023; | |
33 | -float4x4 g_matWorld024; | |
34 | -float4x4 g_matWorld025; | |
35 | -float4x4 g_matWorld026; | |
36 | -float4x4 g_matWorld027; | |
37 | -float4x4 g_matWorld028; | |
38 | -float4x4 g_matWorld029; | |
39 | -float4x4 g_matWorld030; | |
10 | +float4x4 g_matBone001; | |
11 | +float4x4 g_matBone002; | |
12 | +float4x4 g_matBone003; | |
13 | +float4x4 g_matBone004; | |
14 | +float4x4 g_matBone005; | |
15 | +float4x4 g_matBone006; | |
16 | +float4x4 g_matBone007; | |
17 | +float4x4 g_matBone008; | |
18 | +float4x4 g_matBone009; | |
19 | +float4x4 g_matBone010; | |
20 | +float4x4 g_matBone011; | |
21 | +float4x4 g_matBone012; | |
22 | +float4x4 g_matBone013; | |
23 | +float4x4 g_matBone014; | |
24 | +float4x4 g_matBone015; | |
25 | +float4x4 g_matBone016; | |
26 | +float4x4 g_matBone017; | |
27 | +float4x4 g_matBone018; | |
28 | +float4x4 g_matBone019; | |
29 | +float4x4 g_matBone020; | |
30 | +float4x4 g_matBone021; | |
31 | +float4x4 g_matBone022; | |
32 | +float4x4 g_matBone023; | |
33 | +float4x4 g_matBone024; | |
34 | +float4x4 g_matBone025; | |
35 | +float4x4 g_matBone026; | |
36 | +float4x4 g_matBone027; | |
37 | +float4x4 g_matBone028; | |
38 | +float4x4 g_matBone029; | |
39 | +float4x4 g_matBone030; | |
40 | + | |
41 | + | |
42 | +float4x4 g_matBoneOffset001; | |
43 | +float4x4 g_matBoneOffset002; | |
44 | +float4x4 g_matBoneOffset003; | |
45 | +float4x4 g_matBoneOffset004; | |
46 | +float4x4 g_matBoneOffset005; | |
47 | +float4x4 g_matBoneOffset006; | |
48 | +float4x4 g_matBoneOffset007; | |
49 | +float4x4 g_matBoneOffset008; | |
50 | +float4x4 g_matBoneOffset009; | |
51 | +float4x4 g_matBoneOffset010; | |
52 | +float4x4 g_matBoneOffset011; | |
53 | +float4x4 g_matBoneOffset012; | |
54 | +float4x4 g_matBoneOffset013; | |
55 | +float4x4 g_matBoneOffset014; | |
56 | +float4x4 g_matBoneOffset015; | |
57 | +float4x4 g_matBoneOffset016; | |
58 | +float4x4 g_matBoneOffset017; | |
59 | +float4x4 g_matBoneOffset018; | |
60 | +float4x4 g_matBoneOffset019; | |
61 | +float4x4 g_matBoneOffset020; | |
62 | +float4x4 g_matBoneOffset021; | |
63 | +float4x4 g_matBoneOffset022; | |
64 | +float4x4 g_matBoneOffset023; | |
65 | +float4x4 g_matBoneOffset024; | |
66 | +float4x4 g_matBoneOffset025; | |
67 | +float4x4 g_matBoneOffset026; | |
68 | +float4x4 g_matBoneOffset027; | |
69 | +float4x4 g_matBoneOffset028; | |
70 | +float4x4 g_matBoneOffset029; | |
71 | +float4x4 g_matBoneOffset030; | |
72 | + | |
40 | 73 | |
41 | 74 | /** モデルのView変換行列 */ |
42 | 75 | float4x4 g_matView; |
@@ -82,78 +115,79 @@ struct OUT_VS { | ||
82 | 115 | |
83 | 116 | //メッシュ標準頂点シェーダー |
84 | 117 | OUT_VS VS_DefaultSkinAniMesh( |
85 | - float4 prm_posModel_Local : POSITION, // モデルの頂点 | |
118 | + float4 prm_posModel_Local : POSITION, // モデルの頂点 | |
86 | 119 | float3 prm_vecNormal_Local : NORMAL, // モデルの頂点の法線 |
87 | 120 | float prm_index : PSIZE , // モデルのインデックス(何個目のオブジェクトか?) |
88 | - float2 prm_uv : TEXCOORD0 // モデルの頂点のUV | |
89 | - | |
121 | + float2 prm_uv : TEXCOORD0 , // モデルの頂点のUV | |
122 | + float4 infl_weight : BLENDWEIGHT, | |
123 | + int4 infl_bone_idx : BLENDINDICES | |
90 | 124 | ) { |
91 | 125 | OUT_VS out_vs = (OUT_VS)0; |
92 | - const int index = (int)prm_index; | |
126 | + const int index = ((int)prm_index) % SkinAniMeshModel_MAX_BONE_WORLD_MATRIX; | |
93 | 127 | |
94 | 128 | //頂点計算 |
95 | 129 | float4x4 matWorld; |
96 | 130 | |
97 | 131 | if (index == 0) { |
98 | - matWorld = g_matWorld001; | |
132 | + matWorld = g_matBone001; | |
99 | 133 | } else if (index == 1) { |
100 | - matWorld = g_matWorld002; | |
134 | + matWorld = g_matBone002; | |
101 | 135 | } else if (index == 2) { |
102 | - matWorld = g_matWorld003; | |
136 | + matWorld = g_matBone003; | |
103 | 137 | } else if (index == 3) { |
104 | - matWorld = g_matWorld004; | |
138 | + matWorld = g_matBone004; | |
105 | 139 | } else if (index == 4) { |
106 | - matWorld = g_matWorld005; | |
140 | + matWorld = g_matBone005; | |
107 | 141 | } else if (index == 5) { |
108 | - matWorld = g_matWorld006; | |
142 | + matWorld = g_matBone006; | |
109 | 143 | } else if (index == 6) { |
110 | - matWorld = g_matWorld007; | |
144 | + matWorld = g_matBone007; | |
111 | 145 | } else if (index == 7) { |
112 | - matWorld = g_matWorld008; | |
146 | + matWorld = g_matBone008; | |
113 | 147 | } else if (index == 8) { |
114 | - matWorld = g_matWorld009; | |
148 | + matWorld = g_matBone009; | |
115 | 149 | } else if (index == 9) { |
116 | - matWorld = g_matWorld010; | |
150 | + matWorld = g_matBone010; | |
117 | 151 | } else if (index == 10) { |
118 | - matWorld = g_matWorld011; | |
152 | + matWorld = g_matBone011; | |
119 | 153 | } else if (index == 11) { |
120 | - matWorld = g_matWorld012; | |
154 | + matWorld = g_matBone012; | |
121 | 155 | } else if (index == 12) { |
122 | - matWorld = g_matWorld013; | |
156 | + matWorld = g_matBone013; | |
123 | 157 | } else if (index == 13) { |
124 | - matWorld = g_matWorld014; | |
158 | + matWorld = g_matBone014; | |
125 | 159 | } else if (index == 14) { |
126 | - matWorld = g_matWorld015; | |
160 | + matWorld = g_matBone015; | |
127 | 161 | } else if (index == 15) { |
128 | - matWorld = g_matWorld016; | |
162 | + matWorld = g_matBone016; | |
129 | 163 | } else if (index == 16) { |
130 | - matWorld = g_matWorld017; | |
164 | + matWorld = g_matBone017; | |
131 | 165 | } else if (index == 17) { |
132 | - matWorld = g_matWorld018; | |
166 | + matWorld = g_matBone018; | |
133 | 167 | } else if (index == 18) { |
134 | - matWorld = g_matWorld019; | |
168 | + matWorld = g_matBone019; | |
135 | 169 | } else if (index == 19) { |
136 | - matWorld = g_matWorld020; | |
170 | + matWorld = g_matBone020; | |
137 | 171 | } else if (index == 20) { |
138 | - matWorld = g_matWorld021; | |
172 | + matWorld = g_matBone021; | |
139 | 173 | } else if (index == 21) { |
140 | - matWorld = g_matWorld022; | |
174 | + matWorld = g_matBone022; | |
141 | 175 | } else if (index == 22) { |
142 | - matWorld = g_matWorld023; | |
176 | + matWorld = g_matBone023; | |
143 | 177 | } else if (index == 23) { |
144 | - matWorld = g_matWorld024; | |
178 | + matWorld = g_matBone024; | |
145 | 179 | } else if (index == 24) { |
146 | - matWorld = g_matWorld025; | |
180 | + matWorld = g_matBone025; | |
147 | 181 | } else if (index == 25) { |
148 | - matWorld = g_matWorld026; | |
182 | + matWorld = g_matBone026; | |
149 | 183 | } else if (index == 26) { |
150 | - matWorld = g_matWorld027; | |
184 | + matWorld = g_matBone027; | |
151 | 185 | } else if (index == 27) { |
152 | - matWorld = g_matWorld028; | |
186 | + matWorld = g_matBone028; | |
153 | 187 | } else if (index == 28) { |
154 | - matWorld = g_matWorld029; | |
188 | + matWorld = g_matBone029; | |
155 | 189 | } else { //if (index == 29) { |
156 | - matWorld = g_matWorld030; | |
190 | + matWorld = g_matBone030; | |
157 | 191 | } |
158 | 192 | //頂点計算 |
159 | 193 | const float4 posModel_World = mul(prm_posModel_Local, matWorld); |
@@ -260,7 +294,7 @@ technique DefaultSkinAniMeshTechnique | ||
260 | 294 | //【使用条件】 |
261 | 295 | //・テクスチャが存在しs0レジスタにバインドされていること。 |
262 | 296 | //【設定パラメータ】 |
263 | - // float4x4 g_matWorld : World変換行列 | |
297 | + // float4x4 g_matBone : World変換行列 | |
264 | 298 | // float4x4 g_matView : View変換行列 |
265 | 299 | // float4x4 g_matProj : 射影変換行列 |
266 | 300 | // float3 g_vecLightFrom_World : ライトの方向 |
@@ -1 +1 @@ | ||
1 | -#define VERSION "VER 0.30.6724" | |
1 | +#define VERSION "VER 0.30.6726" |