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