• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

MIDITrail をピカピカにする。鍵盤方向自動切替・多ポート・歌詞対応等


Commit MetaInfo

修订版4baefa71126c994111bb14c50ad7f4d513c7366c (tree)
时间2019-08-28 01:57:42
作者yoshy <yoshy@user...>
Commiteryoshy

Log Message

[WORKING] 20190310_1218

更改概述

差异

--- a/MIDITrail/MTPianoKeyboard.h
+++ b/MIDITrail/MTPianoKeyboard.h
@@ -22,6 +22,10 @@
2222
2323 using namespace SMIDILib;
2424
25+//******************************************************************************
26+// パラメータ定義
27+//******************************************************************************
28+#define MTPIANOKEYBOARD_KEY_PLANE_MAX (10)
2529
2630 //******************************************************************************
2731 // ピアノキーボード描画クラス
@@ -102,6 +106,16 @@ protected:
102106 D3DXVECTOR2 t; //テクスチャ画像位置
103107 };
104108
109+// >>> add 20180416 yossiepon begin
110+ //キー種別
111+ enum KeyType {
112+ KeyWhite1, //白鍵1
113+ KeyWhite2, //白鍵2
114+ KeyWhite3, //白鍵3
115+ KeyBlack //黒鍵
116+ };
117+// <<< add 20180416 yossiepon end
118+
105119 //バッファ情報
106120 typedef struct {
107121 unsigned long vertexPos;
@@ -113,6 +127,11 @@ protected:
113127 unsigned long revIndexPos;
114128 unsigned long revIndexTotal;
115129 // <<< add 20180413 yossiepon end
130+// >>> add 20180416 yossiepon begin
131+ KeyType keyType;
132+ unsigned long planeIndexPos[MTPIANOKEYBOARD_KEY_PLANE_MAX];
133+ unsigned long planeIndexNum[MTPIANOKEYBOARD_KEY_PLANE_MAX];
134+// <<< add 20180416 yossiepon end
116135 } MTBufInfo;
117136
118137 // >>> modify access level to protected 20161224 yossiepon begin
--- a/MIDITrail/MTPianoKeyboardMod.cpp
+++ b/MIDITrail/MTPianoKeyboardMod.cpp
@@ -18,20 +18,22 @@ using namespace YNBaseLib;
1818 //******************************************************************************
1919 // パラメータ定義
2020 //******************************************************************************
21-//各キーの頂点数
22-#define MTPIANOKEYBOARD_KEY_WHITE_1_VERTEX_NUM (38)
23-#define MTPIANOKEYBOARD_KEY_WHITE_2_VERTEX_NUM (44)
24-#define MTPIANOKEYBOARD_KEY_WHITE_3_VERTEX_NUM (38)
25-#define MTPIANOKEYBOARD_KEY_BLACK_VERTEX_NUM (30)
26-#define MTPIANOKEYBOARD_KEY_VERTEX_NUM_MAX MTPIANOKEYBOARD_KEY_WHITE_2_VERTEX_NUM
27-
28-//各キーのインデックス数
29-#define MTPIANOKEYBOARD_KEY_WHITE_1_INDEX_NUM (60)
30-#define MTPIANOKEYBOARD_KEY_WHITE_2_INDEX_NUM (66)
31-#define MTPIANOKEYBOARD_KEY_WHITE_3_INDEX_NUM (60)
32-#define MTPIANOKEYBOARD_KEY_BLACK_INDEX_NUM (48)
33-#define MTPIANOKEYBOARD_KEY_INDEX_NUM_MAX MTPIANOKEYBOARD_KEY_WHITE_2_INDEX_NUM
34-
21+#define PLANE_INDEX_UP (0)
22+#define PLANE_INDEX_FRONT (1)
23+#define PLANE_INDEX_RIGHT (2)
24+#define PLANE_INDEX_RIGHT_FRONT (2)
25+#define PLANE_INDEX_MIDDLE_RIGHT (3)
26+#define PLANE_INDEX_RIGHT_BACK (4)
27+#define PLANE_INDEX_BACK (5)
28+#define PLANE_INDEX_LEFT_BACK (6)
29+#define PLANE_INDEX_MIDDLE_LEFT (7)
30+#define PLANE_INDEX_LEFT_FRONT (8)
31+#define PLANE_INDEX_LEFT (8)
32+#define PLANE_INDEX_DOWN (9)
33+#define PLANE_INDEX_WHITEKEY1_MAX (8)
34+#define PLANE_INDEX_WHITEKEY2_MAX (10)
35+#define PLANE_INDEX_WHITEKEY3_MAX (8)
36+#define PLANE_INDEX_BLACKKEY_MAX (6)
3537
3638 //******************************************************************************
3739 // コンストラクタ
@@ -39,13 +41,17 @@ using namespace YNBaseLib;
3941 MTPianoKeyboardMod::MTPianoKeyboardMod(void)
4042 {
4143 //逆順インデックス情報
42- m_pRevIndexBuffer = NULL;
43- m_RevIndexNum = 0;
44- m_IsRevIndexLocked = false;
44+ for (int i = 0; i < MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX; i++) {
45+ m_pRenderingIndexBuffer[i] = NULL;
46+ m_RenderingIndexNum[i] = 0;
47+ m_IsRenderingIndexLocked[i] = false;
48+ }
4549
4650 //キーボード描画範囲
4751 m_noteNoLow = -1;
4852 m_noteNoHigh = -1;
53+ m_camDirLR = 0;
54+ m_camPosIdx = 2;
4955 }
5056
5157 //******************************************************************************
@@ -76,8 +82,8 @@ int MTPianoKeyboardMod::Create(
7682 result = m_KeyboardDesignMod.Initialize(pSceneName, pSeqData);
7783 if (result != 0) goto EXIT;
7884
79- //逆順インデックス生成
80- _CreateRevIndex(pD3DDevice);
85+ //描画インデックス生成
86+ _CreateRenderingIndex(pD3DDevice);
8187
8288 EXIT:;
8389 return result;
@@ -107,29 +113,29 @@ int MTPianoKeyboardMod::Draw(
107113 pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
108114
109115 //視線方向による描画順の変更
110- if (m_camDir == -1) {
111- //正順側キーボードの描画
116+ if (m_camDirLR == -1) {
117+ //低音側キーボードの描画
112118 if (m_noteNoLow != -1) {
113- result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3);
119+ result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRenderingIndexBuffer[m_camPosIdx + 1], m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3);
114120 if (result != 0) goto EXIT;
115121 }
116122
117- //逆順側キーボードの描画
123+ //高音側キーボードの描画
118124 if (m_noteNoHigh != -1) {
119- result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRevIndexBuffer, m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3);
125+ result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRenderingIndexBuffer[m_camPosIdx], m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3);
120126 if (result != 0) goto EXIT;
121127 }
122128 }
123129 else {
124- //逆順側キーボードの描画
130+ //高音側キーボードの描画
125131 if (m_noteNoHigh != -1) {
126- result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRevIndexBuffer, m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3);
132+ result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRenderingIndexBuffer[m_camPosIdx], m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3);
127133 if (result != 0) goto EXIT;
128134 }
129135
130- //正順側キーボードの描画
136+ //低音側キーボードの描画
131137 if (m_noteNoLow != -1) {
132- result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3);
138+ result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRenderingIndexBuffer[m_camPosIdx + 1], m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3);
133139 if (result != 0) goto EXIT;
134140 }
135141 }
@@ -202,8 +208,8 @@ int MTPianoKeyboardMod::Transform(
202208 //変換行列設定
203209 m_PrimitiveKeyboard.Transform(worldMatrix);
204210
205- //キーボード描画順の生成
206- _MakeRenderingOrder(basePosVector, camVector, lookVector);
211+ //キーボード描画情報の生成
212+ _MakeRenderingInfo(basePosVector, playbackPosVector, camVector, lookVector, rollAngle);
207213
208214 //EXIT:;
209215 return result;
@@ -246,30 +252,32 @@ EXIT:;
246252 }
247253
248254 //******************************************************************************
249-// 描画順の作成
255+// 描画情報の作成
250256 //******************************************************************************
251-int MTPianoKeyboardMod::_MakeRenderingOrder(
257+int MTPianoKeyboardMod::_MakeRenderingInfo(
252258 D3DXVECTOR3 basePosVector,
259+ D3DXVECTOR3 playbackPosVector,
253260 D3DXVECTOR3 camVector,
254- D3DXVECTOR3 lookVector
261+ D3DXVECTOR3 lookVector,
262+ float rollAngle
255263 )
256264 {
257265 //ピッチベンド幅を含んだキーボード原点
258- float origin = basePosVector.x;
266+ float originXF = basePosVector.z;
267+ float originXB = basePosVector.z + m_KeyboardDesignMod.GetWhiteKeyLen() * m_KeyboardDesignMod.GetKeyboardResizeRatio();
268+ float originY = basePosVector.y;
269+ float originZ = basePosVector.x;
259270
260271 //カメラ位置
261- float camPos = -camVector.z;
272+ float camPosX = camVector.x - playbackPosVector.x;
273+ float camPosY = camVector.y;
274+ float camPosZ = -camVector.z;
262275
263276 //カメラ視線方向
264277 float camDir = -lookVector.z;
265278
266- m_noteNoLow = (int)::floor((camPos - origin) / m_KeyboardDesignMod.GetNoteStep());
267- m_noteNoHigh = m_noteNoLow + 1;
268-
269- //char buf[256];
270- ////::sprintf(buf, "O:%f, P:%f, L:%d, H:%d\n", origin, camPos, m_noteNoLow, m_noteNoHigh);
271- //::sprintf(buf, "D:%f\n", camDir);
272- //::OutputDebugStringA(buf);
279+ m_noteNoLow = (int)::floor((camPosZ - originZ) / m_KeyboardDesignMod.GetNoteStep() + SM_MAX_NOTE_NUM / 4);
280+ m_noteNoHigh = m_noteNoLow + 2;
273281
274282 if (m_noteNoLow < 0) {
275283 m_noteNoLow = -1;
@@ -288,15 +296,32 @@ int MTPianoKeyboardMod::_MakeRenderingOrder(
288296 m_noteNoHigh = -1;
289297 }
290298
291- m_camDir = camDir < 0 ? -1 : 1;
299+ m_camDirLR = camDir < 0 ? -1 : 1;
300+
301+ if (camPosX < originXF) {
302+ m_camPosIdx = 2;
303+ }
304+ else if (camPosX > originXB) {
305+ m_camPosIdx = 4;
306+ }
307+ else {
308+ m_camPosIdx = 0;
309+ }
310+
311+ char buf[256];
312+ //::sprintf(buf, "O:%f, P:%f, L:%d, H:%d\n", origin, camPos, m_noteNoLow, m_noteNoHigh);
313+ //::sprintf(buf, "D:%f\n", camDir);
314+ //::sprintf(buf, "O:%f, P:%f\n", originY, camPosY);
315+ ::sprintf(buf, "X:%f, Y:%f, Z:%f, D:%d, I:%d, L:%d, H:%d\n", (camPosX - originXF), (camPosY - originY), (camPosZ - originZ), m_camDirLR, m_camPosIdx, m_noteNoLow, m_noteNoHigh);
316+ ::OutputDebugStringA(buf);
292317
293318 return 0;
294319 }
295320
296321 //******************************************************************************
297-// 逆順インデックス生成
322+// 描画インデックス生成
298323 //******************************************************************************
299-int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice)
324+int MTPianoKeyboardMod::_CreateRenderingIndex(LPDIRECT3DDEVICE9 pD3DDevice)
300325 {
301326 int result = 0;
302327
@@ -308,10 +333,6 @@ int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice)
308333 m_BufInfo[noteNo].indexTotal = indexTotal;
309334 }
310335
311- //逆順インデックスバッファ生成
312- result = _CreateRevIndexBuffer(pD3DDevice, indexTotal);
313- if (result != 0) goto EXIT;
314-
315336 //逆順インデックスのオフセット情報を生成
316337 unsigned long revIndexNum = indexTotal;
317338 unsigned long revIndexTotal = 0;
@@ -327,28 +348,37 @@ int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice)
327348 }
328349
329350 unsigned long* pIndex = NULL;
330- unsigned long* pRevIndex = NULL;
331351 unsigned long size = indexTotal * sizeof(unsigned long);
332352
333353 //インデックスバッファのロック
334354 result = m_PrimitiveKeyboard.LockIndex(&pIndex, 0, size);
335355 if (result != 0) goto EXIT;
336356
337- //逆順インデックスバッファのロック
338- result = _LockRevIndex(&pRevIndex, 0, size);
339- if (result != 0) goto EXIT;
357+ //描画インデックスバッファ生成
358+ for (int bufferIdx = 0; bufferIdx < MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX; bufferIdx++) {
340359
341- ZeroMemory(pRevIndex, size);
360+ result = _CreateRenderingIndexBuffer(pD3DDevice, bufferIdx, indexTotal);
361+ if (result != 0) goto EXIT;
342362
343- //バッファに逆順インデックスを書き込む
344- for (unsigned char noteNo = 0; noteNo < SM_MAX_NOTE_NUM; noteNo++) {
345- result = _CreateRevIndexOfKey(noteNo, pIndex, pRevIndex);
363+ unsigned long* pRenderingIndex = NULL;
364+
365+ //描画インデックスバッファのロック
366+ result = _LockRenderingIndex(&pRenderingIndex, bufferIdx, 0, size);
346367 if (result != 0) goto EXIT;
347- }
348368
349- //逆順インデックスバッファのロック解除
350- result = _UnlockRevIndex();
351- if (result != 0) goto EXIT;
369+ ZeroMemory(pRenderingIndex, size);
370+
371+ //バッファに描画インデックスを書き込む
372+ for (unsigned char noteNo = 0; noteNo < SM_MAX_NOTE_NUM; noteNo++) {
373+ result = _CreateRenderingIndexOfKey(noteNo, bufferIdx, pIndex, pRenderingIndex);
374+ if (result != 0) goto EXIT;
375+ }
376+
377+ //描画インデックスバッファのロック解除
378+ result = _UnlockRenderingIndex(bufferIdx);
379+ if (result != 0) goto EXIT;
380+
381+ }
352382
353383 //インデックスバッファのロック解除
354384 result = m_PrimitiveKeyboard.UnlockIndex();
@@ -359,30 +389,530 @@ EXIT:;
359389 }
360390
361391 //******************************************************************************
362-// キー単位の逆順インデックス生成
392+// キー単位の描画インデックス生成
363393 //******************************************************************************
364-int MTPianoKeyboardMod::_CreateRevIndexOfKey(
394+int MTPianoKeyboardMod::_CreateRenderingIndexOfKey(
365395 unsigned char noteNo,
396+ int bufferIdx,
366397 unsigned long* pIndex,
367- unsigned long* pRevIndex
398+ unsigned long* pRenderingIndex
368399 )
369400 {
370401 int result = 0;
371402
403+ if ((bufferIdx < 0) || (bufferIdx >= MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX)) {
404+ result = YN_SET_ERR("Program error.", 0, 0);
405+ goto EXIT;
406+ }
407+
408+ //カメラ位置分類コード: UP(0)/DOWN(1) - MID(0)/BACK(1) - MID(0)/FRONT(1) - LEFT(0)/RIGHT(1)
409+
410+ //白鍵1 キー平面描画順
411+ static int idxWhiteKey1[][PLANE_INDEX_WHITEKEY1_MAX] =
412+ {
413+ //0000
414+ {
415+ PLANE_INDEX_DOWN,
416+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
417+ PLANE_INDEX_BACK,
418+ PLANE_INDEX_FRONT,
419+ PLANE_INDEX_LEFT,
420+ PLANE_INDEX_UP
421+ },
422+ //0001
423+ {
424+ PLANE_INDEX_DOWN,
425+ PLANE_INDEX_LEFT,
426+ PLANE_INDEX_FRONT,
427+ PLANE_INDEX_BACK,
428+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
429+ PLANE_INDEX_UP
430+ },
431+ //0010
432+ {
433+ PLANE_INDEX_DOWN,
434+ PLANE_INDEX_BACK,
435+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
436+ PLANE_INDEX_LEFT,
437+ PLANE_INDEX_FRONT,
438+ PLANE_INDEX_UP
439+ },
440+ //0011
441+ {
442+ PLANE_INDEX_DOWN,
443+ PLANE_INDEX_BACK,
444+ PLANE_INDEX_LEFT,
445+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
446+ PLANE_INDEX_FRONT,
447+ PLANE_INDEX_UP
448+ },
449+ //0100
450+ {
451+ PLANE_INDEX_DOWN,
452+ PLANE_INDEX_FRONT,
453+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
454+ PLANE_INDEX_LEFT,
455+ PLANE_INDEX_BACK,
456+ PLANE_INDEX_UP
457+ },
458+ //0101
459+ {
460+ PLANE_INDEX_DOWN,
461+ PLANE_INDEX_FRONT,
462+ PLANE_INDEX_LEFT,
463+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
464+ PLANE_INDEX_BACK,
465+ PLANE_INDEX_UP
466+ },
467+
468+ //1000
469+ {
470+ PLANE_INDEX_UP,
471+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
472+ PLANE_INDEX_BACK,
473+ PLANE_INDEX_FRONT,
474+ PLANE_INDEX_LEFT,
475+ PLANE_INDEX_DOWN
476+ },
477+ //1001
478+ {
479+ PLANE_INDEX_UP,
480+ PLANE_INDEX_LEFT,
481+ PLANE_INDEX_FRONT,
482+ PLANE_INDEX_BACK,
483+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
484+ PLANE_INDEX_DOWN
485+ },
486+ //1010
487+ {
488+ PLANE_INDEX_UP,
489+ PLANE_INDEX_BACK,
490+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
491+ PLANE_INDEX_LEFT,
492+ PLANE_INDEX_FRONT,
493+ PLANE_INDEX_DOWN
494+ },
495+ //1011
496+ {
497+ PLANE_INDEX_UP,
498+ PLANE_INDEX_BACK,
499+ PLANE_INDEX_LEFT,
500+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
501+ PLANE_INDEX_FRONT,
502+ PLANE_INDEX_DOWN
503+ },
504+ //1100
505+ {
506+ PLANE_INDEX_UP,
507+ PLANE_INDEX_FRONT,
508+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
509+ PLANE_INDEX_LEFT,
510+ PLANE_INDEX_BACK,
511+ PLANE_INDEX_DOWN
512+ },
513+ //1101
514+ {
515+ PLANE_INDEX_UP,
516+ PLANE_INDEX_FRONT,
517+ PLANE_INDEX_LEFT,
518+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
519+ PLANE_INDEX_BACK,
520+ PLANE_INDEX_DOWN
521+ },
522+ };
523+
524+ //白鍵2 キー平面描画順
525+ static int idxWhiteKey2[][PLANE_INDEX_WHITEKEY2_MAX] =
526+ {
527+ //0000
528+ {
529+ PLANE_INDEX_DOWN,
530+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
531+ PLANE_INDEX_BACK,
532+ PLANE_INDEX_FRONT,
533+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
534+ PLANE_INDEX_UP
535+ },
536+ //0001
537+ {
538+ PLANE_INDEX_DOWN,
539+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
540+ PLANE_INDEX_FRONT,
541+ PLANE_INDEX_BACK,
542+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
543+ PLANE_INDEX_UP
544+ },
545+ //0010
546+ {
547+ PLANE_INDEX_DOWN,
548+ PLANE_INDEX_BACK,
549+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
550+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
551+ PLANE_INDEX_FRONT,
552+ PLANE_INDEX_UP
553+ },
554+ //0011
555+ {
556+ PLANE_INDEX_DOWN,
557+ PLANE_INDEX_BACK,
558+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
559+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
560+ PLANE_INDEX_FRONT,
561+ PLANE_INDEX_UP
562+ },
563+ //0100
564+ {
565+ PLANE_INDEX_DOWN,
566+ PLANE_INDEX_FRONT,
567+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
568+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
569+ PLANE_INDEX_BACK,
570+ PLANE_INDEX_UP
571+ },
572+ //0101
573+ {
574+ PLANE_INDEX_DOWN,
575+ PLANE_INDEX_FRONT,
576+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
577+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
578+ PLANE_INDEX_BACK,
579+ PLANE_INDEX_UP
580+ },
581+
582+ //1000
583+ {
584+ PLANE_INDEX_UP,
585+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
586+ PLANE_INDEX_BACK,
587+ PLANE_INDEX_FRONT,
588+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
589+ PLANE_INDEX_DOWN
590+ },
591+ //1001
592+ {
593+ PLANE_INDEX_UP,
594+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
595+ PLANE_INDEX_FRONT,
596+ PLANE_INDEX_BACK,
597+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
598+ PLANE_INDEX_DOWN
599+ },
600+ //1010
601+ {
602+ PLANE_INDEX_UP,
603+ PLANE_INDEX_BACK,
604+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
605+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
606+ PLANE_INDEX_FRONT,
607+ PLANE_INDEX_DOWN
608+ },
609+ //1011
610+ {
611+ PLANE_INDEX_UP,
612+ PLANE_INDEX_BACK,
613+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
614+ PLANE_INDEX_RIGHT_BACK, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_FRONT,
615+ PLANE_INDEX_FRONT,
616+ PLANE_INDEX_DOWN
617+ },
618+ //1100
619+ {
620+ PLANE_INDEX_UP,
621+ PLANE_INDEX_FRONT,
622+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
623+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
624+ PLANE_INDEX_BACK,
625+ PLANE_INDEX_DOWN
626+ },
627+ //1101
628+ {
629+ PLANE_INDEX_UP,
630+ PLANE_INDEX_FRONT,
631+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
632+ PLANE_INDEX_RIGHT_FRONT, PLANE_INDEX_MIDDLE_RIGHT, PLANE_INDEX_RIGHT_BACK,
633+ PLANE_INDEX_BACK,
634+ PLANE_INDEX_DOWN
635+ },
636+ };
637+
638+ //白鍵3 キー平面描画順
639+ static int idxWhiteKey3[][PLANE_INDEX_WHITEKEY3_MAX] =
640+ {
641+ //0000
642+ {
643+ PLANE_INDEX_DOWN,
644+ PLANE_INDEX_RIGHT,
645+ PLANE_INDEX_BACK,
646+ PLANE_INDEX_FRONT,
647+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
648+ PLANE_INDEX_UP
649+ },
650+ //0001
651+ {
652+ PLANE_INDEX_DOWN,
653+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
654+ PLANE_INDEX_FRONT,
655+ PLANE_INDEX_BACK,
656+ PLANE_INDEX_RIGHT,
657+ PLANE_INDEX_UP
658+ },
659+ //0010
660+ {
661+ PLANE_INDEX_DOWN,
662+ PLANE_INDEX_BACK,
663+ PLANE_INDEX_RIGHT,
664+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
665+ PLANE_INDEX_FRONT,
666+ PLANE_INDEX_UP
667+ },
668+ //0011
669+ {
670+ PLANE_INDEX_DOWN,
671+ PLANE_INDEX_BACK,
672+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
673+ PLANE_INDEX_RIGHT,
674+ PLANE_INDEX_FRONT,
675+ PLANE_INDEX_UP
676+ },
677+ //0100
678+ {
679+ PLANE_INDEX_DOWN,
680+ PLANE_INDEX_FRONT,
681+ PLANE_INDEX_RIGHT,
682+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
683+ PLANE_INDEX_BACK,
684+ PLANE_INDEX_UP
685+ },
686+ //0101
687+ {
688+ PLANE_INDEX_DOWN,
689+ PLANE_INDEX_FRONT,
690+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
691+ PLANE_INDEX_RIGHT,
692+ PLANE_INDEX_BACK,
693+ PLANE_INDEX_UP
694+ },
695+
696+ //1000
697+ {
698+ PLANE_INDEX_UP,
699+ PLANE_INDEX_RIGHT,
700+ PLANE_INDEX_BACK,
701+ PLANE_INDEX_FRONT,
702+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
703+ PLANE_INDEX_DOWN
704+ },
705+ //1001
706+ {
707+ PLANE_INDEX_UP,
708+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
709+ PLANE_INDEX_FRONT,
710+ PLANE_INDEX_BACK,
711+ PLANE_INDEX_RIGHT,
712+ PLANE_INDEX_DOWN
713+ },
714+ //1010
715+ {
716+ PLANE_INDEX_UP,
717+ PLANE_INDEX_BACK,
718+ PLANE_INDEX_RIGHT,
719+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
720+ PLANE_INDEX_FRONT,
721+ PLANE_INDEX_DOWN
722+ },
723+ //1011
724+ {
725+ PLANE_INDEX_UP,
726+ PLANE_INDEX_BACK,
727+ PLANE_INDEX_LEFT_BACK, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_FRONT,
728+ PLANE_INDEX_RIGHT,
729+ PLANE_INDEX_FRONT,
730+ PLANE_INDEX_DOWN
731+ },
732+ //1100
733+ {
734+ PLANE_INDEX_UP,
735+ PLANE_INDEX_FRONT,
736+ PLANE_INDEX_RIGHT,
737+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
738+ PLANE_INDEX_BACK,
739+ PLANE_INDEX_DOWN
740+ },
741+ //1101
742+ {
743+ PLANE_INDEX_UP,
744+ PLANE_INDEX_FRONT,
745+ PLANE_INDEX_LEFT_FRONT, PLANE_INDEX_MIDDLE_LEFT, PLANE_INDEX_LEFT_BACK,
746+ PLANE_INDEX_RIGHT,
747+ PLANE_INDEX_BACK,
748+ PLANE_INDEX_DOWN
749+ },
750+ };
751+
752+ //黒鍵 キー平面描画順
753+ static int idxBlackKey[][PLANE_INDEX_BLACKKEY_MAX] =
754+ {
755+ //0000
756+ {
757+ PLANE_INDEX_DOWN,
758+ PLANE_INDEX_RIGHT,
759+ PLANE_INDEX_BACK,
760+ PLANE_INDEX_FRONT,
761+ PLANE_INDEX_LEFT,
762+ PLANE_INDEX_UP
763+ },
764+ //0001
765+ {
766+ PLANE_INDEX_DOWN,
767+ PLANE_INDEX_LEFT,
768+ PLANE_INDEX_FRONT,
769+ PLANE_INDEX_BACK,
770+ PLANE_INDEX_RIGHT,
771+ PLANE_INDEX_UP
772+ },
773+ //0010
774+ {
775+ PLANE_INDEX_DOWN,
776+ PLANE_INDEX_BACK,
777+ PLANE_INDEX_RIGHT,
778+ PLANE_INDEX_LEFT,
779+ PLANE_INDEX_FRONT,
780+ PLANE_INDEX_UP
781+ },
782+ //0011
783+ {
784+ PLANE_INDEX_DOWN,
785+ PLANE_INDEX_BACK,
786+ PLANE_INDEX_LEFT,
787+ PLANE_INDEX_RIGHT,
788+ PLANE_INDEX_FRONT,
789+ PLANE_INDEX_UP
790+ },
791+ //0100
792+ {
793+ PLANE_INDEX_DOWN,
794+ PLANE_INDEX_FRONT,
795+ PLANE_INDEX_RIGHT,
796+ PLANE_INDEX_LEFT,
797+ PLANE_INDEX_BACK,
798+ PLANE_INDEX_UP
799+ },
800+ //0101
801+ {
802+ PLANE_INDEX_DOWN,
803+ PLANE_INDEX_FRONT,
804+ PLANE_INDEX_LEFT,
805+ PLANE_INDEX_RIGHT,
806+ PLANE_INDEX_BACK,
807+ PLANE_INDEX_UP
808+ },
809+
810+ //1000
811+ {
812+ PLANE_INDEX_UP,
813+ PLANE_INDEX_RIGHT,
814+ PLANE_INDEX_BACK,
815+ PLANE_INDEX_FRONT,
816+ PLANE_INDEX_LEFT,
817+ PLANE_INDEX_DOWN
818+ },
819+ //1001
820+ {
821+ PLANE_INDEX_UP,
822+ PLANE_INDEX_LEFT,
823+ PLANE_INDEX_FRONT,
824+ PLANE_INDEX_BACK,
825+ PLANE_INDEX_RIGHT,
826+ PLANE_INDEX_DOWN
827+ },
828+ //1010
829+ {
830+ PLANE_INDEX_UP,
831+ PLANE_INDEX_BACK,
832+ PLANE_INDEX_RIGHT,
833+ PLANE_INDEX_LEFT,
834+ PLANE_INDEX_FRONT,
835+ PLANE_INDEX_DOWN
836+ },
837+ //1011
838+ {
839+ PLANE_INDEX_UP,
840+ PLANE_INDEX_BACK,
841+ PLANE_INDEX_LEFT,
842+ PLANE_INDEX_RIGHT,
843+ PLANE_INDEX_FRONT,
844+ PLANE_INDEX_DOWN
845+ },
846+ //1100
847+ {
848+ PLANE_INDEX_UP,
849+ PLANE_INDEX_FRONT,
850+ PLANE_INDEX_RIGHT,
851+ PLANE_INDEX_LEFT,
852+ PLANE_INDEX_BACK,
853+ PLANE_INDEX_DOWN
854+ },
855+ //1101
856+ {
857+ PLANE_INDEX_UP,
858+ PLANE_INDEX_FRONT,
859+ PLANE_INDEX_LEFT,
860+ PLANE_INDEX_RIGHT,
861+ PLANE_INDEX_BACK,
862+ PLANE_INDEX_DOWN
863+ },
864+ };
865+
372866 unsigned long srcOffset = m_BufInfo[noteNo].indexPos;
373- unsigned long dstOffset = m_BufInfo[noteNo].revIndexPos;
867+ // カメラ視点より右のキー(カメラ位置分類コードがLEFT)は高音側から描画する
868+ unsigned long dstOffset = bufferIdx % 2 == 0 ? m_BufInfo[noteNo].revIndexPos : srcOffset;
374869 unsigned long size = m_BufInfo[noteNo].indexNum;
375870
376- ::memcpy(pRevIndex + dstOffset, pIndex + srcOffset, sizeof(unsigned long) * size);
871+ int *pPlaneIndex;
872+ int planeIndexSize;
873+
874+ switch (m_BufInfo[noteNo].keyType)
875+ {
876+ case MTPianoKeyboardMod::KeyWhite1:
877+ pPlaneIndex = idxWhiteKey1[bufferIdx];
878+ planeIndexSize = PLANE_INDEX_WHITEKEY1_MAX;
879+ break;
880+ case MTPianoKeyboardMod::KeyWhite2:
881+ pPlaneIndex = idxWhiteKey2[bufferIdx];
882+ planeIndexSize = PLANE_INDEX_WHITEKEY2_MAX;
883+ break;
884+ case MTPianoKeyboardMod::KeyWhite3:
885+ pPlaneIndex = idxWhiteKey3[bufferIdx];
886+ planeIndexSize = PLANE_INDEX_WHITEKEY3_MAX;
887+ break;
888+ case MTPianoKeyboardMod::KeyBlack:
889+ pPlaneIndex = idxBlackKey[bufferIdx];
890+ planeIndexSize = PLANE_INDEX_BLACKKEY_MAX;
891+ break;
892+ default:
893+ pPlaneIndex = NULL;
894+ planeIndexSize = 0;
895+ break;
896+ }
897+
898+ for (int i = 0; i < planeIndexSize; i++) {
899+ int planeIndex = pPlaneIndex[i];
900+ int planeOffset = m_BufInfo[noteNo].planeIndexPos[planeIndex];
901+ int planeSize = m_BufInfo[noteNo].planeIndexNum[planeIndex];
902+ ::memcpy(pRenderingIndex + dstOffset, pIndex + srcOffset + planeOffset, sizeof(unsigned long) * planeSize);
903+ dstOffset += planeSize;
904+ }
377905
906+EXIT:
378907 return result;
379908 }
380909
381910 //******************************************************************************
382-// 逆順インデックスバッファ生成
911+// 描画インデックスバッファ生成
383912 //******************************************************************************
384-int MTPianoKeyboardMod::_CreateRevIndexBuffer(
913+int MTPianoKeyboardMod::_CreateRenderingIndexBuffer(
385914 LPDIRECT3DDEVICE9 pD3DDevice,
915+ int bufferIdx,
386916 unsigned long indexNum
387917 )
388918 {
@@ -393,7 +923,13 @@ int MTPianoKeyboardMod::_CreateRevIndexBuffer(
393923 result = YN_SET_ERR("Program error.", 0, 0);
394924 goto EXIT;
395925 }
396- if (m_pRevIndexBuffer != NULL) {
926+
927+ if ((bufferIdx < 0) || (bufferIdx >= MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX)) {
928+ result = YN_SET_ERR("Program error.", 0, 0);
929+ goto EXIT;
930+ }
931+
932+ if (m_pRenderingIndexBuffer[bufferIdx] != NULL) {
397933 result = YN_SET_ERR("Program error.", 0, 0);
398934 goto EXIT;
399935 }
@@ -401,13 +937,12 @@ int MTPianoKeyboardMod::_CreateRevIndexBuffer(
401937 //インデックスバッファ生成
402938 if (indexNum > 0) {
403939 hresult = pD3DDevice->CreateIndexBuffer(
404- sizeof(unsigned long) * indexNum,
405- //インデックスバッファの全体サイズ(byte)
406- D3DUSAGE_WRITEONLY, //使用方法
407- D3DFMT_INDEX32, //インデックスバッファのフォーマット
408- D3DPOOL_MANAGED, //リソース配置場所となるメモリクラス
409- &m_pRevIndexBuffer, //作成されたインデックスバッファ
410- NULL //予約パラメータ
940+ sizeof(unsigned long) * indexNum, //インデックスバッファの全体サイズ(byte)
941+ D3DUSAGE_WRITEONLY, //使用方法
942+ D3DFMT_INDEX32, //インデックスバッファのフォーマット
943+ D3DPOOL_MANAGED, //リソース配置場所となるメモリクラス
944+ &m_pRenderingIndexBuffer[bufferIdx], //作成されたインデックスバッファ
945+ NULL //予約パラメータ
411946 );
412947 if (FAILED(hresult)) {
413948 result = YN_SET_ERR("DirectX API error.", hresult, indexNum);
@@ -415,17 +950,18 @@ int MTPianoKeyboardMod::_CreateRevIndexBuffer(
415950 }
416951 }
417952
418- m_RevIndexNum = indexNum;
953+ m_RenderingIndexNum[bufferIdx] = indexNum;
419954
420955 EXIT:;
421956 return result;
422957 }
423958
424959 //******************************************************************************
425-// 逆順インデックスバッファロック
960+// 描画インデックスバッファロック
426961 //******************************************************************************
427-int MTPianoKeyboardMod::_LockRevIndex(
962+int MTPianoKeyboardMod::_LockRenderingIndex(
428963 unsigned long** pPtrIndex,
964+ int bufferIdx,
429965 unsigned long offset, //省略時はゼロ
430966 unsigned long size //省略時はゼロ
431967 )
@@ -433,19 +969,24 @@ int MTPianoKeyboardMod::_LockRevIndex(
433969 int result = 0;
434970 HRESULT hresult = D3D_OK;
435971
436- if (m_IsRevIndexLocked) {
972+ if ((bufferIdx < 0) || (bufferIdx >= MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX)) {
437973 result = YN_SET_ERR("Program error.", 0, 0);
438974 goto EXIT;
439975 }
440976
441- if ((sizeof(unsigned long) * m_RevIndexNum) < (offset + size)) {
977+ if (m_IsRenderingIndexLocked[bufferIdx]) {
978+ result = YN_SET_ERR("Program error.", 0, 0);
979+ goto EXIT;
980+ }
981+
982+ if ((sizeof(unsigned long) * m_RenderingIndexNum[bufferIdx]) < (offset + size)) {
442983 result = YN_SET_ERR("Program error.", offset, size);
443984 goto EXIT;
444985 }
445986
446987 //インデックスバッファのロックとバッファメモリポインタ取得
447- if (m_pRevIndexBuffer != NULL) {
448- hresult = m_pRevIndexBuffer->Lock(
988+ if (m_pRenderingIndexBuffer[bufferIdx] != NULL) {
989+ hresult = m_pRenderingIndexBuffer[bufferIdx]->Lock(
449990 offset, //ロックするインデックスのオフセット(byte)
450991 size, //ロックするインデックスのサイズ(byte)
451992 (void**)pPtrIndex, //バッファメモリポインタ
@@ -457,29 +998,31 @@ int MTPianoKeyboardMod::_LockRevIndex(
457998 }
458999 }
4591000
460- m_IsRevIndexLocked = true;
1001+ m_IsRenderingIndexLocked[bufferIdx] = true;
4611002
4621003 EXIT:;
4631004 return result;
4641005 }
4651006
4661007 //******************************************************************************
467-// 逆順インデックスバッファロック解除
1008+// 描画インデックスバッファロック解除
4681009 //******************************************************************************
469-int MTPianoKeyboardMod::_UnlockRevIndex()
1010+int MTPianoKeyboardMod::_UnlockRenderingIndex(
1011+ int bufferIdx
1012+ )
4701013 {
4711014 int result = 0;
4721015 HRESULT hresult = D3D_OK;
4731016
474- if (m_IsRevIndexLocked) {
475- if (m_pRevIndexBuffer != NULL) {
476- hresult = m_pRevIndexBuffer->Unlock();
1017+ if (m_IsRenderingIndexLocked[bufferIdx]) {
1018+ if (m_pRenderingIndexBuffer[bufferIdx] != NULL) {
1019+ hresult = m_pRenderingIndexBuffer[bufferIdx]->Unlock();
4771020 if (FAILED(hresult)) {
4781021 result = YN_SET_ERR("DirectX API error.", hresult, 0);
4791022 goto EXIT;
4801023 }
4811024 }
482- m_IsRevIndexLocked = false;
1025+ m_IsRenderingIndexLocked[bufferIdx] = false;
4831026 }
4841027
4851028 EXIT:;
@@ -504,30 +1047,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
5041047 pColor
5051048 );
5061049
507- // 描画順の修正
1050+ //キー種別
1051+ m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyWhite1;
1052+
1053+ //描画順の再生成
5081054 int idx = 0;
5091055
5101056 //----------------------------------------------------------------
511- //下の面
1057+ //上の面
5121058 //----------------------------------------------------------------
513- // 37 6+--+5 36
514- // | |
515- // | |
516- // | |4 35
517- // 34 3+--+--+2 33
518- // | | +z
519- // | | |
520- // | | |
521- // 31 0+-----+1 32 +---> +x
522- // |
523- // posX
1059+ // 6+--+5
1060+ // | |
1061+ // | |
1062+ // | |4
1063+ // 3+--+--+2
1064+ // | | +z
1065+ // | | |
1066+ // | | |
1067+ // 0+-----+1 +---> +x
1068+ // |
1069+ // posX
5241070
525- //下面インデックス
526- unsigned long indexDW[] = { 31, 32, 33, 31, 33, 34, 34, 35, 36, 34, 36, 37 };
1071+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_UP] = idx;
1072+
1073+ //インデックス
1074+ unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 3, 5, 4, 3, 6, 5 };
5271075 for (int i = 0; i < 12; i++) {
528- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
1076+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
5291077 }
5301078
1079+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long);
1080+
5311081 //----------------------------------------------------------------
5321082 //側面 0-1
5331083 //----------------------------------------------------------------
@@ -536,12 +1086,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
5361086 // | |
5371087 // 9+----+10
5381088
1089+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx;
1090+
5391091 //インデックス
5401092 unsigned long index01[] = { 7, 8, 9, 8, 10, 9 };
5411093 for (int i = 0; i < 6; i++) {
5421094 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i];
5431095 }
5441096
1097+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long);
1098+
5451099 //----------------------------------------------------------------
5461100 //側面 1-2
5471101 //----------------------------------------------------------------
@@ -550,12 +1104,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
5501104 // | |
5511105 // 1 11+--+13
5521106
1107+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_FRONT] = idx;
1108+
5531109 //インデックス
5541110 unsigned long index12[] = { 11, 12, 13, 12, 14, 13 };
5551111 for (int i = 0; i < 6; i++) {
5561112 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index12[i];
5571113 }
5581114
1115+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_FRONT] = sizeof(index12) / sizeof(unsigned long);
1116+
5591117 //----------------------------------------------------------------
5601118 //側面 2-4
5611119 //----------------------------------------------------------------
@@ -563,12 +1121,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
5631121 // | |
5641122 // 4 16+--+15 2
5651123
1124+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_RIGHT] = idx;
1125+
5661126 //インデックス
5671127 unsigned long index24[] = { 15, 16, 17, 16, 18, 17 };
5681128 for (int i = 0; i < 6; i++) {
5691129 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index24[i];
5701130 }
5711131
1132+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_RIGHT] = sizeof(index24) / sizeof(unsigned long);
1133+
5721134 //----------------------------------------------------------------
5731135 //側面 4-5
5741136 //----------------------------------------------------------------
@@ -577,12 +1139,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
5771139 // | |
5781140 // 4 19+--+21
5791141
1142+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_BACK] = idx;
1143+
5801144 //インデックス
5811145 unsigned long index45[] = { 19, 20, 21, 20, 22, 21 };
5821146 for (int i = 0; i < 6; i++) {
5831147 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index45[i];
5841148 }
5851149
1150+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_BACK] = sizeof(index45) / sizeof(unsigned long);
1151+
5861152 //----------------------------------------------------------------
5871153 //側面 5-6
5881154 //----------------------------------------------------------------
@@ -590,12 +1156,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
5901156 // | |
5911157 // 6 24+--+23 5
5921158
1159+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx;
1160+
5931161 //インデックス
5941162 unsigned long index56[] = { 23, 24, 25, 24, 26, 25 };
5951163 for (int i = 0; i < 6; i++) {
5961164 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i];
5971165 }
5981166
1167+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index56) / sizeof(unsigned long);
1168+
5991169 //----------------------------------------------------------------
6001170 //側面 6-0
6011171 //----------------------------------------------------------------
@@ -604,33 +1174,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1(
6041174 // | |
6051175 // 30+--+28 0
6061176
1177+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT] = idx;
1178+
6071179 //インデックス
6081180 unsigned long index60[] = { 27, 28, 29, 28, 30, 29 };
6091181 for (int i = 0; i < 6; i++) {
6101182 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index60[i];
6111183 }
6121184
1185+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT] = sizeof(index60) / sizeof(unsigned long);
1186+
6131187 //----------------------------------------------------------------
614- //上の面
1188+ //下の面
6151189 //----------------------------------------------------------------
616- // 6+--+5
617- // | |
618- // | |
619- // | |4
620- // 3+--+--+2
621- // | | +z
622- // | | |
623- // | | |
624- // 0+-----+1 +---> +x
625- // |
626- // posX
1190+ // 37 6+--+5 36
1191+ // | |
1192+ // | |
1193+ // | |4 35
1194+ // 34 3+--+--+2 33
1195+ // | | +z
1196+ // | | |
1197+ // | | |
1198+ // 31 0+-----+1 32 +---> +x
1199+ // |
1200+ // posX
6271201
628- //インデックス
629- unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 3, 5, 4, 3, 6, 5 };
1202+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_DOWN] = idx;
1203+
1204+ //下面インデックス
1205+ unsigned long indexDW[] = { 31, 32, 33, 31, 33, 34, 34, 35, 36, 34, 36, 37 };
6301206 for (int i = 0; i < 12; i++) {
631- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
1207+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
6321208 }
6331209
1210+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long);
1211+
6341212 return result;
6351213 }
6361214
@@ -663,29 +1241,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
6631241 keyColor = *pColor;
6641242 }
6651243
666- // 描画順の修正
1244+ //キー種別
1245+ m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyWhite2;
1246+
1247+ //描画順の再生成
6671248 int idx = 0;
6681249
6691250 //----------------------------------------------------------------
670- //下の面
1251+ //上の面
6711252 //----------------------------------------------------------------
672- // 42 6+-+5 41
673- // | |
674- // | |
675- // 43 7| |4 40
676- // 39 3+-+-+-+2 38
677- // | | +z
678- // | | |
679- // | | |
680- // 36 0+-----+1 37 +---> +x
681- // |
682- // posX
1253+ // 6+-+5
1254+ // | |
1255+ // | |
1256+ // 7| |4
1257+ // 3+-+-+-+2
1258+ // | | +z
1259+ // | | |
1260+ // | | |
1261+ // 0+-----+1 +---> +x
1262+ // |
1263+ // posX
1264+
1265+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_UP] = idx;
6831266
6841267 //インデックス
685- unsigned long indexDW[] = { 36, 37, 38, 36, 38, 39, 43, 40, 41, 43, 41, 42 };
1268+ unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 7, 5, 4, 7, 6, 5 };
6861269 for (int i = 0; i < 12; i++) {
687- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
1270+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
6881271 }
1272+
1273+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long);
1274+
6891275 //----------------------------------------------------------------
6901276 //側面 0-1
6911277 //----------------------------------------------------------------
@@ -694,12 +1280,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
6941280 // | |
6951281 // 10+----+11
6961282
1283+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx;
1284+
6971285 //インデックス
6981286 unsigned long index01[] = { 8, 9, 10, 9, 11, 10 };
6991287 for (int i = 0; i < 6; i++) {
7001288 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i];
7011289 }
7021290
1291+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long);
1292+
7031293 //----------------------------------------------------------------
7041294 //側面 1-2
7051295 //----------------------------------------------------------------
@@ -708,12 +1298,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7081298 // | |
7091299 // 1 12+--+14
7101300
1301+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_FRONT] = idx;
1302+
7111303 //インデックス
7121304 unsigned long index12[] = { 12, 13, 14, 13, 15, 14 };
7131305 for (int i = 0; i < 6; i++) {
7141306 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index12[i];
7151307 }
7161308
1309+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_FRONT] = sizeof(index12) / sizeof(unsigned long);
1310+
7171311 //----------------------------------------------------------------
7181312 //側面 2-4
7191313 //----------------------------------------------------------------
@@ -721,6 +1315,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7211315 // | |
7221316 // 4 17+--+16 2
7231317
1318+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_RIGHT] = idx;
1319+
7241320 //基底クラスでは2-3で生成しているが、透過すると4-7間が仕切りとして
7251321 //見えてしまうため、2-4、7-3に分割する
7261322
@@ -734,6 +1330,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7341330 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index24[i];
7351331 }
7361332
1333+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_RIGHT] = sizeof(index24) / sizeof(unsigned long);
1334+
7371335 //----------------------------------------------------------------
7381336 //側面 4-5
7391337 //----------------------------------------------------------------
@@ -742,12 +1340,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7421340 // | |
7431341 // 4 20+--+22
7441342
1343+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_BACK] = idx;
1344+
7451345 //インデックス
7461346 unsigned long index45[] = { 20, 21, 22, 21, 23, 22 };
7471347 for (int i = 0; i < 6; i++) {
7481348 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index45[i];
7491349 }
7501350
1351+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_BACK] = sizeof(index45) / sizeof(unsigned long);
1352+
7511353 //----------------------------------------------------------------
7521354 //側面 5-6
7531355 //----------------------------------------------------------------
@@ -755,12 +1357,15 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7551357 // | |
7561358 // 6 25+--+24 5
7571359
1360+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx;
1361+
7581362 //インデックス
7591363 unsigned long index56[] = { 24, 25, 26, 25, 27, 26 };
7601364 for (int i = 0; i < 6; i++) {
7611365 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i];
7621366 }
7631367
1368+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index56) / sizeof(unsigned long);
7641369
7651370 //----------------------------------------------------------------
7661371 //側面 6-7
@@ -770,12 +1375,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7701375 // | |
7711376 // 31+--+29 7
7721377
1378+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_BACK] = idx;
1379+
7731380 //インデックス
7741381 unsigned long index67[] = { 28, 29, 30, 29, 31, 30 };
7751382 for (int i = 0; i < 6; i++) {
7761383 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index67[i];
7771384 }
7781385
1386+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_BACK] = sizeof(index67) / sizeof(unsigned long);
1387+
7791388 //----------------------------------------------------------------
7801389 //側面 7-3
7811390 //----------------------------------------------------------------
@@ -783,6 +1392,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
7831392 // | |
7841393 // 3 45+--+44 7
7851394
1395+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_LEFT] = idx;
1396+
7861397 //頂点
7871398 pVertex[44].p = pVertex[7].p;
7881399 pVertex[45].p = pVertex[3].p;
@@ -801,6 +1412,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
8011412 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index73[i];
8021413 }
8031414
1415+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_LEFT] = sizeof(index73) / sizeof(unsigned long);
1416+
8041417 //単一色のテクスチャ座標
8051418 m_KeyboardDesign.GetWhiteKeyTexturePosSingleColor(noteNo, &tsc);
8061419 for (int i = 44; i < 48; i++) {
@@ -815,33 +1428,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2(
8151428 // | |
8161429 // 35+--+33 0
8171430
1431+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_FRONT] = idx;
1432+
8181433 //インデックス
8191434 unsigned long index30[] = { 32, 33, 34, 33, 35, 34 };
8201435 for (int i = 0; i < 6; i++) {
8211436 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index30[i];
8221437 }
8231438
1439+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_FRONT] = sizeof(index30) / sizeof(unsigned long);
1440+
8241441 //----------------------------------------------------------------
825- //上の面
1442+ //下の面
8261443 //----------------------------------------------------------------
827- // 6+-+5
828- // | |
829- // | |
830- // 7| |4
831- // 3+-+-+-+2
832- // | | +z
833- // | | |
834- // | | |
835- // 0+-----+1 +---> +x
836- // |
837- // posX
1444+ // 42 6+-+5 41
1445+ // | |
1446+ // | |
1447+ // 43 7| |4 40
1448+ // 39 3+-+-+-+2 38
1449+ // | | +z
1450+ // | | |
1451+ // | | |
1452+ // 36 0+-----+1 37 +---> +x
1453+ // |
1454+ // posX
1455+
1456+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_DOWN] = idx;
8381457
8391458 //インデックス
840- unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 7, 5, 4, 7, 6, 5 };
1459+ unsigned long indexDW[] = { 36, 37, 38, 36, 38, 39, 43, 40, 41, 43, 41, 42 };
8411460 for (int i = 0; i < 12; i++) {
842- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
1461+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
8431462 }
8441463
1464+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long);
1465+
8451466 return result;
8461467 }
8471468
@@ -863,30 +1484,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
8631484 pColor
8641485 );
8651486
866- // 描画順の修正
1487+ //キー種別
1488+ m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyWhite3;
1489+
1490+ //描画順の再生成
8671491 int idx = 0;
8681492
8691493 //----------------------------------------------------------------
870- //下の面
1494+ //上の面
8711495 //----------------------------------------------------------------
872- // 36 5+--+4 35
873- // | |
874- // | |
875- // 37 6| |
876- // 34 3+--+--+2 33
877- // | | +z
878- // | | |
879- // | | |
880- // 31 0+-----+1 32 +---> +x
881- // |
882- // posX
1496+ // 5+--+4
1497+ // | |
1498+ // | |
1499+ // 6| |
1500+ // 3+--+--+2
1501+ // | | +z
1502+ // | | |
1503+ // | | |
1504+ // 0+-----+1 +---> +x
1505+ // |
1506+ // posX
1507+
1508+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_UP] = idx;
8831509
8841510 //インデックス
885- unsigned long indexDW[] = { 31, 32, 33, 31, 33, 34, 33, 35, 37, 37, 35, 36 };
1511+ unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 2, 6, 4, 6, 5, 4 };
8861512 for (int i = 0; i < 12; i++) {
887- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
1513+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
8881514 }
8891515
1516+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long);
1517+
8901518 //----------------------------------------------------------------
8911519 //側面 0-1
8921520 //----------------------------------------------------------------
@@ -895,12 +1523,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
8951523 // | |
8961524 // 9+----+10
8971525
1526+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx;
1527+
8981528 //インデックス
8991529 unsigned long index01[] = { 7, 8, 9, 8, 10, 9 };
9001530 for (int i = 0; i < 6; i++) {
9011531 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i];
9021532 }
9031533
1534+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long);
1535+
9041536 //----------------------------------------------------------------
9051537 //側面 1-4
9061538 //----------------------------------------------------------------
@@ -909,12 +1541,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
9091541 // | |
9101542 // 1 11+--+13
9111543
1544+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT] = idx;
1545+
9121546 //インデックス
9131547 unsigned long index14[] = { 11, 12, 13, 12, 14, 13 };
9141548 for (int i = 0; i < 6; i++) {
9151549 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index14[i];
9161550 }
9171551
1552+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT] = sizeof(index14) / sizeof(unsigned long);
1553+
9181554 //----------------------------------------------------------------
9191555 //側面 4-5
9201556 //----------------------------------------------------------------
@@ -922,12 +1558,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
9221558 // | |
9231559 // 5 16+--+15 4
9241560
1561+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx;
1562+
9251563 //インデックス
9261564 unsigned long index45[] = { 15, 16, 17, 16, 18, 17 };
9271565 for (int i = 0; i < 6; i++) {
9281566 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index45[i];
9291567 }
9301568
1569+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index45) / sizeof(unsigned long);
1570+
9311571 //----------------------------------------------------------------
9321572 //側面 5-6
9331573 //----------------------------------------------------------------
@@ -936,12 +1576,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
9361576 // | |
9371577 // 22+--+20 6
9381578
1579+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_BACK] = idx;
1580+
9391581 //インデックス
9401582 unsigned long index56[] = { 19, 20, 21, 20, 22, 21 };
9411583 for (int i = 0; i < 6; i++) {
9421584 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i];
9431585 }
9441586
1587+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_BACK] = sizeof(index56) / sizeof(unsigned long);
1588+
9451589 //----------------------------------------------------------------
9461590 //側面 6-3
9471591 //----------------------------------------------------------------
@@ -949,12 +1593,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
9491593 // | |
9501594 // 3 24+--+23 6
9511595
1596+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_LEFT] = idx;
1597+
9521598 //インデックス
9531599 unsigned long index63[] = { 23, 24, 25, 24, 26, 25 };
9541600 for (int i = 0; i < 6; i++) {
9551601 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index63[i];
9561602 }
9571603
1604+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_LEFT] = sizeof(index63) / sizeof(unsigned long);
1605+
9581606 //----------------------------------------------------------------
9591607 //側面 3-0
9601608 //----------------------------------------------------------------
@@ -963,33 +1611,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3(
9631611 // | |
9641612 // 30+--+28 0
9651613
1614+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_FRONT] = idx;
1615+
9661616 //インデックス
9671617 unsigned long index30[] = { 27, 28, 29, 28, 30, 29 };
9681618 for (int i = 0; i < 6; i++) {
9691619 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index30[i];
9701620 }
9711621
1622+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_FRONT] = sizeof(index30) / sizeof(unsigned long);
1623+
9721624 //----------------------------------------------------------------
973- //上の面
1625+ //下の面
9741626 //----------------------------------------------------------------
975- // 5+--+4
976- // | |
977- // | |
978- // 6| |
979- // 3+--+--+2
980- // | | +z
981- // | | |
982- // | | |
983- // 0+-----+1 +---> +x
984- // |
985- // posX
1627+ // 36 5+--+4 35
1628+ // | |
1629+ // | |
1630+ // 37 6| |
1631+ // 34 3+--+--+2 33
1632+ // | | +z
1633+ // | | |
1634+ // | | |
1635+ // 31 0+-----+1 32 +---> +x
1636+ // |
1637+ // posX
1638+
1639+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_DOWN] = idx;
9861640
9871641 //インデックス
988- unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 2, 6, 4, 6, 5, 4 };
1642+ unsigned long indexDW[] = { 31, 32, 33, 31, 33, 34, 33, 35, 37, 37, 35, 36 };
9891643 for (int i = 0; i < 12; i++) {
990- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
1644+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
9911645 }
9921646
1647+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long);
1648+
9931649 return result;
9941650 }
9951651
@@ -1011,30 +1667,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack(
10111667 pColor
10121668 );
10131669
1014- // 描画順の修正
1670+ //キー種別
1671+ m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyBlack;
1672+
1673+ //描画順の修正
10151674 int idx = 0;
10161675
10171676 //----------------------------------------------------------------
1018- //下の面
1677+ //上の面
10191678 //----------------------------------------------------------------
1020- // 29 6+-+5 28
1021- // | |
1022- // | |
1023- // | |
1024- // 26 0+-+1 27
1025- // | +z
1026- // | |
1027- // | |
1028- // --+-- +---> +x
1029- // |
1030- // posX
1679+ // 6+-+5
1680+ // | |
1681+ // | |
1682+ // 7 3+-+2 4
1683+ // 0+-+1
1684+ // | +z
1685+ // | |
1686+ // | |
1687+ // --+-- +---> +x
1688+ // |
1689+ // posX
1690+
1691+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_UP] = idx;
10311692
10321693 //インデックス
1033- unsigned long indexDW[] = { 26, 27, 28, 26, 28, 29 };
1034- for (int i = 0; i < 6; i++) {
1035- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
1694+ unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 4, 7, 5, 7, 6, 5 };
1695+ for (int i = 0; i < 12; i++) {
1696+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
10361697 }
10371698
1699+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long);
1700+
10381701 //----------------------------------------------------------------
10391702 //側面 0-1
10401703 //----------------------------------------------------------------
@@ -1043,12 +1706,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack(
10431706 // | |
10441707 // 10+----+11
10451708
1709+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx;
1710+
10461711 //インデックス
10471712 unsigned long index01[] = { 8, 9, 10, 9, 11, 10 };
10481713 for (int i = 0; i < 6; i++) {
10491714 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i];
10501715 }
10511716
1717+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long);
1718+
10521719 //----------------------------------------------------------------
10531720 //側面 1-2-5
10541721 //----------------------------------------------------------------
@@ -1059,12 +1726,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack(
10591726 // \ |
10601727 // 1 12 +-+15
10611728
1729+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT] = idx;
1730+
10621731 //インデックス
10631732 unsigned long index125[] = { 12, 13, 15, 13, 16, 15, 13, 14, 16 };
10641733 for (int i = 0; i < 9; i++) {
10651734 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index125[i];
10661735 }
10671736
1737+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT] = sizeof(index125) / sizeof(unsigned long);
1738+
10681739 //----------------------------------------------------------------
10691740 //側面 5-6
10701741 //----------------------------------------------------------------
@@ -1072,12 +1743,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack(
10721743 // | |
10731744 // 6 18+--+17 5
10741745
1746+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx;
1747+
10751748 //インデックス
10761749 unsigned long index56[] = { 17, 18, 19, 18, 20, 19 };
10771750 for (int i = 0; i < 6; i++) {
10781751 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i];
10791752 }
10801753
1754+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index56) / sizeof(unsigned long);
1755+
10811756 //----------------------------------------------------------------
10821757 //側面 6-3-0
10831758 //----------------------------------------------------------------
@@ -1088,33 +1763,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack(
10881763 // | /
10891764 // 25+-+23 0
10901765
1766+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT] = idx;
1767+
10911768 //インデックス
10921769 unsigned long index630[] = { 21, 22, 24, 22, 25, 24, 22, 23, 25 };
10931770 for (int i = 0; i < 9; i++) {
10941771 pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index630[i];
10951772 }
10961773
1774+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT] = sizeof(index630) / sizeof(unsigned long);
1775+
10971776 //----------------------------------------------------------------
1098- //上の面
1777+ //下の面
10991778 //----------------------------------------------------------------
1100- // 6+-+5
1101- // | |
1102- // | |
1103- // 7 3+-+2 4
1104- // 0+-+1
1105- // | +z
1106- // | |
1107- // | |
1108- // --+-- +---> +x
1109- // |
1110- // posX
1779+ // 29 6+-+5 28
1780+ // | |
1781+ // | |
1782+ // | |
1783+ // 26 0+-+1 27
1784+ // | +z
1785+ // | |
1786+ // | |
1787+ // --+-- +---> +x
1788+ // |
1789+ // posX
1790+
1791+ m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_DOWN] = idx;
11111792
11121793 //インデックス
1113- unsigned long indexUP[] = { 0, 2, 1, 0, 3, 2, 4, 7, 5, 7, 6, 5 };
1114- for (int i = 0; i < 12; i++) {
1115- pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexUP[i];
1794+ unsigned long indexDW[] = { 26, 27, 28, 26, 28, 29 };
1795+ for (int i = 0; i < 6; i++) {
1796+ pIndex[idx++] = m_BufInfo[noteNo].vertexPos + indexDW[i];
11161797 }
11171798
1799+ m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long);
1800+
11181801 return result;
11191802 }
11201803
--- a/MIDITrail/MTPianoKeyboardMod.h
+++ b/MIDITrail/MTPianoKeyboardMod.h
@@ -15,6 +15,11 @@
1515
1616
1717 //******************************************************************************
18+// パラメータ定義
19+//******************************************************************************
20+#define MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX (12)
21+
22+//******************************************************************************
1823 // ピアノキーボード描画Modクラス
1924 //******************************************************************************
2025 class MTPianoKeyboardMod : public MTPianoKeyboard
@@ -57,29 +62,43 @@ public:
5762
5863 private:
5964
60- //描画順の作成
61- int _MakeRenderingOrder(
65+ //描画情報の作成
66+ int _MakeRenderingInfo(
6267 D3DXVECTOR3 basePosVector,
68+ D3DXVECTOR3 playbackPosVector,
6369 D3DXVECTOR3 camVector,
64- D3DXVECTOR3 lookVector
70+ D3DXVECTOR3 lookVector,
71+ float rollAngle
6572 );
6673
67- //逆順インデックスの生成
68- int _CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice);
74+ //描画インデックスの生成
75+ int _CreateRenderingIndex(LPDIRECT3DDEVICE9 pD3DDevice);
6976
70- //キー単位の逆順インデックスの生成
71- int _CreateRevIndexOfKey(
77+ //キー単位の描画インデックスの生成
78+ int _CreateRenderingIndexOfKey(
7279 unsigned char noteNo,
80+ int bufferIdx,
7381 unsigned long* pIndex,
74- unsigned long* pRevIndex
82+ unsigned long* pRenderingIndex
7583 );
7684
77- //逆順インデックスバッファの生成
78- int _CreateRevIndexBuffer(LPDIRECT3DDEVICE9 pD3DDevice, unsigned long indexNum);
85+ //描画インデックスバッファの生成
86+ int _CreateRenderingIndexBuffer(
87+ LPDIRECT3DDEVICE9 pD3DDevice,
88+ int bufferIdx,
89+ unsigned long indexNum
90+ );
7991
80- //逆順インデックスバッファのロック制御
81- int _LockRevIndex(unsigned long** pPtrIndex, unsigned long offset = 0, unsigned long size = 0);
82- int _UnlockRevIndex();
92+ //描画インデックスバッファのロック制御
93+ int _LockRenderingIndex(
94+ unsigned long** pPtrIndex,
95+ int bufferIdx,
96+ unsigned long offset = 0,
97+ unsigned long size = 0
98+ );
99+ int _UnlockRenderingIndex(
100+ int bufferIdx
101+ );
83102
84103 virtual int _CreateVertexOfKeyWhite1(
85104 unsigned char noteNo,
@@ -111,15 +130,16 @@ private:
111130 //キーボードデザイン
112131 MTPianoKeyboardDesignMod m_KeyboardDesignMod;
113132
114- //逆順インデックス情報
115- LPDIRECT3DINDEXBUFFER9 m_pRevIndexBuffer;
116- unsigned long m_RevIndexNum;
117- bool m_IsRevIndexLocked;
133+ //描画インデックス情報
134+ LPDIRECT3DINDEXBUFFER9 m_pRenderingIndexBuffer[ MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX ];
135+ unsigned long m_RenderingIndexNum[ MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX ];
136+ bool m_IsRenderingIndexLocked[ MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX ];
118137
119- //キーボード描画範囲
138+ //キーボード描画情報
120139 int m_noteNoLow;
121140 int m_noteNoHigh;
122- int m_camDir;
141+ int m_camDirLR;
142+ int m_camPosIdx;
123143 };
124144
125145