Showing the changes to interface/src/main.cpp (1 of 11 files). Show all
Unified · Split
| @@ -145,10 +145,11 @@ float renderPitchRate = 0.f; · 144 unmodified lines | |||
| 145 | glm::vec3 start_location(6.1f, 0, 1.4f); | 145 | glm::vec3 start_location(6.1f, 0, 1.4f); |
| 146 | 146 | ||
| 147 | int stats_on = 0; // Whether to show onscreen text overlay with stats | 147 | int stats_on = 0; // Whether to show onscreen text overlay with stats |
| 148 | bool starsOn = true; // Whether to display the stars | 148 | bool starsOn = false; // Whether to display the stars |
| 149 | bool paintOn = false; // Whether to paint voxels as you fly around | 149 | bool paintOn = false; // Whether to paint voxels as you fly around |
| 150 | VoxelDetail paintingVoxel; // The voxel we're painting if we're painting | 150 | VoxelDetail paintingVoxel; // The voxel we're painting if we're painting |
| 151 | unsigned char dominantColor = 0; // The dominant color of the voxel we're painting | 151 | unsigned char dominantColor = 0; // The dominant color of the voxel we're painting |
| 152 | bool perfStatsOn = false; // Do we want to display perfStats? | ||
| 152 | int noise_on = 0; // Whether to add random noise | 153 | int noise_on = 0; // Whether to add random noise |
| 153 | float noise = 1.0; // Overall magnitude scaling for random noise levels | 154 | float noise = 1.0; // Overall magnitude scaling for random noise levels |
| 154 | 155 | ||
| @@ -259,7 +260,7 @@ void display_stats(void) · 104 unmodified lines | |||
| 259 | char legend[] = "/ - toggle this display, Q - exit, H - show head, M - show hand, T - test audio"; | 260 | char legend[] = "/ - toggle this display, Q - exit, H - show head, M - show hand, T - test audio"; |
| 260 | drawtext(10, 15, 0.10f, 0, 1.0, 0, legend); | 261 | drawtext(10, 15, 0.10f, 0, 1.0, 0, legend); |
| 261 | 262 | ||
| 262 | char legend2[] = "* - toggle stars, & - toggle paint mode"; | 263 | char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene"; |
| 263 | drawtext(10, 32, 0.10f, 0, 1.0, 0, legend2); | 264 | drawtext(10, 32, 0.10f, 0, 1.0, 0, legend2); |
| 264 | 265 | ||
| 265 | glm::vec3 headPos = myHead.getPos(); | 266 | glm::vec3 headPos = myHead.getPos(); |
| @@ -286,18 +287,45 @@ void display_stats(void) · 20 unmodified lines | |||
| 286 | voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered(); | 287 | voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered(); |
| 287 | drawtext(10,70,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | 288 | drawtext(10,70,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 288 | 289 | ||
| 289 | // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups | 290 | voxelStats.str(""); |
| 290 | char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; | 291 | voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() << " (" << voxels.getVoxelsCreatedRunningAverage() |
| 291 | int lines = PerfStat::DumpStats(perfStatLinesArray); | 292 | << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; |
| 292 | int atZ = 150; // arbitrary place on screen that looks good | 293 | drawtext(10,250,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 293 | for (int line=0; line < lines; line++) { | 294 | |
| 294 | drawtext(10,atZ,0.10f, 0, 1.0, 0, perfStatLinesArray[line]); | 295 | voxelStats.str(""); |
| 295 | delete perfStatLinesArray[line]; // we're responsible for cleanup | 296 | voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() << " (" << voxels.getVoxelsColoredRunningAverage() |
| 296 | perfStatLinesArray[line]=NULL; | 297 | << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; |
| 297 | atZ+=20; // height of a line | 298 | drawtext(10,270,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); |
| 298 | } | 299 | |
| 299 | delete []perfStatLinesArray; // we're responsible for cleanup | 300 | voxelStats.str(""); |
| 300 | 301 | voxelStats << "Voxels Bytes Read: " << voxels.getVoxelsBytesRead() | |
| 302 | << " (" << voxels.getVoxelsBytesReadRunningAverage() << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; | ||
| 303 | drawtext(10,290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | ||
| 304 | |||
| 305 | voxelStats.str(""); | ||
| 306 | long int voxelsBytesPerColored = voxels.getVoxelsColored() ? voxels.getVoxelsBytesRead()/voxels.getVoxelsColored() : 0; | ||
| 307 | long int voxelsBytesPerColoredAvg = voxels.getVoxelsColoredRunningAverage() ? | ||
| 308 | voxels.getVoxelsBytesReadRunningAverage()/voxels.getVoxelsColoredRunningAverage() : 0; | ||
| 309 | |||
| 310 | voxelStats << "Voxels Bytes per Colored: " << voxelsBytesPerColored | ||
| 311 | << " (" << voxelsBytesPerColoredAvg << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; | ||
| 312 | drawtext(10,310,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); | ||
| 313 | |||
| 314 | |||
| 315 | if (::perfStatsOn) { | ||
| 316 | // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups | ||
| 317 | char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; | ||
| 318 | int lines = PerfStat::DumpStats(perfStatLinesArray); | ||
| 319 | int atZ = 150; // arbitrary place on screen that looks good | ||
| 320 | for (int line=0; line < lines; line++) { | ||
| 321 | drawtext(10,atZ,0.10f, 0, 1.0, 0, perfStatLinesArray[line]); | ||
| 322 | delete perfStatLinesArray[line]; // we're responsible for cleanup | ||
| 323 | perfStatLinesArray[line]=NULL; | ||
| 324 | atZ+=20; // height of a line | ||
| 325 | } | ||
| 326 | delete []perfStatLinesArray; // we're responsible for cleanup | ||
| 327 | } | ||
| 328 | |||
| 301 | /* | 329 | /* |
| 302 | std::stringstream angles; | 330 | std::stringstream angles; |
| 303 | angles << "render_yaw: " << myHead.getRenderYaw() << ", Yaw: " << myHead.getYaw(); | 331 | angles << "render_yaw: " << myHead.getRenderYaw() << ", Yaw: " << myHead.getYaw(); |
| @@ -513,9 +541,10 @@ void simulateHead(float frametime) · 209 unmodified lines | |||
| 513 | 541 | ||
| 514 | glm::vec3 headPos = myHead.getPos(); | 542 | glm::vec3 headPos = myHead.getPos(); |
| 515 | 543 | ||
| 516 | ::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space | 544 | // For some reason, we don't want to flip X and Z here. |
| 517 | ::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space | 545 | ::paintingVoxel.x = headPos.x/-10.0; |
| 518 | ::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space | 546 | ::paintingVoxel.y = headPos.y/-10.0; |
| 547 | ::paintingVoxel.z = headPos.z/-10.0; | ||
| 519 | 548 | ||
| 520 | unsigned char* bufferOut; | 549 | unsigned char* bufferOut; |
| 521 | int sizeOut; | 550 | int sizeOut; |
| @@ -774,6 +803,20 @@ void testPointToVoxel() · 252 unmodified lines | |||
| 774 | } | 803 | } |
| 775 | } | 804 | } |
| 776 | 805 | ||
| 806 | void sendVoxelServerEraseAll() { | ||
| 807 | char message[100]; | ||
| 808 | sprintf(message,"%c%s",'Z',"erase all"); | ||
| 809 | int messageSize = strlen(message)+1; | ||
| 810 | ::agentList.broadcastToAgents(message, messageSize,AgentList::AGENTS_OF_TYPE_VOXEL); | ||
| 811 | } | ||
| 812 | |||
| 813 | void sendVoxelServerAddScene() { | ||
| 814 | char message[100]; | ||
| 815 | sprintf(message,"%c%s",'Z',"add scene"); | ||
| 816 | int messageSize = strlen(message)+1; | ||
| 817 | ::agentList.broadcastToAgents(message, messageSize,AgentList::AGENTS_OF_TYPE_VOXEL); | ||
| 818 | } | ||
| 819 | |||
| 777 | void shiftPaintingColor() | 820 | void shiftPaintingColor() |
| 778 | { | 821 | { |
| 779 | // About the color of the paintbrush... first determine the dominant color | 822 | // About the color of the paintbrush... first determine the dominant color |
| @@ -883,11 +926,11 @@ void key(unsigned char k, int x, int y) · 103 unmodified lines | |||
| 883 | if (k == '*') ::starsOn = !::starsOn; // toggle stars | 926 | if (k == '*') ::starsOn = !::starsOn; // toggle stars |
| 884 | if (k == '&') { | 927 | if (k == '&') { |
| 885 | ::paintOn = !::paintOn; // toggle paint | 928 | ::paintOn = !::paintOn; // toggle paint |
| 886 | setupPaintingVoxel(); // also randomizes colors | 929 | ::setupPaintingVoxel(); // also randomizes colors |
| 887 | } | ||
| 888 | if (k == '^') { | ||
| 889 | shiftPaintingColor(); // shifts randomize color between R,G,B dominant | ||
| 890 | } | 930 | } |
| 931 | if (k == '^') ::shiftPaintingColor(); // shifts randomize color between R,G,B dominant | ||
| 932 | if (k == '-') ::sendVoxelServerEraseAll(); // sends erase all command to voxel server | ||
| 933 | if (k == '%') ::sendVoxelServerAddScene(); // sends add scene command to voxel server | ||
| 891 | if (k == 'n') | 934 | if (k == 'n') |
| 892 | { | 935 | { |
| 893 | noise_on = !noise_on; // Toggle noise | 936 | noise_on = !noise_on; // Toggle noise |
| @@ -963,7 +1006,7 @@ void *networkReceive(void *args) · 69 unmodified lines | |||
| 963 | if (incomingPacket[0] == 't') { | 1006 | if (incomingPacket[0] == 't') { |
| 964 | // Pass everything but transmitter data to the agent list | 1007 | // Pass everything but transmitter data to the agent list |
| 965 | myHead.hand->processTransmitterData(incomingPacket, bytesReceived); | 1008 | myHead.hand->processTransmitterData(incomingPacket, bytesReceived); |
| 966 | } else if (incomingPacket[0] == 'V' || incomingPacket[0] == 'R') { | 1009 | } else if (incomingPacket[0] == 'V' || incomingPacket[0] == 'Z') { |
| 967 | voxels.parseData(incomingPacket, bytesReceived); | 1010 | voxels.parseData(incomingPacket, bytesReceived); |
| 968 | } else { | 1011 | } else { |
| 969 | agentList.processAgentData(&senderAddress, incomingPacket, bytesReceived); | 1012 | agentList.processAgentData(&senderAddress, incomingPacket, bytesReceived); |