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