Leo's Avatar Mixer + birarda's AgentData updates
Showing the changes to interface/src/main.cpp (1 of 17 files). Show all
Unified · Split
| @@ -200,21 +200,6 @@ timeval timerStart, timerEnd; · 199 unmodified lines | |||
| 200 | timeval lastTimeIdle; | 200 | timeval lastTimeIdle; |
| 201 | double elapsedTime; | 201 | double elapsedTime; |
| 202 | 202 | ||
| 203 | #ifdef MARKER_CAPTURE | ||
| 204 | |||
| 205 | /*** Marker Capture ***/ | ||
| 206 | #define MARKER_CAPTURE_INTERVAL 1 | ||
| 207 | MarkerCapture marker_capturer(CV_CAP_ANY); // Create a new marker capturer, attached to any valid camera. | ||
| 208 | MarkerAcquisitionView marker_acq_view(&marker_capturer); | ||
| 209 | bool marker_capture_enabled = true; | ||
| 210 | bool marker_capture_display = true; | ||
| 211 | IplImage* marker_capture_frame; | ||
| 212 | IplImage* marker_capture_blob_frame; | ||
| 213 | pthread_mutex_t frame_lock; | ||
| 214 | |||
| 215 | #endif | ||
| 216 | |||
| 217 | |||
| 218 | // Every second, check the frame rates and other stuff | 203 | // Every second, check the frame rates and other stuff |
| 219 | void Timer(int extra) | 204 | void Timer(int extra) |
| 220 | { | 205 | { |
| @@ -229,9 +214,6 @@ void Timer(int extra) · 8 unmodified lines | |||
| 229 | glutTimerFunc(1000,Timer,0); | 214 | glutTimerFunc(1000,Timer,0); |
| 230 | gettimeofday(&timerStart, NULL); | 215 | gettimeofday(&timerStart, NULL); |
| 231 | 216 | ||
| 232 | // Ping the agents we can see | ||
| 233 | agentList.pingAgents(); | ||
| 234 | |||
| 235 | // if we haven't detected gyros, check for them now | 217 | // if we haven't detected gyros, check for them now |
| 236 | if (!serialPort.active) { | 218 | if (!serialPort.active) { |
| 237 | serialPort.pair(); | 219 | serialPort.pair(); |
| @@ -478,11 +460,12 @@ void simulateHead(float frametime) · 240 unmodified lines | |||
| 478 | myAvatar.setAverageLoudness(averageLoudness); | 460 | myAvatar.setAverageLoudness(averageLoudness); |
| 479 | #endif | 461 | #endif |
| 480 | 462 | ||
| 481 | // Send my streaming head data to agents that are nearby and need to see it! | 463 | // Send my stream of head/hand data to the avatar mixer and voxel server |
| 482 | const int MAX_BROADCAST_STRING = 200; | 464 | char broadcastString[200]; |
| 483 | char broadcast_string[MAX_BROADCAST_STRING]; | 465 | int broadcastBytes = myAvatar.getBroadcastData(broadcastString); |
| 484 | int broadcast_bytes = myAvatar.getBroadcastData(broadcast_string); | 466 | const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER}; |
| 485 | agentList.broadcastToAgents(broadcast_string, broadcast_bytes,AgentList::AGENTS_OF_TYPE_VOXEL_AND_INTERFACE); | 467 | |
| 468 | agentList.broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers, 2); | ||
| 486 | 469 | ||
| 487 | // If I'm in paint mode, send a voxel out to VOXEL server agents. | 470 | // If I'm in paint mode, send a voxel out to VOXEL server agents. |
| 488 | if (::paintOn) { | 471 | if (::paintOn) { |
| @@ -501,8 +484,8 @@ void simulateHead(float frametime) · 12 unmodified lines | |||
| 501 | ::paintingVoxel.y >= 0.0 && ::paintingVoxel.y <= 1.0 && | 484 | ::paintingVoxel.y >= 0.0 && ::paintingVoxel.y <= 1.0 && |
| 502 | ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) { | 485 | ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) { |
| 503 | 486 | ||
| 504 | if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL,0,1,&::paintingVoxel,bufferOut,sizeOut)){ | 487 | if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){ |
| 505 | agentList.broadcastToAgents((char*)bufferOut, sizeOut,AgentList::AGENTS_OF_TYPE_VOXEL); | 488 | agentList.broadcastToAgents((char*)bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1); |
| 506 | delete bufferOut; | 489 | delete bufferOut; |
| 507 | } | 490 | } |
| 508 | } | 491 | } |
| @@ -1023,15 +1006,15 @@ void testPointToVoxel() · 514 unmodified lines | |||
| 1023 | void sendVoxelServerEraseAll() { | 1006 | void sendVoxelServerEraseAll() { |
| 1024 | char message[100]; | 1007 | char message[100]; |
| 1025 | sprintf(message,"%c%s",'Z',"erase all"); | 1008 | sprintf(message,"%c%s",'Z',"erase all"); |
| 1026 | int messageSize = strlen(message)+1; | 1009 | int messageSize = strlen(message) + 1; |
| 1027 | ::agentList.broadcastToAgents(message, messageSize,AgentList::AGENTS_OF_TYPE_VOXEL); | 1010 | ::agentList.broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1); |
| 1028 | } | 1011 | } |
| 1029 | 1012 | ||
| 1030 | void sendVoxelServerAddScene() { | 1013 | void sendVoxelServerAddScene() { |
| 1031 | char message[100]; | 1014 | char message[100]; |
| 1032 | sprintf(message,"%c%s",'Z',"add scene"); | 1015 | sprintf(message,"%c%s",'Z',"add scene"); |
| 1033 | int messageSize = strlen(message)+1; | 1016 | int messageSize = strlen(message) + 1; |
| 1034 | ::agentList.broadcastToAgents(message, messageSize,AgentList::AGENTS_OF_TYPE_VOXEL); | 1017 | ::agentList.broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1); |
| 1035 | } | 1018 | } |
| 1036 | 1019 | ||
| 1037 | void shiftPaintingColor() | 1020 | void shiftPaintingColor() |
| @@ -1207,9 +1190,7 @@ void key(unsigned char k, int x, int y) · 169 unmodified lines | |||
| 1207 | if (k == '.') addRandomSphere(wantColorRandomizer); | 1190 | if (k == '.') addRandomSphere(wantColorRandomizer); |
| 1208 | } | 1191 | } |
| 1209 | 1192 | ||
| 1210 | // | ||
| 1211 | // Receive packets from other agents/servers and decide what to do with them! | 1193 | // Receive packets from other agents/servers and decide what to do with them! |
| 1212 | // | ||
| 1213 | void *networkReceive(void *args) | 1194 | void *networkReceive(void *args) |
| 1214 | { | 1195 | { |
| 1215 | sockaddr senderAddress; | 1196 | sockaddr senderAddress; |
| @@ -1221,19 +1202,26 @@ void *networkReceive(void *args) · 5 unmodified lines | |||
| 1221 | packetCount++; | 1202 | packetCount++; |
| 1222 | bytesCount += bytesReceived; | 1203 | bytesCount += bytesReceived; |
| 1223 | 1204 | ||
| 1224 | if (incomingPacket[0] == PACKET_HEADER_TRANSMITTER_DATA) { | 1205 | switch (incomingPacket[0]) { |
| 1225 | // Pass everything but transmitter data to the agent list | 1206 | case PACKET_HEADER_TRANSMITTER_DATA: |
| 1226 | myAvatar.hand->processTransmitterData(incomingPacket, bytesReceived); | 1207 | myAvatar.hand->processTransmitterData(incomingPacket, bytesReceived); |
| 1227 | } else if (incomingPacket[0] == PACKET_HEADER_VOXEL_DATA || | 1208 | break; |
| 1228 | incomingPacket[0] == PACKET_HEADER_Z_COMMAND || | 1209 | case PACKET_HEADER_VOXEL_DATA: |
| 1229 | incomingPacket[0] == PACKET_HEADER_ERASE_VOXEL) { | 1210 | case PACKET_HEADER_Z_COMMAND: |
| 1230 | voxels.parseData(incomingPacket, bytesReceived); | 1211 | case PACKET_HEADER_ERASE_VOXEL: |
| 1231 | } else { | 1212 | voxels.parseData(incomingPacket, bytesReceived); |
| 1232 | agentList.processAgentData(&senderAddress, incomingPacket, bytesReceived); | 1213 | break; |
| 1214 | case PACKET_HEADER_HEAD_DATA: | ||
| 1215 | agentList.processBulkAgentData(&senderAddress, incomingPacket, bytesReceived, sizeof(float) * 11); | ||
| 1216 | break; | ||
| 1217 | default: | ||
| 1218 | agentList.processAgentData(&senderAddress, incomingPacket, bytesReceived); | ||
| 1219 | break; | ||
| 1233 | } | 1220 | } |
| 1234 | } | 1221 | } |
| 1235 | } | 1222 | } |
| 1236 | 1223 | ||
| 1224 | delete[] incomingPacket; | ||
| 1237 | pthread_exit(0); | 1225 | pthread_exit(0); |
| 1238 | return NULL; | 1226 | return NULL; |
| 1239 | } | 1227 | } |
| @@ -1401,9 +1389,10 @@ int main(int argc, const char * argv[]) · 161 unmodified lines | |||
| 1401 | int wsaresult = WSAStartup( MAKEWORD(2,2), &WsaData ); | 1389 | int wsaresult = WSAStartup( MAKEWORD(2,2), &WsaData ); |
| 1402 | #endif | 1390 | #endif |
| 1403 | 1391 | ||
| 1404 | // start the thread which checks for silent agents | 1392 | // start the agentList threads |
| 1405 | agentList.startSilentAgentRemovalThread(); | 1393 | agentList.startSilentAgentRemovalThread(); |
| 1406 | agentList.startDomainServerCheckInThread(); | 1394 | agentList.startDomainServerCheckInThread(); |
| 1395 | agentList.startPingUnknownAgentsThread(); | ||
| 1407 | 1396 | ||
| 1408 | glutInit(&argc, (char**)argv); | 1397 | glutInit(&argc, (char**)argv); |
| 1409 | glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); | 1398 | glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); |