Showing the changes to interface/src/main.cpp (1 of 48 files). Show all
Unified · Split
| @@ -228,7 +228,7 @@ void displayStats(void) · 227 unmodified lines | |||
| 228 | char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene"; | 228 | char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene"; |
| 229 | drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2); | 229 | drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2); |
| 230 | 230 | ||
| 231 | glm::vec3 avatarPos = myAvatar.getPos(); | 231 | glm::vec3 avatarPos = myAvatar.getBodyPosition(); |
| 232 | 232 | ||
| 233 | char stats[200]; | 233 | char stats[200]; |
| 234 | sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ", | 234 | sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ", |
| @@ -309,7 +309,7 @@ void init(void) · 74 unmodified lines | |||
| 309 | if (noiseOn) { | 309 | if (noiseOn) { |
| 310 | myAvatar.setNoise(noise); | 310 | myAvatar.setNoise(noise); |
| 311 | } | 311 | } |
| 312 | myAvatar.setPos(start_location ); | 312 | myAvatar.setBodyPosition(start_location); |
| 313 | myCamera.setPosition( start_location ); | 313 | myCamera.setPosition( start_location ); |
| 314 | 314 | ||
| 315 | 315 | ||
| @@ -351,7 +351,7 @@ void reset_sensors() · 35 unmodified lines | |||
| 351 | 351 | ||
| 352 | renderYawRate = 0; | 352 | renderYawRate = 0; |
| 353 | renderPitchRate = 0; | 353 | renderPitchRate = 0; |
| 354 | myAvatar.setPos(start_location); | 354 | myAvatar.setBodyPosition(start_location); |
| 355 | headMouseX = WIDTH/2; | 355 | headMouseX = WIDTH/2; |
| 356 | headMouseY = HEIGHT/2; | 356 | headMouseY = HEIGHT/2; |
| 357 | 357 | ||
| @@ -449,8 +449,10 @@ void updateAvatar(float frametime) · 91 unmodified lines | |||
| 449 | #endif | 449 | #endif |
| 450 | 450 | ||
| 451 | // Send my stream of head/hand data to the avatar mixer and voxel server | 451 | // Send my stream of head/hand data to the avatar mixer and voxel server |
| 452 | char broadcastString[200]; | 452 | unsigned char broadcastString[200]; |
| 453 | int broadcastBytes = myAvatar.getBroadcastData(broadcastString); | 453 | *broadcastString = PACKET_HEADER_HEAD_DATA; |
| 454 | |||
| 455 | int broadcastBytes = myAvatar.getBroadcastData(broadcastString + 1); | ||
| 454 | const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER}; | 456 | const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER}; |
| 455 | 457 | ||
| 456 | AgentList::getInstance()->broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers, 2); | 458 | AgentList::getInstance()->broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers, 2); |
| @@ -458,7 +460,7 @@ void updateAvatar(float frametime) · 1 unmodified line | |||
| 458 | // If I'm in paint mode, send a voxel out to VOXEL server agents. | 460 | // If I'm in paint mode, send a voxel out to VOXEL server agents. |
| 459 | if (::paintOn) { | 461 | if (::paintOn) { |
| 460 | 462 | ||
| 461 | glm::vec3 avatarPos = myAvatar.getPos(); | 463 | glm::vec3 avatarPos = myAvatar.getBodyPosition(); |
| 462 | 464 | ||
| 463 | // For some reason, we don't want to flip X and Z here. | 465 | // For some reason, we don't want to flip X and Z here. |
| 464 | ::paintingVoxel.x = avatarPos.x/10.0; | 466 | ::paintingVoxel.x = avatarPos.x/10.0; |
| @@ -473,7 +475,7 @@ void updateAvatar(float frametime) · 8 unmodified lines | |||
| 473 | ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) { | 475 | ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) { |
| 474 | 476 | ||
| 475 | if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){ | 477 | if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){ |
| 476 | AgentList::getInstance()->broadcastToAgents((char*)bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1); | 478 | AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1); |
| 477 | delete bufferOut; | 479 | delete bufferOut; |
| 478 | } | 480 | } |
| 479 | } | 481 | } |
| @@ -700,11 +702,13 @@ void display(void) · 220 unmodified lines | |||
| 700 | //-------------------------------------------------------- | 702 | //-------------------------------------------------------- |
| 701 | // camera settings | 703 | // camera settings |
| 702 | //-------------------------------------------------------- | 704 | //-------------------------------------------------------- |
| 705 | myCamera.setTargetPosition( myAvatar.getBodyPosition() ); | ||
| 706 | |||
| 703 | if ( displayHead ) { | 707 | if ( displayHead ) { |
| 704 | //----------------------------------------------- | 708 | //----------------------------------------------- |
| 705 | // set the camera to looking at my own face | 709 | // set the camera to looking at my own face |
| 706 | //----------------------------------------------- | 710 | //----------------------------------------------- |
| 707 | myCamera.setTargetPosition ( myAvatar.getPos() ); | 711 | myCamera.setTargetPosition ( myAvatar.getBodyPosition() ); |
| 708 | myCamera.setYaw ( - myAvatar.getBodyYaw() ); | 712 | myCamera.setYaw ( - myAvatar.getBodyYaw() ); |
| 709 | myCamera.setPitch ( 0.0 ); | 713 | myCamera.setPitch ( 0.0 ); |
| 710 | myCamera.setRoll ( 0.0 ); | 714 | myCamera.setRoll ( 0.0 ); |
| @@ -716,7 +720,7 @@ void display(void) · 5 unmodified lines | |||
| 716 | //---------------------------------------------------- | 720 | //---------------------------------------------------- |
| 717 | // set the camera to third-person view behind my av | 721 | // set the camera to third-person view behind my av |
| 718 | //---------------------------------------------------- | 722 | //---------------------------------------------------- |
| 719 | myCamera.setTargetPosition ( myAvatar.getPos() ); | 723 | myCamera.setTargetPosition ( myAvatar.getBodyPosition() ); |
| 720 | myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); | 724 | myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() ); |
| 721 | myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju | 725 | myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju |
| 722 | myCamera.setRoll ( 0.0 ); | 726 | myCamera.setRoll ( 0.0 ); |
| @@ -815,7 +819,7 @@ void display(void) · 92 unmodified lines | |||
| 815 | if (agent->getLinkedData() != NULL) { | 819 | if (agent->getLinkedData() != NULL) { |
| 816 | Head *agentHead = (Head *)agent->getLinkedData(); | 820 | Head *agentHead = (Head *)agent->getLinkedData(); |
| 817 | glPushMatrix(); | 821 | glPushMatrix(); |
| 818 | glm::vec3 pos = agentHead->getPos(); | 822 | glm::vec3 pos = agentHead->getBodyPosition(); |
| 819 | glTranslatef(-pos.x, -pos.y, -pos.z); | 823 | glTranslatef(-pos.x, -pos.y, -pos.z); |
| 820 | agentHead->render(0, 0); | 824 | agentHead->render(0, 0); |
| 821 | glPopMatrix(); | 825 | glPopMatrix(); |
| @@ -905,9 +909,11 @@ void display(void) · 83 unmodified lines | |||
| 905 | 909 | ||
| 906 | // If application has just started, report time from startup to now (first frame display) | 910 | // If application has just started, report time from startup to now (first frame display) |
| 907 | if (justStarted) { | 911 | if (justStarted) { |
| 908 | printf("Startup Time: %4.2f\n", | 912 | float startupTime = (usecTimestampNow() - usecTimestamp(&applicationStartupTime))/1000000.0; |
| 909 | (usecTimestampNow() - usecTimestamp(&applicationStartupTime))/1000000.0); | ||
| 910 | justStarted = false; | 913 | justStarted = false; |
| 914 | char title[30]; | ||
| 915 | snprintf(title, 30, "Interface: %4.2f seconds", startupTime); | ||
| 916 | glutSetWindowTitle(title); | ||
| 911 | } | 917 | } |
| 912 | } | 918 | } |
| 913 | 919 | ||
| @@ -1087,14 +1093,14 @@ void sendVoxelServerEraseAll() { · 173 unmodified lines | |||
| 1087 | char message[100]; | 1093 | char message[100]; |
| 1088 | sprintf(message,"%c%s",'Z',"erase all"); | 1094 | sprintf(message,"%c%s",'Z',"erase all"); |
| 1089 | int messageSize = strlen(message) + 1; | 1095 | int messageSize = strlen(message) + 1; |
| 1090 | AgentList::getInstance()->broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1); | 1096 | AgentList::getInstance()->broadcastToAgents((unsigned char*) message, messageSize, &AGENT_TYPE_VOXEL, 1); |
| 1091 | } | 1097 | }\ |
| 1092 | 1098 | ||
| 1093 | void sendVoxelServerAddScene() { | 1099 | void sendVoxelServerAddScene() { |
| 1094 | char message[100]; | 1100 | char message[100]; |
| 1095 | sprintf(message,"%c%s",'Z',"add scene"); | 1101 | sprintf(message,"%c%s",'Z',"add scene"); |
| 1096 | int messageSize = strlen(message) + 1; | 1102 | int messageSize = strlen(message) + 1; |
| 1097 | AgentList::getInstance()->broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1); | 1103 | AgentList::getInstance()->broadcastToAgents((unsigned char*)message, messageSize, &AGENT_TYPE_VOXEL, 1); |
| 1098 | } | 1104 | } |
| 1099 | 1105 | ||
| 1100 | void shiftPaintingColor() | 1106 | void shiftPaintingColor() |
| @@ -1107,7 +1113,7 @@ void shiftPaintingColor() · 6 unmodified lines | |||
| 1107 | } | 1113 | } |
| 1108 | 1114 | ||
| 1109 | void setupPaintingVoxel() { | 1115 | void setupPaintingVoxel() { |
| 1110 | glm::vec3 avatarPos = myAvatar.getPos(); | 1116 | glm::vec3 avatarPos = myAvatar.getBodyPosition(); |
| 1111 | 1117 | ||
| 1112 | ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space | 1118 | ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space |
| 1113 | ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space | 1119 | ::paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space |
| @@ -1280,7 +1286,7 @@ void *networkReceive(void *args) · 166 unmodified lines | |||
| 1280 | { | 1286 | { |
| 1281 | sockaddr senderAddress; | 1287 | sockaddr senderAddress; |
| 1282 | ssize_t bytesReceived; | 1288 | ssize_t bytesReceived; |
| 1283 | char *incomingPacket = new char[MAX_PACKET_SIZE]; | 1289 | unsigned char *incomingPacket = new unsigned char[MAX_PACKET_SIZE]; |
| 1284 | 1290 | ||
| 1285 | while (!stopNetworkReceiveThread) { | 1291 | while (!stopNetworkReceiveThread) { |
| 1286 | if (AgentList::getInstance()->getAgentSocket().receive(&senderAddress, incomingPacket, &bytesReceived)) { | 1292 | if (AgentList::getInstance()->getAgentSocket().receive(&senderAddress, incomingPacket, &bytesReceived)) { |
| @@ -1525,6 +1531,9 @@ int main(int argc, const char * argv[]) · 238 unmodified lines | |||
| 1525 | AgentList::getInstance()->startPingUnknownAgentsThread(); | 1531 | AgentList::getInstance()->startPingUnknownAgentsThread(); |
| 1526 | 1532 | ||
| 1527 | glutInit(&argc, (char**)argv); | 1533 | glutInit(&argc, (char**)argv); |
| 1534 | WIDTH = glutGet(GLUT_SCREEN_WIDTH); | ||
| 1535 | HEIGHT = glutGet(GLUT_SCREEN_HEIGHT); | ||
| 1536 | |||
| 1528 | glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); | 1537 | glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); |
| 1529 | glutInitWindowSize(WIDTH, HEIGHT); | 1538 | glutInitWindowSize(WIDTH, HEIGHT); |
| 1530 | glutCreateWindow("Interface"); | 1539 | glutCreateWindow("Interface"); |