MIDITrail をピカピカにする。鍵盤方向自動切替・多ポート・歌詞対応等
修订版 | cdfa87d56c1fb507f29da50dd84312f34eb32f76 (tree) |
---|---|
时间 | 2018-04-12 08:44:05 |
作者 | yoshy <yoshy@user...> |
Commiter | yoshy |
[CLEAN] キーボードデザインクラスで必要なノートデザイン情報を取得するように修正
@@ -74,19 +74,19 @@ protected: | ||
74 | 74 | |
75 | 75 | private: |
76 | 76 | |
77 | - //ディケイ時間 | |
77 | + //波紋ディケイ時間 | |
78 | 78 | int m_RippleDecayDuration; |
79 | - //リリース時間 | |
79 | + //波紋リリース時間 | |
80 | 80 | int m_RippleReleaseDuration; |
81 | 81 | |
82 | - //描画元(リップル画像)ブレンド指定 | |
82 | + //波紋描画元(リップル画像)ブレンド指定 | |
83 | 83 | D3DBLEND m_RippleSrcBlend; |
84 | - //描画先(背景画像)ブレンド指定 | |
84 | + //波紋描画先(背景画像)ブレンド指定 | |
85 | 85 | D3DBLEND m_RippleDestBlend; |
86 | 86 | |
87 | - //上書き回数 | |
87 | + //波紋上書き回数 | |
88 | 88 | int m_RippleOverwriteTimes; |
89 | - //描画間隔 | |
89 | + //波紋描画間隔 | |
90 | 90 | float m_RippleSpacing; |
91 | 91 | }; |
92 | 92 |
@@ -12,8 +12,6 @@ | ||
12 | 12 | #include "YNBaseLib.h" |
13 | 13 | #include "MTPianoKeyboardCtrlMod.h" |
14 | 14 | #include "MTPianoKeyboardMod.h" |
15 | -#include "MTNoteRippleMod.h" | |
16 | -#include "MTNoteLyrics.h" | |
17 | 15 | |
18 | 16 | using namespace YNBaseLib; |
19 | 17 |
@@ -200,14 +198,11 @@ int MTPianoKeyboardCtrlMod::Transform( | ||
200 | 198 | &portWindowRD |
201 | 199 | ); |
202 | 200 | |
203 | - float boardHeight = portWindowLU.y - portWindowLD.y; | |
204 | - float keyboardWidth = m_KeyboardDesignMod.GetPortOriginX() * -2.0f; | |
201 | + float boardHeight = m_KeyboardDesignMod.GetPlaybackSectionHeight(); | |
202 | + float keyboardWidth = m_KeyboardDesignMod.GetKeyboardWidth(); | |
205 | 203 | |
206 | 204 | float resizeSacle = boardHeight / keyboardWidth; |
207 | 205 | |
208 | - float rippleSpacing = m_NoteDesignMod.GetRippleSpacing(); | |
209 | - float rippleMargin = rippleSpacing * (MTNOTELYRICS_MAX_LYRICS_NUM + MTNOTERIPPLE_MAX_RIPPLE_NUM); // * antiResizeScale; | |
210 | - | |
211 | 206 | //移動ベクトル:再生面に追従する |
212 | 207 | playbackPosVector = m_NoteDesignMod.GetWorldMoveVector(); |
213 | 208 | playbackPosVector.x += m_NoteDesignMod.GetPlayPosX(m_CurTickTime); |
@@ -234,7 +229,7 @@ int MTPianoKeyboardCtrlMod::Transform( | ||
234 | 229 | } |
235 | 230 | |
236 | 231 | //移動ベクトル:キーボード基準座標 |
237 | - transformVector = m_KeyboardDesignMod.GetKeyboardBasePos(keyboardIndex, rippleMargin, boardHeight, rollAngle); | |
232 | + transformVector = m_KeyboardDesignMod.GetKeyboardBasePos(keyboardIndex, rollAngle); | |
238 | 233 | |
239 | 234 | //移動ベクトル:ピッチベンドシフトを反映 |
240 | 235 | transformVector.x += GetMaxPitchBendShift(portNo); |
@@ -12,6 +12,8 @@ | ||
12 | 12 | #include "DXColorUtil.h" |
13 | 13 | #include "MTConfFile.h" |
14 | 14 | #include "MTPianoKeyboardDesignMod.h" |
15 | +#include "MTNoteRippleMod.h" | |
16 | +#include "MTNoteLyrics.h" | |
15 | 17 | |
16 | 18 | |
17 | 19 | //****************************************************************************** |
@@ -75,6 +77,37 @@ void MTPianoKeyboardDesignMod::_Initialize() | ||
75 | 77 | } |
76 | 78 | |
77 | 79 | //****************************************************************************** |
80 | +// キーボード基準座標取得 | |
81 | +//****************************************************************************** | |
82 | +D3DXVECTOR3 MTPianoKeyboardDesignMod::GetKeyboardBasePos( | |
83 | + int keyboardIndex, | |
84 | + float angle | |
85 | + ) | |
86 | +{ | |
87 | + float ox, oy, oz = 0.0f; | |
88 | + | |
89 | + //ロール角度によって描画方法を切り替える | |
90 | + angle += angle < 0.0f ? 360.0f : 0.0f; | |
91 | + bool flip = !((angle > 120.0f) && (angle < 300.0f)); | |
92 | + | |
93 | + float boardHeight = GetPlaybackSectionHeight(); | |
94 | + float keyboardWidth = GetKeyboardWidth(); | |
95 | + | |
96 | + float rippleMargin = GetRippleMargin(); // * antiResizeScale; | |
97 | + | |
98 | + //キーボード描画時にリサイズがかかってはならない相対座標用の逆リサイズ比 | |
99 | + //対象:ポート間隔、リップルマージン | |
100 | + float antiResizeScale = keyboardWidth / boardHeight; | |
101 | + | |
102 | + //ポート単位の原点座標 | |
103 | + ox = GetPortOriginX(); | |
104 | + oy = GetPortOriginY(keyboardIndex, antiResizeScale, flip); | |
105 | + oz = GetPortOriginZ(keyboardIndex, antiResizeScale, flip); | |
106 | + | |
107 | + return D3DXVECTOR3(ox, oy, oz); | |
108 | +} | |
109 | + | |
110 | +//****************************************************************************** | |
78 | 111 | // ポート原点X座標取得 |
79 | 112 | //****************************************************************************** |
80 | 113 | float MTPianoKeyboardDesignMod::GetPortOriginX() |
@@ -108,7 +141,7 @@ float MTPianoKeyboardDesignMod::GetPortOriginX() | ||
108 | 141 | // | |
109 | 142 | // -z |
110 | 143 | |
111 | - float originX = MTPianoKeyboardDesign::GetPortOriginX(0); | |
144 | + float originX = -GetKeyboardWidth() / 2.0f; | |
112 | 145 | |
113 | 146 | //鍵盤の1/2の幅だけ高音側に移動 |
114 | 147 | return originX + GetWhiteKeyStep() / 2.0f; |
@@ -167,7 +200,7 @@ float MTPianoKeyboardDesignMod::GetPortOriginY( | ||
167 | 200 | float originY = portWidth * (keyboardDispNum - keyboardIndex - 1); |
168 | 201 | |
169 | 202 | if (!flip) { |
170 | - originY = -(originY + GetChStep() * 15.0f); | |
203 | + originY = 0; //-(originY + GetChStep() * 15.0f); | |
171 | 204 | } |
172 | 205 | |
173 | 206 | //キーボードリサイズ後に正しいポート間隔となるよう逆比をかける |
@@ -184,7 +217,6 @@ float MTPianoKeyboardDesignMod::GetPortOriginY( | ||
184 | 217 | //****************************************************************************** |
185 | 218 | float MTPianoKeyboardDesignMod::GetPortOriginZ( |
186 | 219 | int keyboardIndex, |
187 | - float rippleMargin, | |
188 | 220 | float antiResizeScale, |
189 | 221 | bool flip |
190 | 222 | ) |
@@ -221,7 +253,7 @@ float MTPianoKeyboardDesignMod::GetPortOriginZ( | ||
221 | 253 | float originZ; |
222 | 254 | |
223 | 255 | //キーボードリサイズ後に正しいリップルマージンとなるよう逆比をかける |
224 | - rippleMargin *= antiResizeScale; | |
256 | + float rippleMargin = GetRippleSpacing() * antiResizeScale; | |
225 | 257 | |
226 | 258 | if (!flip) { |
227 | 259 | originZ = -(GetWhiteKeyLen() + rippleMargin); |
@@ -234,6 +266,30 @@ float MTPianoKeyboardDesignMod::GetPortOriginZ( | ||
234 | 266 | } |
235 | 267 | |
236 | 268 | //****************************************************************************** |
269 | +// ノートボックス高さ取得 | |
270 | +//****************************************************************************** | |
271 | +float MTPianoKeyboardDesignMod::GetNoteBoxHeight() | |
272 | +{ | |
273 | + return m_NoteBoxHeight; | |
274 | +} | |
275 | + | |
276 | +//****************************************************************************** | |
277 | +// ノートボックス幅取得 | |
278 | +//****************************************************************************** | |
279 | +float MTPianoKeyboardDesignMod::GetNoteBoxWidth() | |
280 | +{ | |
281 | + return m_NoteBoxWidth; | |
282 | +} | |
283 | + | |
284 | +//****************************************************************************** | |
285 | +// ノート間隔取得 | |
286 | +//****************************************************************************** | |
287 | +float MTPianoKeyboardDesignMod::GetNoteStep() | |
288 | +{ | |
289 | + return m_NoteStep; | |
290 | +} | |
291 | + | |
292 | +//****************************************************************************** | |
237 | 293 | // チャンネル間隔取得 |
238 | 294 | //****************************************************************************** |
239 | 295 | float MTPianoKeyboardDesignMod::GetChStep() |
@@ -242,6 +298,70 @@ float MTPianoKeyboardDesignMod::GetChStep() | ||
242 | 298 | } |
243 | 299 | |
244 | 300 | //****************************************************************************** |
301 | +// キーボード高さ取得 | |
302 | +//****************************************************************************** | |
303 | +float MTPianoKeyboardDesignMod::GetKeyboardHeight() | |
304 | +{ | |
305 | + return GetBlackKeyHeight(); | |
306 | +} | |
307 | + | |
308 | +//****************************************************************************** | |
309 | +// キーボード幅取得 | |
310 | +//****************************************************************************** | |
311 | +float MTPianoKeyboardDesignMod::GetKeyboardWidth() | |
312 | +{ | |
313 | + return GetWhiteKeyStep() * (float)(SM_MAX_NOTE_NUM - 53); | |
314 | +} | |
315 | + | |
316 | +//****************************************************************************** | |
317 | +// グリッド高さ取得 | |
318 | +//****************************************************************************** | |
319 | +float MTPianoKeyboardDesignMod::GetGridHeight() | |
320 | +{ | |
321 | + return GetNoteStep() * 127; | |
322 | +} | |
323 | + | |
324 | +//****************************************************************************** | |
325 | +// グリッド幅取得 | |
326 | +//****************************************************************************** | |
327 | +float MTPianoKeyboardDesignMod::GetGridWidth() | |
328 | +{ | |
329 | + return GetChStep() * 15; | |
330 | +} | |
331 | + | |
332 | +//****************************************************************************** | |
333 | +// 再生面高さ取得 | |
334 | +//****************************************************************************** | |
335 | +float MTPianoKeyboardDesignMod::GetPlaybackSectionHeight() | |
336 | +{ | |
337 | + return GetGridHeight() + GetNoteBoxHeight(); | |
338 | +} | |
339 | + | |
340 | +//****************************************************************************** | |
341 | +// 再生面幅取得 | |
342 | +//****************************************************************************** | |
343 | +float MTPianoKeyboardDesignMod::GetPlaybackSectionWidth() | |
344 | +{ | |
345 | + return GetGridWidth() + GetNoteBoxWidth(); | |
346 | +} | |
347 | + | |
348 | +//****************************************************************************** | |
349 | +// 波紋描画間隔取得 | |
350 | +//****************************************************************************** | |
351 | +float MTPianoKeyboardDesignMod::GetRippleSpacing() | |
352 | +{ | |
353 | + return m_RippleSpacing; | |
354 | +} | |
355 | + | |
356 | +//****************************************************************************** | |
357 | +// 波紋描画マージン取得 | |
358 | +//****************************************************************************** | |
359 | +float MTPianoKeyboardDesignMod::GetRippleMargin() | |
360 | +{ | |
361 | + return GetRippleSpacing() * (MTNOTELYRICS_MAX_LYRICS_NUM + MTNOTERIPPLE_MAX_RIPPLE_NUM); | |
362 | +} | |
363 | + | |
364 | +//****************************************************************************** | |
245 | 365 | // 発音中キーカラー取得 |
246 | 366 | //****************************************************************************** |
247 | 367 | D3DXCOLOR MTPianoKeyboardDesignMod::GetActiveKeyColor( |
@@ -306,36 +426,6 @@ D3DXCOLOR MTPianoKeyboardDesignMod::GetActiveKeyColor( | ||
306 | 426 | } |
307 | 427 | |
308 | 428 | //****************************************************************************** |
309 | -// キーボード基準座標取得 | |
310 | -//****************************************************************************** | |
311 | -D3DXVECTOR3 MTPianoKeyboardDesignMod::GetKeyboardBasePos( | |
312 | - int keyboardIndex, | |
313 | - float rippleMargin, | |
314 | - float boardHeight, | |
315 | - float angle | |
316 | - ) | |
317 | -{ | |
318 | - float ox, oy, oz = 0.0f; | |
319 | - | |
320 | - //ロール角度によって描画方法を切り替える | |
321 | - angle += angle < 0.0f ? 360.0f : 0.0f; | |
322 | - bool flip = !((angle > 120.0f) && (angle < 300.0f)); | |
323 | - | |
324 | - float keyboardWidth = MTPianoKeyboardDesign::GetPortOriginX(0) * -2.0f; | |
325 | - | |
326 | - //キーボード描画時にリサイズがかかってはならない相対座標用の逆リサイズ比 | |
327 | - //対象:ポート間隔、リップルマージン | |
328 | - float antiResizeScale = keyboardWidth / boardHeight; | |
329 | - | |
330 | - //ポート単位の原点座標 | |
331 | - ox = GetPortOriginX(); | |
332 | - oy = GetPortOriginY(keyboardIndex, antiResizeScale, flip); | |
333 | - oz = GetPortOriginZ(keyboardIndex, rippleMargin, antiResizeScale, flip); | |
334 | - | |
335 | - return D3DXVECTOR3(ox, oy, oz); | |
336 | -} | |
337 | - | |
338 | -//****************************************************************************** | |
339 | 429 | // 設定ファイル読み込み |
340 | 430 | //****************************************************************************** |
341 | 431 | int MTPianoKeyboardDesignMod::_LoadConfFile( |
@@ -361,6 +451,13 @@ int MTPianoKeyboardDesignMod::_LoadConfFile( | ||
361 | 451 | //---------------------------------- |
362 | 452 | result = confFile.SetCurSection(_T("Scale")); |
363 | 453 | if (result != 0) goto EXIT; |
454 | + | |
455 | + result = confFile.GetFloat(_T("NoteBoxHeight"), &m_NoteBoxHeight, 0.1f); | |
456 | + if (result != 0) goto EXIT; | |
457 | + result = confFile.GetFloat(_T("NoteBoxWidth"), &m_NoteBoxWidth, 0.1f); | |
458 | + if (result != 0) goto EXIT; | |
459 | + result = confFile.GetFloat(_T("NoteStep"), &m_NoteStep, 0.1f); | |
460 | + if (result != 0) goto EXIT; | |
364 | 461 | result = confFile.GetFloat(_T("ChStep"), &m_ChStep, 0.5f); |
365 | 462 | if (result != 0) goto EXIT; |
366 | 463 |
@@ -379,6 +476,16 @@ int MTPianoKeyboardDesignMod::_LoadConfFile( | ||
379 | 476 | m_ActiveKeyColorList[i] = DXColorUtil::MakeColorFromHexRGBA(hexColor); |
380 | 477 | } |
381 | 478 | |
479 | + //---------------------------------- | |
480 | + //波紋情報 | |
481 | + //---------------------------------- | |
482 | + result = confFile.SetCurSection(_T("Ripple")); | |
483 | + if (result != 0) goto EXIT; | |
484 | + | |
485 | + //波紋描画間隔 | |
486 | + result = confFile.GetFloat(_T("Spacing"), &m_RippleSpacing, 0.002f); | |
487 | + if (result != 0) goto EXIT; | |
488 | + | |
382 | 489 | EXIT:; |
383 | 490 | return result; |
384 | 491 | } |
@@ -27,14 +27,42 @@ public: | ||
27 | 27 | //初期化 |
28 | 28 | virtual int Initialize(const TCHAR* pSceneName, SMSeqData* pSeqData); |
29 | 29 | |
30 | + //キーボード基準座標取得 | |
31 | + D3DXVECTOR3 GetKeyboardBasePos(int keyboardIndex, float angle); | |
32 | + | |
30 | 33 | //ポート原点座標取得 |
31 | 34 | float GetPortOriginX(); |
32 | 35 | float GetPortOriginY(int keyboardIndex, float antiResizeScale, bool flip); |
33 | - float GetPortOriginZ(int keyboardIndex, float rippleMargin, float antiResizeScale, bool flip); | |
36 | + float GetPortOriginZ(int keyboardIndex, float antiResizeScale, bool flip); | |
37 | + | |
38 | + //ノートボックス高さ・幅取得 | |
39 | + float GetNoteBoxHeight(); | |
40 | + float GetNoteBoxWidth(); | |
41 | + | |
42 | + //ノート間隔取得 | |
43 | + float GetNoteStep(); | |
34 | 44 | |
35 | 45 | //チャンネル間隔取得 |
36 | 46 | float GetChStep(); |
37 | 47 | |
48 | + //キーボード高さ・幅取得 | |
49 | + float GetKeyboardHeight(); | |
50 | + float GetKeyboardWidth(); | |
51 | + | |
52 | + //グリッド高さ・幅取得 | |
53 | + float GetGridHeight(); | |
54 | + float GetGridWidth(); | |
55 | + | |
56 | + //再生面高さ・幅取得 | |
57 | + float GetPlaybackSectionHeight(); | |
58 | + float GetPlaybackSectionWidth(); | |
59 | + | |
60 | + //波紋描画間隔取得 | |
61 | + float GetRippleSpacing(); | |
62 | + | |
63 | + //波紋描画マージン取得 | |
64 | + float GetRippleMargin(); | |
65 | + | |
38 | 66 | //発音中キーカラー取得 |
39 | 67 | D3DXCOLOR GetActiveKeyColor( |
40 | 68 | unsigned char chNo, |
@@ -43,9 +71,6 @@ public: | ||
43 | 71 | D3DXCOLOR* pNoteColor = NULL |
44 | 72 | ); |
45 | 73 | |
46 | - //キーボード基準座標取得 | |
47 | - D3DXVECTOR3 GetKeyboardBasePos(int keyboardIndex, float rippleMargin, float boardHeight, float angle); | |
48 | - | |
49 | 74 | protected: |
50 | 75 | |
51 | 76 | virtual void _Initialize(); |
@@ -53,9 +78,18 @@ protected: | ||
53 | 78 | |
54 | 79 | private: |
55 | 80 | |
81 | + //ノートボックス高さ | |
82 | + float m_NoteBoxHeight; | |
83 | + //ノートボックス幅 | |
84 | + float m_NoteBoxWidth; | |
85 | + //ノート間隔 | |
86 | + float m_NoteStep; | |
56 | 87 | //チャンネル間隔 |
57 | 88 | float m_ChStep; |
58 | 89 | |
90 | + //波紋描画間隔 | |
91 | + float m_RippleSpacing; | |
92 | + | |
59 | 93 | //発音中キー色情報 |
60 | 94 | D3DXCOLOR m_ActiveKeyColorList[16]; |
61 | 95 |