MIDITrail をピカピカにする。鍵盤方向自動切替・多ポート・歌詞対応等
Revision | 18964f21d8843c781d3882f3e5ca2b22160c2fd0 (tree) |
---|---|
Zeit | 2019-08-28 07:06:19 |
Autor | yoshy <yoshy@user...> |
Commiter | yoshy |
[WORKING] 20190310_1218
@@ -22,6 +22,10 @@ | ||
22 | 22 | |
23 | 23 | using namespace SMIDILib; |
24 | 24 | |
25 | +//****************************************************************************** | |
26 | +// パラメータ定義 | |
27 | +//****************************************************************************** | |
28 | +#define MTPIANOKEYBOARD_KEY_PLANE_MAX (10) | |
25 | 29 | |
26 | 30 | //****************************************************************************** |
27 | 31 | // ピアノキーボード描画クラス |
@@ -102,6 +106,16 @@ protected: | ||
102 | 106 | D3DXVECTOR2 t; //テクスチャ画像位置 |
103 | 107 | }; |
104 | 108 | |
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 | + | |
105 | 119 | //バッファ情報 |
106 | 120 | typedef struct { |
107 | 121 | unsigned long vertexPos; |
@@ -113,6 +127,11 @@ protected: | ||
113 | 127 | unsigned long revIndexPos; |
114 | 128 | unsigned long revIndexTotal; |
115 | 129 | // <<< 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 | |
116 | 135 | } MTBufInfo; |
117 | 136 | |
118 | 137 | // >>> modify access level to protected 20161224 yossiepon begin |
@@ -18,20 +18,22 @@ using namespace YNBaseLib; | ||
18 | 18 | //****************************************************************************** |
19 | 19 | // パラメータ定義 |
20 | 20 | //****************************************************************************** |
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) | |
35 | 37 | |
36 | 38 | //****************************************************************************** |
37 | 39 | // コンストラクタ |
@@ -39,13 +41,17 @@ using namespace YNBaseLib; | ||
39 | 41 | MTPianoKeyboardMod::MTPianoKeyboardMod(void) |
40 | 42 | { |
41 | 43 | //逆順インデックス情報 |
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 | + } | |
45 | 49 | |
46 | 50 | //キーボード描画範囲 |
47 | 51 | m_noteNoLow = -1; |
48 | 52 | m_noteNoHigh = -1; |
53 | + m_camDirLR = 0; | |
54 | + m_camPosIdx = 2; | |
49 | 55 | } |
50 | 56 | |
51 | 57 | //****************************************************************************** |
@@ -76,8 +82,8 @@ int MTPianoKeyboardMod::Create( | ||
76 | 82 | result = m_KeyboardDesignMod.Initialize(pSceneName, pSeqData); |
77 | 83 | if (result != 0) goto EXIT; |
78 | 84 | |
79 | - //逆順インデックス生成 | |
80 | - _CreateRevIndex(pD3DDevice); | |
85 | + //描画インデックス生成 | |
86 | + _CreateRenderingIndex(pD3DDevice); | |
81 | 87 | |
82 | 88 | EXIT:; |
83 | 89 | return result; |
@@ -107,29 +113,29 @@ int MTPianoKeyboardMod::Draw( | ||
107 | 113 | pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); |
108 | 114 | |
109 | 115 | //視線方向による描画順の変更 |
110 | - if (m_camDir == -1) { | |
111 | - //正順側キーボードの描画 | |
116 | + if (m_camDirLR == -1) { | |
117 | + //低音側キーボードの描画 | |
112 | 118 | 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); | |
114 | 120 | if (result != 0) goto EXIT; |
115 | 121 | } |
116 | 122 | |
117 | - //逆順側キーボードの描画 | |
123 | + //高音側キーボードの描画 | |
118 | 124 | 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); | |
120 | 126 | if (result != 0) goto EXIT; |
121 | 127 | } |
122 | 128 | } |
123 | 129 | else { |
124 | - //逆順側キーボードの描画 | |
130 | + //高音側キーボードの描画 | |
125 | 131 | 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); | |
127 | 133 | if (result != 0) goto EXIT; |
128 | 134 | } |
129 | 135 | |
130 | - //正順側キーボードの描画 | |
136 | + //低音側キーボードの描画 | |
131 | 137 | 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); | |
133 | 139 | if (result != 0) goto EXIT; |
134 | 140 | } |
135 | 141 | } |
@@ -202,8 +208,8 @@ int MTPianoKeyboardMod::Transform( | ||
202 | 208 | //変換行列設定 |
203 | 209 | m_PrimitiveKeyboard.Transform(worldMatrix); |
204 | 210 | |
205 | - //キーボード描画順の生成 | |
206 | - _MakeRenderingOrder(basePosVector, camVector, lookVector); | |
211 | + //キーボード描画情報の生成 | |
212 | + _MakeRenderingInfo(basePosVector, playbackPosVector, camVector, lookVector, rollAngle); | |
207 | 213 | |
208 | 214 | //EXIT:; |
209 | 215 | return result; |
@@ -246,30 +252,32 @@ EXIT:; | ||
246 | 252 | } |
247 | 253 | |
248 | 254 | //****************************************************************************** |
249 | -// 描画順の作成 | |
255 | +// 描画情報の作成 | |
250 | 256 | //****************************************************************************** |
251 | -int MTPianoKeyboardMod::_MakeRenderingOrder( | |
257 | +int MTPianoKeyboardMod::_MakeRenderingInfo( | |
252 | 258 | D3DXVECTOR3 basePosVector, |
259 | + D3DXVECTOR3 playbackPosVector, | |
253 | 260 | D3DXVECTOR3 camVector, |
254 | - D3DXVECTOR3 lookVector | |
261 | + D3DXVECTOR3 lookVector, | |
262 | + float rollAngle | |
255 | 263 | ) |
256 | 264 | { |
257 | 265 | //ピッチベンド幅を含んだキーボード原点 |
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; | |
259 | 270 | |
260 | 271 | //カメラ位置 |
261 | - float camPos = -camVector.z; | |
272 | + float camPosX = camVector.x - playbackPosVector.x; | |
273 | + float camPosY = camVector.y; | |
274 | + float camPosZ = -camVector.z; | |
262 | 275 | |
263 | 276 | //カメラ視線方向 |
264 | 277 | float camDir = -lookVector.z; |
265 | 278 | |
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; | |
273 | 281 | |
274 | 282 | if (m_noteNoLow < 0) { |
275 | 283 | m_noteNoLow = -1; |
@@ -288,15 +296,32 @@ int MTPianoKeyboardMod::_MakeRenderingOrder( | ||
288 | 296 | m_noteNoHigh = -1; |
289 | 297 | } |
290 | 298 | |
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); | |
292 | 317 | |
293 | 318 | return 0; |
294 | 319 | } |
295 | 320 | |
296 | 321 | //****************************************************************************** |
297 | -// 逆順インデックス生成 | |
322 | +// 描画インデックス生成 | |
298 | 323 | //****************************************************************************** |
299 | -int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice) | |
324 | +int MTPianoKeyboardMod::_CreateRenderingIndex(LPDIRECT3DDEVICE9 pD3DDevice) | |
300 | 325 | { |
301 | 326 | int result = 0; |
302 | 327 |
@@ -308,10 +333,6 @@ int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice) | ||
308 | 333 | m_BufInfo[noteNo].indexTotal = indexTotal; |
309 | 334 | } |
310 | 335 | |
311 | - //逆順インデックスバッファ生成 | |
312 | - result = _CreateRevIndexBuffer(pD3DDevice, indexTotal); | |
313 | - if (result != 0) goto EXIT; | |
314 | - | |
315 | 336 | //逆順インデックスのオフセット情報を生成 |
316 | 337 | unsigned long revIndexNum = indexTotal; |
317 | 338 | unsigned long revIndexTotal = 0; |
@@ -327,28 +348,37 @@ int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice) | ||
327 | 348 | } |
328 | 349 | |
329 | 350 | unsigned long* pIndex = NULL; |
330 | - unsigned long* pRevIndex = NULL; | |
331 | 351 | unsigned long size = indexTotal * sizeof(unsigned long); |
332 | 352 | |
333 | 353 | //インデックスバッファのロック |
334 | 354 | result = m_PrimitiveKeyboard.LockIndex(&pIndex, 0, size); |
335 | 355 | if (result != 0) goto EXIT; |
336 | 356 | |
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++) { | |
340 | 359 | |
341 | - ZeroMemory(pRevIndex, size); | |
360 | + result = _CreateRenderingIndexBuffer(pD3DDevice, bufferIdx, indexTotal); | |
361 | + if (result != 0) goto EXIT; | |
342 | 362 | |
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); | |
346 | 367 | if (result != 0) goto EXIT; |
347 | - } | |
348 | 368 | |
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 | + } | |
352 | 382 | |
353 | 383 | //インデックスバッファのロック解除 |
354 | 384 | result = m_PrimitiveKeyboard.UnlockIndex(); |
@@ -359,30 +389,530 @@ EXIT:; | ||
359 | 389 | } |
360 | 390 | |
361 | 391 | //****************************************************************************** |
362 | -// キー単位の逆順インデックス生成 | |
392 | +// キー単位の描画インデックス生成 | |
363 | 393 | //****************************************************************************** |
364 | -int MTPianoKeyboardMod::_CreateRevIndexOfKey( | |
394 | +int MTPianoKeyboardMod::_CreateRenderingIndexOfKey( | |
365 | 395 | unsigned char noteNo, |
396 | + int bufferIdx, | |
366 | 397 | unsigned long* pIndex, |
367 | - unsigned long* pRevIndex | |
398 | + unsigned long* pRenderingIndex | |
368 | 399 | ) |
369 | 400 | { |
370 | 401 | int result = 0; |
371 | 402 | |
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 | + | |
372 | 866 | 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; | |
374 | 869 | unsigned long size = m_BufInfo[noteNo].indexNum; |
375 | 870 | |
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 | + } | |
377 | 905 | |
906 | +EXIT: | |
378 | 907 | return result; |
379 | 908 | } |
380 | 909 | |
381 | 910 | //****************************************************************************** |
382 | -// 逆順インデックスバッファ生成 | |
911 | +// 描画インデックスバッファ生成 | |
383 | 912 | //****************************************************************************** |
384 | -int MTPianoKeyboardMod::_CreateRevIndexBuffer( | |
913 | +int MTPianoKeyboardMod::_CreateRenderingIndexBuffer( | |
385 | 914 | LPDIRECT3DDEVICE9 pD3DDevice, |
915 | + int bufferIdx, | |
386 | 916 | unsigned long indexNum |
387 | 917 | ) |
388 | 918 | { |
@@ -393,7 +923,13 @@ int MTPianoKeyboardMod::_CreateRevIndexBuffer( | ||
393 | 923 | result = YN_SET_ERR("Program error.", 0, 0); |
394 | 924 | goto EXIT; |
395 | 925 | } |
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) { | |
397 | 933 | result = YN_SET_ERR("Program error.", 0, 0); |
398 | 934 | goto EXIT; |
399 | 935 | } |
@@ -401,13 +937,12 @@ int MTPianoKeyboardMod::_CreateRevIndexBuffer( | ||
401 | 937 | //インデックスバッファ生成 |
402 | 938 | if (indexNum > 0) { |
403 | 939 | 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 //予約パラメータ | |
411 | 946 | ); |
412 | 947 | if (FAILED(hresult)) { |
413 | 948 | result = YN_SET_ERR("DirectX API error.", hresult, indexNum); |
@@ -415,17 +950,18 @@ int MTPianoKeyboardMod::_CreateRevIndexBuffer( | ||
415 | 950 | } |
416 | 951 | } |
417 | 952 | |
418 | - m_RevIndexNum = indexNum; | |
953 | + m_RenderingIndexNum[bufferIdx] = indexNum; | |
419 | 954 | |
420 | 955 | EXIT:; |
421 | 956 | return result; |
422 | 957 | } |
423 | 958 | |
424 | 959 | //****************************************************************************** |
425 | -// 逆順インデックスバッファロック | |
960 | +// 描画インデックスバッファロック | |
426 | 961 | //****************************************************************************** |
427 | -int MTPianoKeyboardMod::_LockRevIndex( | |
962 | +int MTPianoKeyboardMod::_LockRenderingIndex( | |
428 | 963 | unsigned long** pPtrIndex, |
964 | + int bufferIdx, | |
429 | 965 | unsigned long offset, //省略時はゼロ |
430 | 966 | unsigned long size //省略時はゼロ |
431 | 967 | ) |
@@ -433,19 +969,24 @@ int MTPianoKeyboardMod::_LockRevIndex( | ||
433 | 969 | int result = 0; |
434 | 970 | HRESULT hresult = D3D_OK; |
435 | 971 | |
436 | - if (m_IsRevIndexLocked) { | |
972 | + if ((bufferIdx < 0) || (bufferIdx >= MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX)) { | |
437 | 973 | result = YN_SET_ERR("Program error.", 0, 0); |
438 | 974 | goto EXIT; |
439 | 975 | } |
440 | 976 | |
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)) { | |
442 | 983 | result = YN_SET_ERR("Program error.", offset, size); |
443 | 984 | goto EXIT; |
444 | 985 | } |
445 | 986 | |
446 | 987 | //インデックスバッファのロックとバッファメモリポインタ取得 |
447 | - if (m_pRevIndexBuffer != NULL) { | |
448 | - hresult = m_pRevIndexBuffer->Lock( | |
988 | + if (m_pRenderingIndexBuffer[bufferIdx] != NULL) { | |
989 | + hresult = m_pRenderingIndexBuffer[bufferIdx]->Lock( | |
449 | 990 | offset, //ロックするインデックスのオフセット(byte) |
450 | 991 | size, //ロックするインデックスのサイズ(byte) |
451 | 992 | (void**)pPtrIndex, //バッファメモリポインタ |
@@ -457,29 +998,31 @@ int MTPianoKeyboardMod::_LockRevIndex( | ||
457 | 998 | } |
458 | 999 | } |
459 | 1000 | |
460 | - m_IsRevIndexLocked = true; | |
1001 | + m_IsRenderingIndexLocked[bufferIdx] = true; | |
461 | 1002 | |
462 | 1003 | EXIT:; |
463 | 1004 | return result; |
464 | 1005 | } |
465 | 1006 | |
466 | 1007 | //****************************************************************************** |
467 | -// 逆順インデックスバッファロック解除 | |
1008 | +// 描画インデックスバッファロック解除 | |
468 | 1009 | //****************************************************************************** |
469 | -int MTPianoKeyboardMod::_UnlockRevIndex() | |
1010 | +int MTPianoKeyboardMod::_UnlockRenderingIndex( | |
1011 | + int bufferIdx | |
1012 | + ) | |
470 | 1013 | { |
471 | 1014 | int result = 0; |
472 | 1015 | HRESULT hresult = D3D_OK; |
473 | 1016 | |
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(); | |
477 | 1020 | if (FAILED(hresult)) { |
478 | 1021 | result = YN_SET_ERR("DirectX API error.", hresult, 0); |
479 | 1022 | goto EXIT; |
480 | 1023 | } |
481 | 1024 | } |
482 | - m_IsRevIndexLocked = false; | |
1025 | + m_IsRenderingIndexLocked[bufferIdx] = false; | |
483 | 1026 | } |
484 | 1027 | |
485 | 1028 | EXIT:; |
@@ -504,30 +1047,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
504 | 1047 | pColor |
505 | 1048 | ); |
506 | 1049 | |
507 | - // 描画順の修正 | |
1050 | + //キー種別 | |
1051 | + m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyWhite1; | |
1052 | + | |
1053 | + //描画順の再生成 | |
508 | 1054 | int idx = 0; |
509 | 1055 | |
510 | 1056 | //---------------------------------------------------------------- |
511 | - //下の面 | |
1057 | + //上の面 | |
512 | 1058 | //---------------------------------------------------------------- |
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 | |
524 | 1070 | |
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 }; | |
527 | 1075 | 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]; | |
529 | 1077 | } |
530 | 1078 | |
1079 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long); | |
1080 | + | |
531 | 1081 | //---------------------------------------------------------------- |
532 | 1082 | //側面 0-1 |
533 | 1083 | //---------------------------------------------------------------- |
@@ -536,12 +1086,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
536 | 1086 | // | | |
537 | 1087 | // 9+----+10 |
538 | 1088 | |
1089 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx; | |
1090 | + | |
539 | 1091 | //インデックス |
540 | 1092 | unsigned long index01[] = { 7, 8, 9, 8, 10, 9 }; |
541 | 1093 | for (int i = 0; i < 6; i++) { |
542 | 1094 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i]; |
543 | 1095 | } |
544 | 1096 | |
1097 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long); | |
1098 | + | |
545 | 1099 | //---------------------------------------------------------------- |
546 | 1100 | //側面 1-2 |
547 | 1101 | //---------------------------------------------------------------- |
@@ -550,12 +1104,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
550 | 1104 | // | | |
551 | 1105 | // 1 11+--+13 |
552 | 1106 | |
1107 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_FRONT] = idx; | |
1108 | + | |
553 | 1109 | //インデックス |
554 | 1110 | unsigned long index12[] = { 11, 12, 13, 12, 14, 13 }; |
555 | 1111 | for (int i = 0; i < 6; i++) { |
556 | 1112 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index12[i]; |
557 | 1113 | } |
558 | 1114 | |
1115 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_FRONT] = sizeof(index12) / sizeof(unsigned long); | |
1116 | + | |
559 | 1117 | //---------------------------------------------------------------- |
560 | 1118 | //側面 2-4 |
561 | 1119 | //---------------------------------------------------------------- |
@@ -563,12 +1121,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
563 | 1121 | // | | |
564 | 1122 | // 4 16+--+15 2 |
565 | 1123 | |
1124 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_RIGHT] = idx; | |
1125 | + | |
566 | 1126 | //インデックス |
567 | 1127 | unsigned long index24[] = { 15, 16, 17, 16, 18, 17 }; |
568 | 1128 | for (int i = 0; i < 6; i++) { |
569 | 1129 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index24[i]; |
570 | 1130 | } |
571 | 1131 | |
1132 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_RIGHT] = sizeof(index24) / sizeof(unsigned long); | |
1133 | + | |
572 | 1134 | //---------------------------------------------------------------- |
573 | 1135 | //側面 4-5 |
574 | 1136 | //---------------------------------------------------------------- |
@@ -577,12 +1139,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
577 | 1139 | // | | |
578 | 1140 | // 4 19+--+21 |
579 | 1141 | |
1142 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_BACK] = idx; | |
1143 | + | |
580 | 1144 | //インデックス |
581 | 1145 | unsigned long index45[] = { 19, 20, 21, 20, 22, 21 }; |
582 | 1146 | for (int i = 0; i < 6; i++) { |
583 | 1147 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index45[i]; |
584 | 1148 | } |
585 | 1149 | |
1150 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_BACK] = sizeof(index45) / sizeof(unsigned long); | |
1151 | + | |
586 | 1152 | //---------------------------------------------------------------- |
587 | 1153 | //側面 5-6 |
588 | 1154 | //---------------------------------------------------------------- |
@@ -590,12 +1156,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
590 | 1156 | // | | |
591 | 1157 | // 6 24+--+23 5 |
592 | 1158 | |
1159 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx; | |
1160 | + | |
593 | 1161 | //インデックス |
594 | 1162 | unsigned long index56[] = { 23, 24, 25, 24, 26, 25 }; |
595 | 1163 | for (int i = 0; i < 6; i++) { |
596 | 1164 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i]; |
597 | 1165 | } |
598 | 1166 | |
1167 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index56) / sizeof(unsigned long); | |
1168 | + | |
599 | 1169 | //---------------------------------------------------------------- |
600 | 1170 | //側面 6-0 |
601 | 1171 | //---------------------------------------------------------------- |
@@ -604,33 +1174,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite1( | ||
604 | 1174 | // | | |
605 | 1175 | // 30+--+28 0 |
606 | 1176 | |
1177 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT] = idx; | |
1178 | + | |
607 | 1179 | //インデックス |
608 | 1180 | unsigned long index60[] = { 27, 28, 29, 28, 30, 29 }; |
609 | 1181 | for (int i = 0; i < 6; i++) { |
610 | 1182 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index60[i]; |
611 | 1183 | } |
612 | 1184 | |
1185 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT] = sizeof(index60) / sizeof(unsigned long); | |
1186 | + | |
613 | 1187 | //---------------------------------------------------------------- |
614 | - //上の面 | |
1188 | + //下の面 | |
615 | 1189 | //---------------------------------------------------------------- |
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 | |
627 | 1201 | |
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 }; | |
630 | 1206 | 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]; | |
632 | 1208 | } |
633 | 1209 | |
1210 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long); | |
1211 | + | |
634 | 1212 | return result; |
635 | 1213 | } |
636 | 1214 |
@@ -663,29 +1241,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
663 | 1241 | keyColor = *pColor; |
664 | 1242 | } |
665 | 1243 | |
666 | - // 描画順の修正 | |
1244 | + //キー種別 | |
1245 | + m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyWhite2; | |
1246 | + | |
1247 | + //描画順の再生成 | |
667 | 1248 | int idx = 0; |
668 | 1249 | |
669 | 1250 | //---------------------------------------------------------------- |
670 | - //下の面 | |
1251 | + //上の面 | |
671 | 1252 | //---------------------------------------------------------------- |
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; | |
683 | 1266 | |
684 | 1267 | //インデックス |
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 }; | |
686 | 1269 | 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]; | |
688 | 1271 | } |
1272 | + | |
1273 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long); | |
1274 | + | |
689 | 1275 | //---------------------------------------------------------------- |
690 | 1276 | //側面 0-1 |
691 | 1277 | //---------------------------------------------------------------- |
@@ -694,12 +1280,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
694 | 1280 | // | | |
695 | 1281 | // 10+----+11 |
696 | 1282 | |
1283 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx; | |
1284 | + | |
697 | 1285 | //インデックス |
698 | 1286 | unsigned long index01[] = { 8, 9, 10, 9, 11, 10 }; |
699 | 1287 | for (int i = 0; i < 6; i++) { |
700 | 1288 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i]; |
701 | 1289 | } |
702 | 1290 | |
1291 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long); | |
1292 | + | |
703 | 1293 | //---------------------------------------------------------------- |
704 | 1294 | //側面 1-2 |
705 | 1295 | //---------------------------------------------------------------- |
@@ -708,12 +1298,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
708 | 1298 | // | | |
709 | 1299 | // 1 12+--+14 |
710 | 1300 | |
1301 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_FRONT] = idx; | |
1302 | + | |
711 | 1303 | //インデックス |
712 | 1304 | unsigned long index12[] = { 12, 13, 14, 13, 15, 14 }; |
713 | 1305 | for (int i = 0; i < 6; i++) { |
714 | 1306 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index12[i]; |
715 | 1307 | } |
716 | 1308 | |
1309 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_FRONT] = sizeof(index12) / sizeof(unsigned long); | |
1310 | + | |
717 | 1311 | //---------------------------------------------------------------- |
718 | 1312 | //側面 2-4 |
719 | 1313 | //---------------------------------------------------------------- |
@@ -721,6 +1315,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
721 | 1315 | // | | |
722 | 1316 | // 4 17+--+16 2 |
723 | 1317 | |
1318 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_RIGHT] = idx; | |
1319 | + | |
724 | 1320 | //基底クラスでは2-3で生成しているが、透過すると4-7間が仕切りとして |
725 | 1321 | //見えてしまうため、2-4、7-3に分割する |
726 | 1322 |
@@ -734,6 +1330,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
734 | 1330 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index24[i]; |
735 | 1331 | } |
736 | 1332 | |
1333 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_RIGHT] = sizeof(index24) / sizeof(unsigned long); | |
1334 | + | |
737 | 1335 | //---------------------------------------------------------------- |
738 | 1336 | //側面 4-5 |
739 | 1337 | //---------------------------------------------------------------- |
@@ -742,12 +1340,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
742 | 1340 | // | | |
743 | 1341 | // 4 20+--+22 |
744 | 1342 | |
1343 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT_BACK] = idx; | |
1344 | + | |
745 | 1345 | //インデックス |
746 | 1346 | unsigned long index45[] = { 20, 21, 22, 21, 23, 22 }; |
747 | 1347 | for (int i = 0; i < 6; i++) { |
748 | 1348 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index45[i]; |
749 | 1349 | } |
750 | 1350 | |
1351 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT_BACK] = sizeof(index45) / sizeof(unsigned long); | |
1352 | + | |
751 | 1353 | //---------------------------------------------------------------- |
752 | 1354 | //側面 5-6 |
753 | 1355 | //---------------------------------------------------------------- |
@@ -755,12 +1357,15 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
755 | 1357 | // | | |
756 | 1358 | // 6 25+--+24 5 |
757 | 1359 | |
1360 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx; | |
1361 | + | |
758 | 1362 | //インデックス |
759 | 1363 | unsigned long index56[] = { 24, 25, 26, 25, 27, 26 }; |
760 | 1364 | for (int i = 0; i < 6; i++) { |
761 | 1365 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i]; |
762 | 1366 | } |
763 | 1367 | |
1368 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index56) / sizeof(unsigned long); | |
764 | 1369 | |
765 | 1370 | //---------------------------------------------------------------- |
766 | 1371 | //側面 6-7 |
@@ -770,12 +1375,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
770 | 1375 | // | | |
771 | 1376 | // 31+--+29 7 |
772 | 1377 | |
1378 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_BACK] = idx; | |
1379 | + | |
773 | 1380 | //インデックス |
774 | 1381 | unsigned long index67[] = { 28, 29, 30, 29, 31, 30 }; |
775 | 1382 | for (int i = 0; i < 6; i++) { |
776 | 1383 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index67[i]; |
777 | 1384 | } |
778 | 1385 | |
1386 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_BACK] = sizeof(index67) / sizeof(unsigned long); | |
1387 | + | |
779 | 1388 | //---------------------------------------------------------------- |
780 | 1389 | //側面 7-3 |
781 | 1390 | //---------------------------------------------------------------- |
@@ -783,6 +1392,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
783 | 1392 | // | | |
784 | 1393 | // 3 45+--+44 7 |
785 | 1394 | |
1395 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_LEFT] = idx; | |
1396 | + | |
786 | 1397 | //頂点 |
787 | 1398 | pVertex[44].p = pVertex[7].p; |
788 | 1399 | pVertex[45].p = pVertex[3].p; |
@@ -801,6 +1412,8 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
801 | 1412 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index73[i]; |
802 | 1413 | } |
803 | 1414 | |
1415 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_LEFT] = sizeof(index73) / sizeof(unsigned long); | |
1416 | + | |
804 | 1417 | //単一色のテクスチャ座標 |
805 | 1418 | m_KeyboardDesign.GetWhiteKeyTexturePosSingleColor(noteNo, &tsc); |
806 | 1419 | for (int i = 44; i < 48; i++) { |
@@ -815,33 +1428,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite2( | ||
815 | 1428 | // | | |
816 | 1429 | // 35+--+33 0 |
817 | 1430 | |
1431 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_FRONT] = idx; | |
1432 | + | |
818 | 1433 | //インデックス |
819 | 1434 | unsigned long index30[] = { 32, 33, 34, 33, 35, 34 }; |
820 | 1435 | for (int i = 0; i < 6; i++) { |
821 | 1436 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index30[i]; |
822 | 1437 | } |
823 | 1438 | |
1439 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_FRONT] = sizeof(index30) / sizeof(unsigned long); | |
1440 | + | |
824 | 1441 | //---------------------------------------------------------------- |
825 | - //上の面 | |
1442 | + //下の面 | |
826 | 1443 | //---------------------------------------------------------------- |
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; | |
838 | 1457 | |
839 | 1458 | //インデックス |
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 }; | |
841 | 1460 | 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]; | |
843 | 1462 | } |
844 | 1463 | |
1464 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long); | |
1465 | + | |
845 | 1466 | return result; |
846 | 1467 | } |
847 | 1468 |
@@ -863,30 +1484,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
863 | 1484 | pColor |
864 | 1485 | ); |
865 | 1486 | |
866 | - // 描画順の修正 | |
1487 | + //キー種別 | |
1488 | + m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyWhite3; | |
1489 | + | |
1490 | + //描画順の再生成 | |
867 | 1491 | int idx = 0; |
868 | 1492 | |
869 | 1493 | //---------------------------------------------------------------- |
870 | - //下の面 | |
1494 | + //上の面 | |
871 | 1495 | //---------------------------------------------------------------- |
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; | |
883 | 1509 | |
884 | 1510 | //インデックス |
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 }; | |
886 | 1512 | 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]; | |
888 | 1514 | } |
889 | 1515 | |
1516 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long); | |
1517 | + | |
890 | 1518 | //---------------------------------------------------------------- |
891 | 1519 | //側面 0-1 |
892 | 1520 | //---------------------------------------------------------------- |
@@ -895,12 +1523,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
895 | 1523 | // | | |
896 | 1524 | // 9+----+10 |
897 | 1525 | |
1526 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx; | |
1527 | + | |
898 | 1528 | //インデックス |
899 | 1529 | unsigned long index01[] = { 7, 8, 9, 8, 10, 9 }; |
900 | 1530 | for (int i = 0; i < 6; i++) { |
901 | 1531 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i]; |
902 | 1532 | } |
903 | 1533 | |
1534 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long); | |
1535 | + | |
904 | 1536 | //---------------------------------------------------------------- |
905 | 1537 | //側面 1-4 |
906 | 1538 | //---------------------------------------------------------------- |
@@ -909,12 +1541,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
909 | 1541 | // | | |
910 | 1542 | // 1 11+--+13 |
911 | 1543 | |
1544 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT] = idx; | |
1545 | + | |
912 | 1546 | //インデックス |
913 | 1547 | unsigned long index14[] = { 11, 12, 13, 12, 14, 13 }; |
914 | 1548 | for (int i = 0; i < 6; i++) { |
915 | 1549 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index14[i]; |
916 | 1550 | } |
917 | 1551 | |
1552 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT] = sizeof(index14) / sizeof(unsigned long); | |
1553 | + | |
918 | 1554 | //---------------------------------------------------------------- |
919 | 1555 | //側面 4-5 |
920 | 1556 | //---------------------------------------------------------------- |
@@ -922,12 +1558,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
922 | 1558 | // | | |
923 | 1559 | // 5 16+--+15 4 |
924 | 1560 | |
1561 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx; | |
1562 | + | |
925 | 1563 | //インデックス |
926 | 1564 | unsigned long index45[] = { 15, 16, 17, 16, 18, 17 }; |
927 | 1565 | for (int i = 0; i < 6; i++) { |
928 | 1566 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index45[i]; |
929 | 1567 | } |
930 | 1568 | |
1569 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index45) / sizeof(unsigned long); | |
1570 | + | |
931 | 1571 | //---------------------------------------------------------------- |
932 | 1572 | //側面 5-6 |
933 | 1573 | //---------------------------------------------------------------- |
@@ -936,12 +1576,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
936 | 1576 | // | | |
937 | 1577 | // 22+--+20 6 |
938 | 1578 | |
1579 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_BACK] = idx; | |
1580 | + | |
939 | 1581 | //インデックス |
940 | 1582 | unsigned long index56[] = { 19, 20, 21, 20, 22, 21 }; |
941 | 1583 | for (int i = 0; i < 6; i++) { |
942 | 1584 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i]; |
943 | 1585 | } |
944 | 1586 | |
1587 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_BACK] = sizeof(index56) / sizeof(unsigned long); | |
1588 | + | |
945 | 1589 | //---------------------------------------------------------------- |
946 | 1590 | //側面 6-3 |
947 | 1591 | //---------------------------------------------------------------- |
@@ -949,12 +1593,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
949 | 1593 | // | | |
950 | 1594 | // 3 24+--+23 6 |
951 | 1595 | |
1596 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_MIDDLE_LEFT] = idx; | |
1597 | + | |
952 | 1598 | //インデックス |
953 | 1599 | unsigned long index63[] = { 23, 24, 25, 24, 26, 25 }; |
954 | 1600 | for (int i = 0; i < 6; i++) { |
955 | 1601 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index63[i]; |
956 | 1602 | } |
957 | 1603 | |
1604 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_MIDDLE_LEFT] = sizeof(index63) / sizeof(unsigned long); | |
1605 | + | |
958 | 1606 | //---------------------------------------------------------------- |
959 | 1607 | //側面 3-0 |
960 | 1608 | //---------------------------------------------------------------- |
@@ -963,33 +1611,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyWhite3( | ||
963 | 1611 | // | | |
964 | 1612 | // 30+--+28 0 |
965 | 1613 | |
1614 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT_FRONT] = idx; | |
1615 | + | |
966 | 1616 | //インデックス |
967 | 1617 | unsigned long index30[] = { 27, 28, 29, 28, 30, 29 }; |
968 | 1618 | for (int i = 0; i < 6; i++) { |
969 | 1619 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index30[i]; |
970 | 1620 | } |
971 | 1621 | |
1622 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT_FRONT] = sizeof(index30) / sizeof(unsigned long); | |
1623 | + | |
972 | 1624 | //---------------------------------------------------------------- |
973 | - //上の面 | |
1625 | + //下の面 | |
974 | 1626 | //---------------------------------------------------------------- |
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; | |
986 | 1640 | |
987 | 1641 | //インデックス |
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 }; | |
989 | 1643 | 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]; | |
991 | 1645 | } |
992 | 1646 | |
1647 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long); | |
1648 | + | |
993 | 1649 | return result; |
994 | 1650 | } |
995 | 1651 |
@@ -1011,30 +1667,37 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack( | ||
1011 | 1667 | pColor |
1012 | 1668 | ); |
1013 | 1669 | |
1014 | - // 描画順の修正 | |
1670 | + //キー種別 | |
1671 | + m_BufInfo[noteNo].keyType = MTPianoKeyboardMod::KeyBlack; | |
1672 | + | |
1673 | + //描画順の修正 | |
1015 | 1674 | int idx = 0; |
1016 | 1675 | |
1017 | 1676 | //---------------------------------------------------------------- |
1018 | - //下の面 | |
1677 | + //上の面 | |
1019 | 1678 | //---------------------------------------------------------------- |
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; | |
1031 | 1692 | |
1032 | 1693 | //インデックス |
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]; | |
1036 | 1697 | } |
1037 | 1698 | |
1699 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_UP] = sizeof(indexUP) / sizeof(unsigned long); | |
1700 | + | |
1038 | 1701 | //---------------------------------------------------------------- |
1039 | 1702 | //側面 0-1 |
1040 | 1703 | //---------------------------------------------------------------- |
@@ -1043,12 +1706,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack( | ||
1043 | 1706 | // | | |
1044 | 1707 | // 10+----+11 |
1045 | 1708 | |
1709 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_FRONT] = idx; | |
1710 | + | |
1046 | 1711 | //インデックス |
1047 | 1712 | unsigned long index01[] = { 8, 9, 10, 9, 11, 10 }; |
1048 | 1713 | for (int i = 0; i < 6; i++) { |
1049 | 1714 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index01[i]; |
1050 | 1715 | } |
1051 | 1716 | |
1717 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_FRONT] = sizeof(index01) / sizeof(unsigned long); | |
1718 | + | |
1052 | 1719 | //---------------------------------------------------------------- |
1053 | 1720 | //側面 1-2-5 |
1054 | 1721 | //---------------------------------------------------------------- |
@@ -1059,12 +1726,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack( | ||
1059 | 1726 | // \ | |
1060 | 1727 | // 1 12 +-+15 |
1061 | 1728 | |
1729 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_RIGHT] = idx; | |
1730 | + | |
1062 | 1731 | //インデックス |
1063 | 1732 | unsigned long index125[] = { 12, 13, 15, 13, 16, 15, 13, 14, 16 }; |
1064 | 1733 | for (int i = 0; i < 9; i++) { |
1065 | 1734 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index125[i]; |
1066 | 1735 | } |
1067 | 1736 | |
1737 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_RIGHT] = sizeof(index125) / sizeof(unsigned long); | |
1738 | + | |
1068 | 1739 | //---------------------------------------------------------------- |
1069 | 1740 | //側面 5-6 |
1070 | 1741 | //---------------------------------------------------------------- |
@@ -1072,12 +1743,16 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack( | ||
1072 | 1743 | // | | |
1073 | 1744 | // 6 18+--+17 5 |
1074 | 1745 | |
1746 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_BACK] = idx; | |
1747 | + | |
1075 | 1748 | //インデックス |
1076 | 1749 | unsigned long index56[] = { 17, 18, 19, 18, 20, 19 }; |
1077 | 1750 | for (int i = 0; i < 6; i++) { |
1078 | 1751 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index56[i]; |
1079 | 1752 | } |
1080 | 1753 | |
1754 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_BACK] = sizeof(index56) / sizeof(unsigned long); | |
1755 | + | |
1081 | 1756 | //---------------------------------------------------------------- |
1082 | 1757 | //側面 6-3-0 |
1083 | 1758 | //---------------------------------------------------------------- |
@@ -1088,33 +1763,41 @@ int MTPianoKeyboardMod::_CreateVertexOfKeyBlack( | ||
1088 | 1763 | // | / |
1089 | 1764 | // 25+-+23 0 |
1090 | 1765 | |
1766 | + m_BufInfo[noteNo].planeIndexPos[PLANE_INDEX_LEFT] = idx; | |
1767 | + | |
1091 | 1768 | //インデックス |
1092 | 1769 | unsigned long index630[] = { 21, 22, 24, 22, 25, 24, 22, 23, 25 }; |
1093 | 1770 | for (int i = 0; i < 9; i++) { |
1094 | 1771 | pIndex[idx++] = m_BufInfo[noteNo].vertexPos + index630[i]; |
1095 | 1772 | } |
1096 | 1773 | |
1774 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_LEFT] = sizeof(index630) / sizeof(unsigned long); | |
1775 | + | |
1097 | 1776 | //---------------------------------------------------------------- |
1098 | - //上の面 | |
1777 | + //下の面 | |
1099 | 1778 | //---------------------------------------------------------------- |
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; | |
1111 | 1792 | |
1112 | 1793 | //インデックス |
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]; | |
1116 | 1797 | } |
1117 | 1798 | |
1799 | + m_BufInfo[noteNo].planeIndexNum[PLANE_INDEX_DOWN] = sizeof(indexDW) / sizeof(unsigned long); | |
1800 | + | |
1118 | 1801 | return result; |
1119 | 1802 | } |
1120 | 1803 |
@@ -15,6 +15,11 @@ | ||
15 | 15 | |
16 | 16 | |
17 | 17 | //****************************************************************************** |
18 | +// パラメータ定義 | |
19 | +//****************************************************************************** | |
20 | +#define MTPIANOKEYBOARDMOD_INDEX_BUFFER_MAX (12) | |
21 | + | |
22 | +//****************************************************************************** | |
18 | 23 | // ピアノキーボード描画Modクラス |
19 | 24 | //****************************************************************************** |
20 | 25 | class MTPianoKeyboardMod : public MTPianoKeyboard |
@@ -57,29 +62,43 @@ public: | ||
57 | 62 | |
58 | 63 | private: |
59 | 64 | |
60 | - //描画順の作成 | |
61 | - int _MakeRenderingOrder( | |
65 | + //描画情報の作成 | |
66 | + int _MakeRenderingInfo( | |
62 | 67 | D3DXVECTOR3 basePosVector, |
68 | + D3DXVECTOR3 playbackPosVector, | |
63 | 69 | D3DXVECTOR3 camVector, |
64 | - D3DXVECTOR3 lookVector | |
70 | + D3DXVECTOR3 lookVector, | |
71 | + float rollAngle | |
65 | 72 | ); |
66 | 73 | |
67 | - //逆順インデックスの生成 | |
68 | - int _CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice); | |
74 | + //描画インデックスの生成 | |
75 | + int _CreateRenderingIndex(LPDIRECT3DDEVICE9 pD3DDevice); | |
69 | 76 | |
70 | - //キー単位の逆順インデックスの生成 | |
71 | - int _CreateRevIndexOfKey( | |
77 | + //キー単位の描画インデックスの生成 | |
78 | + int _CreateRenderingIndexOfKey( | |
72 | 79 | unsigned char noteNo, |
80 | + int bufferIdx, | |
73 | 81 | unsigned long* pIndex, |
74 | - unsigned long* pRevIndex | |
82 | + unsigned long* pRenderingIndex | |
75 | 83 | ); |
76 | 84 | |
77 | - //逆順インデックスバッファの生成 | |
78 | - int _CreateRevIndexBuffer(LPDIRECT3DDEVICE9 pD3DDevice, unsigned long indexNum); | |
85 | + //描画インデックスバッファの生成 | |
86 | + int _CreateRenderingIndexBuffer( | |
87 | + LPDIRECT3DDEVICE9 pD3DDevice, | |
88 | + int bufferIdx, | |
89 | + unsigned long indexNum | |
90 | + ); | |
79 | 91 | |
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 | + ); | |
83 | 102 | |
84 | 103 | virtual int _CreateVertexOfKeyWhite1( |
85 | 104 | unsigned char noteNo, |
@@ -111,15 +130,16 @@ private: | ||
111 | 130 | //キーボードデザイン |
112 | 131 | MTPianoKeyboardDesignMod m_KeyboardDesignMod; |
113 | 132 | |
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 ]; | |
118 | 137 | |
119 | - //キーボード描画範囲 | |
138 | + //キーボード描画情報 | |
120 | 139 | int m_noteNoLow; |
121 | 140 | int m_noteNoHigh; |
122 | - int m_camDir; | |
141 | + int m_camDirLR; | |
142 | + int m_camPosIdx; | |
123 | 143 | }; |
124 | 144 | |
125 | 145 |