History

Merge remote-tracking branch 'upstream/master'

Philip Rosedale committed 13 years ago

Commit f4f8a4e2 parents 2179932 60c37f048 files · +406 −508Browse files

Showing the changes to interface/src/main.cpp (1 of 48 files). Show all

Unified · Split

interface/src/main.cpp+26−17
@@ -228,7 +228,7 @@ void displayStats(void) · 227 unmodified lines
228228 char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
229229 drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
230230
231− glm::vec3 avatarPos = myAvatar.getPos();
231+ glm::vec3 avatarPos = myAvatar.getBodyPosition();
232232
233233 char stats[200];
234234 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
309309 if (noiseOn) {
310310 myAvatar.setNoise(noise);
311311 }
312− myAvatar.setPos(start_location );
312+ myAvatar.setBodyPosition(start_location);
313313 myCamera.setPosition( start_location );
314314
315315
@@ -351,7 +351,7 @@ void reset_sensors() · 35 unmodified lines
351351
352352 renderYawRate = 0;
353353 renderPitchRate = 0;
354− myAvatar.setPos(start_location);
354+ myAvatar.setBodyPosition(start_location);
355355 headMouseX = WIDTH/2;
356356 headMouseY = HEIGHT/2;
357357
@@ -449,8 +449,10 @@ void updateAvatar(float frametime) · 91 unmodified lines
449449 #endif
450450
451451 // Send my stream of head/hand data to the avatar mixer and voxel server
452− char broadcastString[200];
453− int broadcastBytes = myAvatar.getBroadcastData(broadcastString);
452+ unsigned char broadcastString[200];
453+ *broadcastString = PACKET_HEADER_HEAD_DATA;
454+
455+ int broadcastBytes = myAvatar.getBroadcastData(broadcastString + 1);
454456 const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER};
455457
456458 AgentList::getInstance()->broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers, 2);
@@ -458,7 +460,7 @@ void updateAvatar(float frametime) · 1 unmodified line
458460 // If I'm in paint mode, send a voxel out to VOXEL server agents.
459461 if (::paintOn) {
460462
461− glm::vec3 avatarPos = myAvatar.getPos();
463+ glm::vec3 avatarPos = myAvatar.getBodyPosition();
462464
463465 // For some reason, we don't want to flip X and Z here.
464466 ::paintingVoxel.x = avatarPos.x/10.0;
@@ -473,7 +475,7 @@ void updateAvatar(float frametime) · 8 unmodified lines
473475 ::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) {
474476
475477 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);
477479 delete bufferOut;
478480 }
479481 }
@@ -700,11 +702,13 @@ void display(void) · 220 unmodified lines
700702 //--------------------------------------------------------
701703 // camera settings
702704 //--------------------------------------------------------
705+ myCamera.setTargetPosition( myAvatar.getBodyPosition() );
706+
703707 if ( displayHead ) {
704708 //-----------------------------------------------
705709 // set the camera to looking at my own face
706710 //-----------------------------------------------
707− myCamera.setTargetPosition ( myAvatar.getPos() );
711+ myCamera.setTargetPosition ( myAvatar.getBodyPosition() );
708712 myCamera.setYaw ( - myAvatar.getBodyYaw() );
709713 myCamera.setPitch ( 0.0 );
710714 myCamera.setRoll ( 0.0 );
@@ -716,7 +720,7 @@ void display(void) · 5 unmodified lines
716720 //----------------------------------------------------
717721 // set the camera to third-person view behind my av
718722 //----------------------------------------------------
719− myCamera.setTargetPosition ( myAvatar.getPos() );
723+ myCamera.setTargetPosition ( myAvatar.getBodyPosition() );
720724 myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() );
721725 myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
722726 myCamera.setRoll ( 0.0 );
@@ -815,7 +819,7 @@ void display(void) · 92 unmodified lines
815819 if (agent->getLinkedData() != NULL) {
816820 Head *agentHead = (Head *)agent->getLinkedData();
817821 glPushMatrix();
818− glm::vec3 pos = agentHead->getPos();
822+ glm::vec3 pos = agentHead->getBodyPosition();
819823 glTranslatef(-pos.x, -pos.y, -pos.z);
820824 agentHead->render(0, 0);
821825 glPopMatrix();
@@ -905,9 +909,11 @@ void display(void) · 83 unmodified lines
905909
906910 // If application has just started, report time from startup to now (first frame display)
907911 if (justStarted) {
908− printf("Startup Time: %4.2f\n",
909− (usecTimestampNow() - usecTimestamp(&applicationStartupTime))/1000000.0);
912+ float startupTime = (usecTimestampNow() - usecTimestamp(&applicationStartupTime))/1000000.0;
910913 justStarted = false;
914+ char title[30];
915+ snprintf(title, 30, "Interface: %4.2f seconds", startupTime);
916+ glutSetWindowTitle(title);
911917 }
912918 }
913919
@@ -1087,14 +1093,14 @@ void sendVoxelServerEraseAll() { · 173 unmodified lines
10871093 char message[100];
10881094 sprintf(message,"%c%s",'Z',"erase all");
10891095 int messageSize = strlen(message) + 1;
1090− AgentList::getInstance()->broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1);
1091−}
1096+ AgentList::getInstance()->broadcastToAgents((unsigned char*) message, messageSize, &AGENT_TYPE_VOXEL, 1);
1097+}\
10921098
10931099 void sendVoxelServerAddScene() {
10941100 char message[100];
10951101 sprintf(message,"%c%s",'Z',"add scene");
10961102 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);
10981104 }
10991105
11001106 void shiftPaintingColor()
@@ -1107,7 +1113,7 @@ void shiftPaintingColor() · 6 unmodified lines
11071113 }
11081114
11091115 void setupPaintingVoxel() {
1110− glm::vec3 avatarPos = myAvatar.getPos();
1116+ glm::vec3 avatarPos = myAvatar.getBodyPosition();
11111117
11121118 ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space
11131119 ::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
12801286 {
12811287 sockaddr senderAddress;
12821288 ssize_t bytesReceived;
1283− char *incomingPacket = new char[MAX_PACKET_SIZE];
1289+ unsigned char *incomingPacket = new unsigned char[MAX_PACKET_SIZE];
12841290
12851291 while (!stopNetworkReceiveThread) {
12861292 if (AgentList::getInstance()->getAgentSocket().receive(&senderAddress, incomingPacket, &bytesReceived)) {
@@ -1525,6 +1531,9 @@ int main(int argc, const char * argv[]) · 238 unmodified lines
15251531 AgentList::getInstance()->startPingUnknownAgentsThread();
15261532
15271533 glutInit(&argc, (char**)argv);
1534+ WIDTH = glutGet(GLUT_SCREEN_WIDTH);
1535+ HEIGHT = glutGet(GLUT_SCREEN_HEIGHT);
1536+
15281537 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
15291538 glutInitWindowSize(WIDTH, HEIGHT);
15301539 glutCreateWindow("Interface");