Code for sending the keyframes over to the demo
This commit is contained in:
parent
5faf9d53fd
commit
d681e5bd20
@ -10,6 +10,7 @@
|
||||
#include "RemoteConnection.h"
|
||||
#include "../../sync/sync.h"
|
||||
#include "../../sync/base.h"
|
||||
#include "../../sync/data.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -23,8 +24,21 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct EditorData
|
||||
{
|
||||
struct sync_data syncData;
|
||||
TrackViewInfo trackViewInfo;
|
||||
int trackOrder[8192];
|
||||
int orderCount;
|
||||
|
||||
} EditorData;
|
||||
|
||||
static EditorData s_editorData;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static uint64_t fontIds[2];
|
||||
static TrackViewInfo s_trackViewInfo;
|
||||
int clientIndex = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -34,7 +48,7 @@ void Editor_create()
|
||||
//fontIds[0] = Emgui_loadFont("/Users/daniel/Library/Fonts/MicroKnight_v1.0.ttf", 11.0f);
|
||||
fontIds[0] = Emgui_loadFont(FONT_PATH "Arial.ttf", 11.0f);
|
||||
|
||||
memset(&s_trackViewInfo, 0, sizeof(s_trackViewInfo));
|
||||
memset(&s_editorData, 0, sizeof(s_editorData));
|
||||
|
||||
RemoteConnection_createListner();
|
||||
}
|
||||
@ -51,7 +65,7 @@ void Editor_update()
|
||||
{
|
||||
Emgui_begin();
|
||||
|
||||
TrackView_render(&s_trackViewInfo);
|
||||
TrackView_render(&s_editorData.trackViewInfo);
|
||||
|
||||
Emgui_end();
|
||||
}
|
||||
@ -81,11 +95,20 @@ bool Editor_keyDown(int key)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int createTrack(EditorData* data, const char* name)
|
||||
{
|
||||
int index = sync_create_track(&data->syncData, name);
|
||||
data->trackOrder[data->orderCount] = index;
|
||||
data->orderCount++;
|
||||
return index;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void processCommands()
|
||||
{
|
||||
//SyncDocument *doc = trackView->getDocument();
|
||||
int strLen, newRow;
|
||||
//const struct sync_track* t;
|
||||
int strLen, newRow, serverIndex;
|
||||
unsigned char cmd = 0;
|
||||
|
||||
if (RemoteConnection_recv((char*)&cmd, 1, 0))
|
||||
@ -110,21 +133,20 @@ static void processCommands()
|
||||
rlog(R_INFO, "Got trackname %s (%d) from demo\n", trackName, strLen);
|
||||
|
||||
// find track
|
||||
/*
|
||||
serverIndex = sync_find_track(doc, trackName.c_str());
|
||||
if (0 > serverIndex)
|
||||
serverIndex = int(doc->createTrack(trackName));
|
||||
|
||||
// setup remap
|
||||
doc->clientSocket.clientTracks[trackName] = clientIndex++;
|
||||
serverIndex = sync_find_track(&s_editorData.syncData, trackName);
|
||||
if (0 > serverIndex)
|
||||
serverIndex = createTrack(&s_editorData, trackName);
|
||||
|
||||
// setup remap and send the keyframes to the demo
|
||||
RemoteConnection_mapTrackName(trackName, clientIndex++);
|
||||
RemoteConnection_sendKeyFrames(trackName, s_editorData.syncData.tracks[serverIndex]);
|
||||
|
||||
// send key-frames
|
||||
t = doc->tracks[serverIndex];
|
||||
for (int i = 0; i < (int)t->num_keys; ++i)
|
||||
doc->clientSocket.sendSetKeyCommand(trackName, t->keys[i]);
|
||||
//t = doc->tracks[serverIndex];
|
||||
//for (i = 0; i < (int)t->num_keys; ++i)
|
||||
// doc->clientSocket.sendSetKeyCommand(trackName, t->keys[i]);
|
||||
|
||||
InvalidateRect(trackViewWin, NULL, FALSE);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
extern int clientIndex;
|
||||
int s_socket = INVALID_SOCKET;
|
||||
int s_serverSocket = INVALID_SOCKET;
|
||||
static bool s_paused = false;
|
||||
@ -93,6 +94,20 @@ int findTrack(const char* name)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoteConnection_mapTrackName(const char* name, int index)
|
||||
{
|
||||
int count = s_nameLookup.count;
|
||||
|
||||
if (findTrack(name))
|
||||
return;
|
||||
|
||||
s_nameLookup.hashes[count] = quickHash(name);
|
||||
s_nameLookup.ids[count] = index;
|
||||
s_nameLookup.count++;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool setBlocking(int sock, bool blocking)
|
||||
{
|
||||
u_long block = blocking ? 0 : 1;
|
||||
@ -205,10 +220,9 @@ void RemoteConnection_updateListner()
|
||||
{
|
||||
rlog(R_INFO, "Connected to %s\n", inet_ntoa(client.sin_addr));
|
||||
s_socket = clientSocket;
|
||||
|
||||
clientIndex = 0;
|
||||
RemoteConnection_sendPauseCommand(true);
|
||||
//RemoteConnection_sendSetRowCommand(trackView->getEditRow());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -280,7 +294,7 @@ bool RemoteConnection_pollRead()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoteConnection_sendSetKeyCommand(const char* trackName, const struct track_key* key)
|
||||
static void sendSetKeyCommandIndex(uint32_t index, const struct track_key* key)
|
||||
{
|
||||
uint32_t track, row;
|
||||
uint8_t cmd = SET_KEY;
|
||||
@ -291,12 +305,7 @@ void RemoteConnection_sendSetKeyCommand(const char* trackName, const struct trac
|
||||
uint32_t i;
|
||||
} v;
|
||||
|
||||
track_id = findTrack(trackName);
|
||||
|
||||
if (!RemoteConnection_connected() || track_id == -1)
|
||||
return;
|
||||
|
||||
track = htonl((uint32_t)track_id);
|
||||
track = htonl(track_id);
|
||||
row = htonl(key->row);
|
||||
|
||||
v.f = key->value;
|
||||
@ -313,6 +322,18 @@ void RemoteConnection_sendSetKeyCommand(const char* trackName, const struct trac
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoteConnection_sendSetKeyCommand(const char* trackName, const struct track_key* key)
|
||||
{
|
||||
int track_id = findTrack(trackName);
|
||||
|
||||
if (!RemoteConnection_connected() || track_id == -1)
|
||||
return;
|
||||
|
||||
sendSetKeyCommandIndex((uint32_t)track_id, key);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoteConnection_sendDeleteKeyCommand(const char* trackName, int row)
|
||||
{
|
||||
uint32_t track;
|
||||
@ -378,3 +399,16 @@ bool RemoteConnection_isPaused()
|
||||
return s_paused;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoteConnection_sendKeyFrames(const char* name, struct sync_track* track)
|
||||
{
|
||||
int i, track_id = findTrack(name);
|
||||
|
||||
if (!RemoteConnection_connected() || track_id == -1)
|
||||
return;
|
||||
|
||||
for (i = 0; i < (int)track->num_keys; ++i)
|
||||
sendSetKeyCommandIndex((uint32_t)track_id, &track->keys[i]);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <Types.h>
|
||||
|
||||
struct track_key;
|
||||
struct sync_track;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Listen for incoming connections
|
||||
@ -19,9 +20,13 @@ void RemoteConnection_disconnect();
|
||||
bool RemoteConnection_recv(char* buffer, size_t length, int flags);
|
||||
bool RemoteConnection_send(const char* buffer, size_t length, int flags);
|
||||
bool RemoteConnection_pollRead();
|
||||
|
||||
void RemoteConnection_sendSetKeyCommand(const char* trackName, const struct track_key* key);
|
||||
void RemoteConnection_sendDeleteKeyCommand(const char* trackName, int row);
|
||||
void RemoteConnection_sendSetRowCommand(int row);
|
||||
void RemoteConnection_sendPauseCommand(bool pause);
|
||||
void RemoteConnection_sendSaveCommand();
|
||||
|
||||
void RemoteConnection_sendKeyFrames(const char* name, struct sync_track* track);
|
||||
void RemoteConnection_mapTrackName(const char* name, int index);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user