viewing works (?)
This commit is contained in:
parent
ead6a8959d
commit
09c3df6d43
20
syncdata.h
20
syncdata.h
@ -24,27 +24,31 @@ public:
|
||||
int currRow = int(floor(time));
|
||||
|
||||
// find bounding keyframes
|
||||
keyFrameContainer::const_iterator upper = keyFrames.upper_bound(currRow);
|
||||
keyFrameContainer::const_iterator lower = upper;
|
||||
KeyFrameContainer::const_iterator upper = keyFrames.upper_bound(currRow);
|
||||
KeyFrameContainer::const_iterator lower = upper;
|
||||
lower--;
|
||||
|
||||
// bounds check
|
||||
if (lower == keyFrames.end()) return upper->second.value;
|
||||
if (upper == keyFrames.end()) return lower->second.value;
|
||||
|
||||
float delta = upper->second.value - lower->second.value;
|
||||
|
||||
// lerp, bitch
|
||||
float d = (time - lower->first) / (upper->first - lower->first);
|
||||
return lower->second.value + (upper->second.value - lower->second.value) * d;
|
||||
return lower->second.value + delta * d;
|
||||
};
|
||||
|
||||
bool isKeyFrame(int row)
|
||||
bool isKeyFrame(int row) const
|
||||
{
|
||||
return keyFrames.find(row) != keyFrames.end();
|
||||
}
|
||||
|
||||
KeyFrame &getKeyFrame(int row)
|
||||
const KeyFrame *getKeyFrame(int row) const
|
||||
{
|
||||
return keyFrames[row];
|
||||
KeyFrameContainer::const_iterator iter = keyFrames.find(row);
|
||||
if (iter == keyFrames.end()) return NULL;
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
void setKeyFrame(int row, const KeyFrame &keyFrame)
|
||||
@ -53,8 +57,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::map<int, struct KeyFrame> keyFrameContainer;
|
||||
keyFrameContainer keyFrames;
|
||||
typedef std::map<int, struct KeyFrame> KeyFrameContainer;
|
||||
KeyFrameContainer keyFrames;
|
||||
};
|
||||
|
||||
class SyncData
|
||||
|
||||
@ -11,7 +11,7 @@ const TCHAR *mainWindowClassName = _T("MainWindow");
|
||||
TrackView *trackView;
|
||||
HWND trackViewWin;
|
||||
|
||||
LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
@ -37,7 +37,7 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
||||
return 0;
|
||||
}
|
||||
|
||||
ATOM registerMainWindowClass(HINSTANCE hInstance)
|
||||
static ATOM registerMainWindowClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
|
||||
@ -66,17 +66,19 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
SyncData syncData;
|
||||
SyncTrack &testTrack = syncData.getTrack("test");
|
||||
SyncTrack &test2Track = syncData.getTrack("test2");
|
||||
for (int i = 0; i < 1 << 16; ++i)
|
||||
/* for (int i = 0; i < 1 << 16; ++i)
|
||||
{
|
||||
char temp[256];
|
||||
sprintf(temp, "gen %02d", i);
|
||||
SyncTrack &temp2 = syncData.getTrack(temp);
|
||||
}
|
||||
} */
|
||||
|
||||
// testTrack.setKeyFrame(0, SyncTrack::KeyFrame(1.0f));
|
||||
testTrack.setKeyFrame(1, SyncTrack::KeyFrame(2.0f));
|
||||
testTrack.setKeyFrame(4, SyncTrack::KeyFrame(3.0f));
|
||||
|
||||
test2Track.setKeyFrame(0, SyncTrack::KeyFrame(100.0f));
|
||||
test2Track.setKeyFrame(8, SyncTrack::KeyFrame(999.0f));
|
||||
|
||||
for (int i = 0; i < 5 * 2; ++i)
|
||||
{
|
||||
float time = float(i) / 2;
|
||||
|
||||
@ -176,8 +176,15 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
||||
|
||||
SetTextColor(hdc, RGB(0, 0, 0));
|
||||
|
||||
for (int track = firstTrack; track <= lastTrack; ++track)
|
||||
SyncData *syncData = getSyncData();
|
||||
if (NULL == syncData) return;
|
||||
|
||||
SyncData::TrackContainer::iterator trackIter = syncData->tracks.begin();
|
||||
for (int track = 0; track <= lastTrack; ++track, ++trackIter)
|
||||
{
|
||||
ASSERT(trackIter != syncData->tracks.end());
|
||||
if (track < firstTrack) continue;
|
||||
|
||||
for (int line = firstLine; line <= lastLine; ++line)
|
||||
{
|
||||
RECT patternDataRect;
|
||||
@ -201,12 +208,17 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
||||
Rectangle(hdc, fillRect.left, fillRect.top, fillRect.right, fillRect.bottom);
|
||||
}
|
||||
|
||||
bool key = (line % 8 == 0);
|
||||
float val = (float(line) / 16);
|
||||
const SyncTrack &track = trackIter->second;
|
||||
bool key = track.isKeyFrame(line);
|
||||
|
||||
/* format the text */
|
||||
if (!key) _sntprintf_s(temp, 256, _T("---"));
|
||||
else _sntprintf_s(temp, 256, _T("%2.2f"), val);
|
||||
else
|
||||
{
|
||||
float val = track.getKeyFrame(line)->value;
|
||||
_sntprintf_s(temp, 256, _T("%2.2f"), val);
|
||||
}
|
||||
|
||||
TextOut(hdc,
|
||||
patternDataRect.left, patternDataRect.top,
|
||||
temp, int(_tcslen(temp))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user