MIDITrail をピカピカにする。鍵盤方向自動切替・多ポート・歌詞対応等
Revisão | a4fe713bf30da995e89ceb76cb9053e975a6fd49 (tree) |
---|---|
Hora | 2019-08-28 07:06:19 |
Autor | yoshy <yoshy@user...> |
Commiter | yoshy |
[UPDATE] カメラ視線方向によるキーボード描画順の変更を実装
@@ -106,16 +106,32 @@ int MTPianoKeyboardMod::Draw( | ||
106 | 106 | pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); |
107 | 107 | pD3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); |
108 | 108 | |
109 | - //正順側キーボードの描画 | |
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; | |
109 | + //視線方向による描画順の変更 | |
110 | + if (m_camDir == -1) { | |
111 | + //正順側キーボードの描画 | |
112 | + if (m_noteNoLow != -1) { | |
113 | + result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3); | |
114 | + if (result != 0) goto EXIT; | |
115 | + } | |
116 | + | |
117 | + //逆順側キーボードの描画 | |
118 | + if (m_noteNoHigh != -1) { | |
119 | + result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRevIndexBuffer, m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3); | |
120 | + if (result != 0) goto EXIT; | |
121 | + } | |
113 | 122 | } |
123 | + else { | |
124 | + //逆順側キーボードの描画 | |
125 | + if (m_noteNoHigh != -1) { | |
126 | + result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pRevIndexBuffer, m_pTexture, m_BufInfo[m_noteNoHigh].revIndexTotal / 3); | |
127 | + if (result != 0) goto EXIT; | |
128 | + } | |
114 | 129 | |
115 | - //逆順側キーボードの描画 | |
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; | |
130 | + //正順側キーボードの描画 | |
131 | + if (m_noteNoLow != -1) { | |
132 | + result = m_PrimitiveKeyboard.Draw(pD3DDevice, m_pTexture, m_BufInfo[m_noteNoLow].indexTotal / 3); | |
133 | + if (result != 0) goto EXIT; | |
134 | + } | |
119 | 135 | } |
120 | 136 | |
121 | 137 | EXIT:; |
@@ -238,15 +254,21 @@ int MTPianoKeyboardMod::_MakeRenderingOrder( | ||
238 | 254 | D3DXVECTOR3 lookVector |
239 | 255 | ) |
240 | 256 | { |
257 | + //ピッチベンド幅を含んだキーボード原点 | |
241 | 258 | float origin = basePosVector.x; |
242 | 259 | |
260 | + //カメラ位置 | |
243 | 261 | float camPos = -camVector.z; |
244 | 262 | |
263 | + //カメラ視線方向 | |
264 | + float camDir = -lookVector.z; | |
265 | + | |
245 | 266 | m_noteNoLow = (int)::floor((camPos - origin) / m_KeyboardDesignMod.GetNoteStep()); |
246 | 267 | m_noteNoHigh = m_noteNoLow + 1; |
247 | 268 | |
248 | 269 | //char buf[256]; |
249 | - //::sprintf(buf, "O:%f, P:%f, L:%d, H:%d\n", origin, camPos, m_noteNoLow, m_noteNoHigh); | |
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); | |
250 | 272 | //::OutputDebugStringA(buf); |
251 | 273 | |
252 | 274 | if (m_noteNoLow < 0) { |
@@ -266,6 +288,8 @@ int MTPianoKeyboardMod::_MakeRenderingOrder( | ||
266 | 288 | m_noteNoHigh = -1; |
267 | 289 | } |
268 | 290 | |
291 | + m_camDir = camDir < 0 ? -1 : 1; | |
292 | + | |
269 | 293 | return 0; |
270 | 294 | } |
271 | 295 |
@@ -119,6 +119,7 @@ private: | ||
119 | 119 | //キーボード描画範囲 |
120 | 120 | int m_noteNoLow; |
121 | 121 | int m_noteNoHigh; |
122 | + int m_camDir; | |
122 | 123 | }; |
123 | 124 | |
124 | 125 |