History

Merge remote-tracking branch 'origin'

Jeffrey Ventrella committed 13 years ago

Commit 191ee712 parents cd1533d 6f8808e11 files · +435 −28Browse files

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

Unified · Split

interface/src/main.cpp+65−22
@@ -145,10 +145,11 @@ float renderPitchRate = 0.f; · 144 unmodified lines
145glm::vec3 start_location(6.1f, 0, 1.4f);145glm::vec3 start_location(6.1f, 0, 1.4f);
146 146
147int stats_on = 0; // Whether to show onscreen text overlay with stats147int stats_on = 0; // Whether to show onscreen text overlay with stats
148bool starsOn = true; // Whether to display the stars148bool starsOn = false; // Whether to display the stars
149bool paintOn = false; // Whether to paint voxels as you fly around149bool paintOn = false; // Whether to paint voxels as you fly around
150VoxelDetail paintingVoxel; // The voxel we're painting if we're painting150VoxelDetail paintingVoxel; // The voxel we're painting if we're painting
151unsigned char dominantColor = 0; // The dominant color of the voxel we're painting151unsigned char dominantColor = 0; // The dominant color of the voxel we're painting
152bool perfStatsOn = false; // Do we want to display perfStats?
152int noise_on = 0; // Whether to add random noise 153int noise_on = 0; // Whether to add random noise
153float noise = 1.0; // Overall magnitude scaling for random noise levels 154float 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+groups290 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 good293 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 cleanup296 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 line298 drawtext(10,270,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
298 }299
299 delete []perfStatLinesArray; // we're responsible for cleanup300 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 space544 // 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 space545 ::paintingVoxel.x = headPos.x/-10.0;
518 ::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space546 ::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
806void 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
813void 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
777void shiftPaintingColor()820void shiftPaintingColor()
778{821{
779 // About the color of the paintbrush... first determine the dominant color822 // 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 stars926 if (k == '*') ::starsOn = !::starsOn; // toggle stars
884 if (k == '&') {927 if (k == '&') {
885 ::paintOn = !::paintOn; // toggle paint928 ::paintOn = !::paintOn; // toggle paint
886 setupPaintingVoxel(); // also randomizes colors929 ::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 list1007 // 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);