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
145145 glm::vec3 start_location(6.1f, 0, 1.4f);
146146
147147 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
149149 bool paintOn = false; // Whether to paint voxels as you fly around
150150 VoxelDetail paintingVoxel; // The voxel we're painting if we're painting
151151 unsigned char dominantColor = 0; // The dominant color of the voxel we're painting
152+bool perfStatsOn = false; // Do we want to display perfStats?
152153 int noise_on = 0; // Whether to add random noise
153154 float noise = 1.0; // Overall magnitude scaling for random noise levels
154155
@@ -259,7 +260,7 @@ void display_stats(void) · 104 unmodified lines
259260 char legend[] = "/ - toggle this display, Q - exit, H - show head, M - show hand, T - test audio";
260261 drawtext(10, 15, 0.10f, 0, 1.0, 0, legend);
261262
262− char legend2[] = "* - toggle stars, & - toggle paint mode";
263+ char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
263264 drawtext(10, 32, 0.10f, 0, 1.0, 0, legend2);
264265
265266 glm::vec3 headPos = myHead.getPos();
@@ -286,18 +287,45 @@ void display_stats(void) · 20 unmodified lines
286287 voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered();
287288 drawtext(10,70,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
288289
289− // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups
290− char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1];
291− int lines = PerfStat::DumpStats(perfStatLinesArray);
292− int atZ = 150; // arbitrary place on screen that looks good
293− for (int line=0; line < lines; line++) {
294− drawtext(10,atZ,0.10f, 0, 1.0, 0, perfStatLinesArray[line]);
295− delete perfStatLinesArray[line]; // we're responsible for cleanup
296− perfStatLinesArray[line]=NULL;
297− atZ+=20; // height of a line
298− }
299− delete []perfStatLinesArray; // we're responsible for cleanup
300−
290+ voxelStats.str("");
291+ voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() << " (" << voxels.getVoxelsCreatedRunningAverage()
292+ << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) ";
293+ drawtext(10,250,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
294+
295+ voxelStats.str("");
296+ voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() << " (" << voxels.getVoxelsColoredRunningAverage()
297+ << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) ";
298+ drawtext(10,270,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
299+
300+ voxelStats.str("");
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+
301329 /*
302330 std::stringstream angles;
303331 angles << "render_yaw: " << myHead.getRenderYaw() << ", Yaw: " << myHead.getYaw();
@@ -513,9 +541,10 @@ void simulateHead(float frametime) · 209 unmodified lines
513541
514542 glm::vec3 headPos = myHead.getPos();
515543
516− ::paintingVoxel.x = headPos.z/-10.0; // voxel space x is negative z head space
517− ::paintingVoxel.y = headPos.y/-10.0; // voxel space y is negative y head space
518− ::paintingVoxel.z = headPos.x/-10.0; // voxel space z is negative x head space
544+ // For some reason, we don't want to flip X and Z here.
545+ ::paintingVoxel.x = headPos.x/-10.0;
546+ ::paintingVoxel.y = headPos.y/-10.0;
547+ ::paintingVoxel.z = headPos.z/-10.0;
519548
520549 unsigned char* bufferOut;
521550 int sizeOut;
@@ -774,6 +803,20 @@ void testPointToVoxel() · 252 unmodified lines
774803 }
775804 }
776805
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+
777820 void shiftPaintingColor()
778821 {
779822 // 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
883926 if (k == '*') ::starsOn = !::starsOn; // toggle stars
884927 if (k == '&') {
885928 ::paintOn = !::paintOn; // toggle paint
886− setupPaintingVoxel(); // also randomizes colors
887− }
888− if (k == '^') {
889− shiftPaintingColor(); // shifts randomize color between R,G,B dominant
929+ ::setupPaintingVoxel(); // also randomizes colors
890930 }
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
891934 if (k == 'n')
892935 {
893936 noise_on = !noise_on; // Toggle noise
@@ -963,7 +1006,7 @@ void *networkReceive(void *args) · 69 unmodified lines
9631006 if (incomingPacket[0] == 't') {
9641007 // Pass everything but transmitter data to the agent list
9651008 myHead.hand->processTransmitterData(incomingPacket, bytesReceived);
966− } else if (incomingPacket[0] == 'V' || incomingPacket[0] == 'R') {
1009+ } else if (incomingPacket[0] == 'V' || incomingPacket[0] == 'Z') {
9671010 voxels.parseData(incomingPacket, bytesReceived);
9681011 } else {
9691012 agentList.processAgentData(&senderAddress, incomingPacket, bytesReceived);