• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Revisiónf1bebbec186165b6cd1acfc45d3c4f7fcc7f34ba (tree)
Tiempo2019-08-28 07:06:19
Autoryoshy <yoshy@user...>
Commiteryoshy

Log Message

[UPDATE] カメラ位置によるキーボード描画順の変更を実装

Cambiar Resumen

Diferencia incremental

--- a/MIDITrail/MTPianoKeyboard.cpp
+++ b/MIDITrail/MTPianoKeyboard.cpp
@@ -1611,6 +1611,8 @@ int MTPianoKeyboard::Transform(
16111611 LPDIRECT3DDEVICE9 pD3DDevice,
16121612 D3DXVECTOR3 basePosVector,
16131613 D3DXVECTOR3 playbackPosVector,
1614+ D3DXVECTOR3 camVector,
1615+ D3DXVECTOR3 lookVector,
16141616 float rollAngle
16151617 )
16161618 {
--- a/MIDITrail/MTPianoKeyboard.h
+++ b/MIDITrail/MTPianoKeyboard.h
@@ -47,14 +47,16 @@ public:
4747 //更新
4848 int Transform(LPDIRECT3DDEVICE9 pD3DDevice, D3DXVECTOR3 moveVector, float rollAngle);
4949 // >>> add 20120729 yossiepon begin
50-// >>> modify 20180411 yossiepon begin
50+// >>> modify 20180414 yossiepon begin
5151 virtual int Transform(
5252 LPDIRECT3DDEVICE9 pD3DDevice,
5353 D3DXVECTOR3 basePosVector,
5454 D3DXVECTOR3 playbackPosVector,
55+ D3DXVECTOR3 camVector,
56+ D3DXVECTOR3 lookVector,
5557 float rollAngle
5658 );
57-// <<< modify 20180411 yossiepon end
59+// <<< modify 20180414 yossiepon end
5860 // <<< add 20120729 yossiepon end
5961
6062 // >>> modify function decl to virtual 20180412 yossiepon begin
--- a/MIDITrail/MTPianoKeyboardCtrlMod.cpp
+++ b/MIDITrail/MTPianoKeyboardCtrlMod.cpp
@@ -139,6 +139,7 @@ EXIT:;
139139 int MTPianoKeyboardCtrlMod::Transform(
140140 LPDIRECT3DDEVICE9 pD3DDevice,
141141 D3DXVECTOR3 camVector,
142+ D3DXVECTOR3 lookVector,
142143 float rollAngle
143144 )
144145 {
@@ -171,7 +172,7 @@ int MTPianoKeyboardCtrlMod::Transform(
171172 basePosVector.x += _GetMaxPitchBendShift(index);
172173
173174 //キーボード移動
174- result = m_pPianoKeyboard[index]->Transform(pD3DDevice, basePosVector, playbackPosVector, rollAngle);
175+ result = m_pPianoKeyboard[index]->Transform(pD3DDevice, basePosVector, playbackPosVector, camVector, lookVector, rollAngle);
175176 if (result != 0) goto EXIT;
176177 }
177178
--- a/MIDITrail/MTPianoKeyboardCtrlMod.h
+++ b/MIDITrail/MTPianoKeyboardCtrlMod.h
@@ -39,6 +39,7 @@ public:
3939 int Transform(
4040 LPDIRECT3DDEVICE9 pD3DDevice,
4141 D3DXVECTOR3 camVector,
42+ D3DXVECTOR3 lookVector,
4243 float rollAngle
4344 );
4445
--- a/MIDITrail/MTPianoKeyboardMod.cpp
+++ b/MIDITrail/MTPianoKeyboardMod.cpp
@@ -42,6 +42,10 @@ MTPianoKeyboardMod::MTPianoKeyboardMod(void)
4242 m_pRevIndexBuffer = NULL;
4343 m_RevIndexNum = 0;
4444 m_IsRevIndexLocked = false;
45+
46+ //キーボード描画範囲
47+ m_noteNoLow = -1;
48+ m_noteNoHigh = -1;
4549 }
4650
4751 //******************************************************************************
@@ -103,12 +107,16 @@ int MTPianoKeyboardMod::Draw(
103107 pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
104108
105109 //正順側キーボードの描画
106- result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pTexture, m_BufInfo[63].indexTotal / 3);
107- if (result != 0) goto EXIT;
110+ if (m_noteNoLow != -1) {
111+ result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3);
112+ if (result != 0) goto EXIT;
113+ }
108114
109115 //逆順側キーボードの描画
110- result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRevIndexBuffer, m_pTexture, m_BufInfo[64].revIndexTotal / 3);
111- if (result != 0) goto EXIT;
116+ if (m_noteNoHigh != -1) {
117+ result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRevIndexBuffer, m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3);
118+ if (result != 0) goto EXIT;
119+ }
112120
113121 EXIT:;
114122 return result;
@@ -121,6 +129,8 @@ int MTPianoKeyboardMod::Transform(
121129 LPDIRECT3DDEVICE9 pD3DDevice,
122130 D3DXVECTOR3 basePosVector,
123131 D3DXVECTOR3 playbackPosVector,
132+ D3DXVECTOR3 camVector,
133+ D3DXVECTOR3 lookVector,
124134 float rollAngle
125135 )
126136 {
@@ -176,6 +186,9 @@ int MTPianoKeyboardMod::Transform(
176186 //変換行列設定
177187 m_PrimitiveKeyboard.Transform(worldMatrix);
178188
189+ //キーボード描画順の生成
190+ _MakeRenderingOrder(basePosVector, camVector, lookVector);
191+
179192 //EXIT:;
180193 return result;
181194 }
@@ -217,6 +230,46 @@ EXIT:;
217230 }
218231
219232 //******************************************************************************
233+// 描画順の作成
234+//******************************************************************************
235+int MTPianoKeyboardMod::_MakeRenderingOrder(
236+ D3DXVECTOR3 basePosVector,
237+ D3DXVECTOR3 camVector,
238+ D3DXVECTOR3 lookVector
239+ )
240+{
241+ float origin = basePosVector.x;
242+
243+ float camPos = -camVector.z;
244+
245+ m_noteNoLow = (int)::floor((camPos - origin) / m_KeyboardDesignMod.GetNoteStep());
246+ m_noteNoHigh = m_noteNoLow + 1;
247+
248+ //char buf[256];
249+ //::sprintf(buf, "O:%f, P:%f, L:%d, H:%d\n", origin, camPos, m_noteNoLow, m_noteNoHigh);
250+ //::OutputDebugStringA(buf);
251+
252+ if (m_noteNoLow < 0) {
253+ m_noteNoLow = -1;
254+ }
255+
256+ if (m_noteNoLow >= SM_MAX_NOTE_NUM) {
257+ m_noteNoLow = SM_MAX_NOTE_NUM - 1;
258+ }
259+
260+
261+ if (m_noteNoHigh < 0) {
262+ m_noteNoHigh = 0;
263+ }
264+
265+ if (m_noteNoHigh >= SM_MAX_NOTE_NUM) {
266+ m_noteNoHigh = -1;
267+ }
268+
269+ return 0;
270+}
271+
272+//******************************************************************************
220273 // 逆順インデックス生成
221274 //******************************************************************************
222275 int MTPianoKeyboardMod::_CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice)
--- a/MIDITrail/MTPianoKeyboardMod.h
+++ b/MIDITrail/MTPianoKeyboardMod.h
@@ -41,6 +41,8 @@ public:
4141 LPDIRECT3DDEVICE9 pD3DDevice,
4242 D3DXVECTOR3 basePosVector,
4343 D3DXVECTOR3 playbackPosVector,
44+ D3DXVECTOR3 camVector,
45+ D3DXVECTOR3 lookVector,
4446 float rollAngle
4547 );
4648
@@ -55,6 +57,13 @@ public:
5557
5658 private:
5759
60+ //描画順の作成
61+ int _MakeRenderingOrder(
62+ D3DXVECTOR3 basePosVector,
63+ D3DXVECTOR3 camVector,
64+ D3DXVECTOR3 lookVector
65+ );
66+
5867 //逆順インデックスの生成
5968 int _CreateRevIndex(LPDIRECT3DDEVICE9 pD3DDevice);
6069
@@ -106,6 +115,10 @@ private:
106115 LPDIRECT3DINDEXBUFFER9 m_pRevIndexBuffer;
107116 unsigned long m_RevIndexNum;
108117 bool m_IsRevIndexLocked;
118+
119+ //キーボード描画範囲
120+ int m_noteNoLow;
121+ int m_noteNoHigh;
109122 };
110123
111124
--- a/MIDITrail/MTScenePianoRoll3DMod.cpp
+++ b/MIDITrail/MTScenePianoRoll3DMod.cpp
@@ -106,6 +106,11 @@ int MTScenePianoRoll3DMod::Transform(
106106 int result = 0;
107107 float rollAngle = 0.0f;
108108 D3DXVECTOR3 camVector;
109+ D3DXVECTOR3 lookVector;
110+ float phi;
111+ float phiRad;
112+ float theta;
113+ float thetaRad;
109114
110115 //基底クラスの変換処理を呼び出す
111116 result = MTScenePianoRoll3D::Transform(pD3DDevice);
@@ -114,6 +119,16 @@ int MTScenePianoRoll3DMod::Transform(
114119 //カメラ座標取得
115120 m_FirstPersonCam.GetPosition(&camVector);
116121
122+ //カメラ視線方向取得
123+ m_FirstPersonCam.GetDirection(&phi, &theta);
124+
125+ //視線ベクトル(極座標から直交座標へ変換)
126+ phiRad = D3DXToRadian(phi);
127+ thetaRad = D3DXToRadian(theta);
128+ lookVector.x = 10.0f * sin(thetaRad) * cos(phiRad);
129+ lookVector.y = 10.0f * cos(thetaRad);
130+ lookVector.z = 10.0f * sin(thetaRad) * sin(phiRad);
131+
117132 //回転角度取得
118133 rollAngle = m_FirstPersonCam.GetManualRollAngle();
119134
@@ -134,7 +149,7 @@ int MTScenePianoRoll3DMod::Transform(
134149 if (result != 0) goto EXIT;
135150
136151 //ピアノキーボード更新
137- result = m_PianoKeyboardCtrlMod.Transform(pD3DDevice, camVector, rollAngle);
152+ result = m_PianoKeyboardCtrlMod.Transform(pD3DDevice, camVector, lookVector, rollAngle);
138153 if (result != 0) goto EXIT;
139154
140155 EXIT:;