From 834821d005cbe0bd57638dec6f741d208fe1d596 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 18:25:54 -0700 Subject: [PATCH 1/4] Removed the lattice object --- interface/src/Lattice.cpp | 106 -------------------------------------- interface/src/Lattice.h | 39 -------------- interface/src/main.cpp | 15 ++---- 3 files changed, 5 insertions(+), 155 deletions(-) delete mode 100644 interface/src/Lattice.cpp delete mode 100644 interface/src/Lattice.h diff --git a/interface/src/Lattice.cpp b/interface/src/Lattice.cpp deleted file mode 100644 index 10a11b8763..0000000000 --- a/interface/src/Lattice.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -// Lattice.cpp -// interface -// -// Created by Philip on 1/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#include "Lattice.h" - -Lattice::Lattice(int w, int h) { - width = w; - height = h; - tilegap = 2; - lastindex = -1; - tiles = new Tile[width*height]; - for (int i = 0; i < (width*height); i++) { - tiles[i].color[0] = tiles[i].color[1] = tiles[i].color[2] = 0.2f + randFloat()*0.3f; - tiles[i].x = static_cast(i % width); - tiles[i].y = static_cast(i/width); - tiles[i].brightness = 1.0; - tiles[i].type = 0; - tiles[i].excited = tiles[i].inhibited = 0.0; - } -} - -void Lattice::render(int screenWidth, int screenHeight) { - float tilewidth = static_cast(screenWidth/width); - float tileheight = static_cast(screenHeight/height); - float tilecolor[3]; - glBegin(GL_QUADS); - for (int i = 0; i < (width*height); i++) { - if (tiles[i].type == 0) { - tilecolor[0] = 0.25; tilecolor[1] = 0.25; tilecolor[2] = 0.25; - } else if (tiles[i].type == 1) { - if (tiles[i].inhibited >= 0.1) { - tilecolor[0] = 0.5f; tilecolor[1] = 0.0; tilecolor[2] = 0.0; - } else { - tilecolor[0] = 0.2f; tilecolor[1] = 0.0; tilecolor[2] = 0.5f; - } - } - glColor3f(tilecolor[0]*(1.f+tiles[i].excited), tilecolor[1]*(1.f+tiles[i].excited), tilecolor[2]*(1.f+tiles[i].excited)); - glVertex2f(tiles[i].x*tilewidth, tiles[i].y*tileheight); - glVertex2f((tiles[i].x + 1)*tilewidth - tilegap, tiles[i].y*tileheight); - glVertex2f((tiles[i].x + 1)*tilewidth - tilegap, (tiles[i].y + 1)*tileheight - tilegap); - glVertex2f(tiles[i].x*tilewidth, (tiles[i].y + 1)*tileheight - tilegap); - } - glEnd(); -} - -void Lattice::mouseClick(float x, float y) { - // Update lattice based on mouse location, where x and y are floats between 0 and 1 corresponding to screen location clicked - // Change the clicked cell to a different type - //printf("X = %3.1f Y = %3.1f\n", x, y); - int index = int(x*(float)width) + int(y*(float)height)*width; - if (index != lastindex) { - tiles[index].type++; - if (tiles[index].type == 2) tiles[index].type = 0; - lastindex = index; - } -} - -void Lattice::mouseOver(float x, float y) { - // Update lattice based on mouse location, where x and y are floats between 0 and 1 corresponding to screen location clicked - // Excite the hovered cell a bit toward firing - //printf("X = %3.1f Y = %3.1f\n", x, y); - if (0) { - int index = int(x*(float)width) + int(y*(float)height)*width; - if (tiles[index].type > 0) tiles[index].excited += 0.05f; - //printf("excited = %3.1f, inhibited = %3.1f\n", tiles[index].excited, tiles[index].inhibited); - } -} - -void Lattice::simulate(float deltaTime) { - int index; - for (int i = 0; i < (width*height); i++) { - if (tiles[i].type > 0) { - if ((tiles[i].excited > 0.5) && (tiles[i].inhibited < 0.1)) { - tiles[i].excited = 1.0; - tiles[i].inhibited = 1.0; - // Add Energy to neighbors - for (int j = 0; j < 8; j++) { - if (j == 0) index = i - width - 1; - else if (j == 1) index = i - width; - else if (j == 2) index = i - width + 1; - else if (j == 3) index = i - 1; - else if (j == 4) index = i + 1; - else if (j == 5) index = i + width - 1; - else if (j == 6) index = i + width; - else index = i + width + 1; - if ((index > 0) && (index < width*height)) { - if (tiles[index].inhibited < 0.1) tiles[index].excited += 0.5; - } - - } - } - tiles[i].excited *= 0.98f; - tiles[i].inhibited *= 0.98f; - } - } -} - - - - - diff --git a/interface/src/Lattice.h b/interface/src/Lattice.h deleted file mode 100644 index 82d56cc7ae..0000000000 --- a/interface/src/Lattice.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Lattice.h -// interface -// -// Created by Philip on 1/19/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#ifndef __interface__Lattice__ -#define __interface__Lattice__ - -#include -#include "Util.h" -#include "world.h" -#include "InterfaceConfig.h" -#include - -class Lattice { -public: - Lattice(int width, int height); - void simulate(float deltaTime); - void render(int screenWidth, int screenHeight); - void mouseClick(float x, float y); - void mouseOver(float x, float y); -private: - int lastindex; - int width, height; - int tilegap; - struct Tile { - float x,y; - float color[3]; - float brightness; - float excited; - float inhibited; - int type; - } *tiles; -}; - -#endif /* defined(__interface__lattice__) */ diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 3953a657f1..de5a731a39 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -69,7 +69,6 @@ #include #include #include "VoxelSystem.h" -#include "Lattice.h" #include "Finger.h" #include "Oscilloscope.h" #include "UDPSocket.h" @@ -130,7 +129,6 @@ Cloud cloud(0, // Particles VoxelSystem voxels; -Lattice lattice(160,100); Finger myFinger(WIDTH, HEIGHT); Field field; @@ -337,6 +335,8 @@ void init(void) } myAvatar.setPos(start_location ); myCamera.setPosition( start_location ); + + myFinger.setTarget(WIDTH/2, HEIGHT/2); #ifdef MARKER_CAPTURE if(marker_capture_enabled){ @@ -793,8 +793,8 @@ void display(void) glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); - //lattice.render(WIDTH, HEIGHT); - //myFinger.render(); + myFinger.render(); + #ifndef _WIN32 audio.render(WIDTH, HEIGHT); if (audioScope.getState()) audioScope.render(); @@ -1198,7 +1198,6 @@ void idle(void) myAvatar.simulate(1.f/FPS); balls.simulate(1.f/FPS); cloud.simulate(1.f/FPS); - lattice.simulate(1.f/FPS); myFinger.simulate(1.f/FPS); glutPostRedisplay(); @@ -1242,7 +1241,6 @@ void mouseFunc( int button, int state, int x, int y ) mouseX = x; mouseY = y; mousePressed = 1; - lattice.mouseClick((float)x/(float)WIDTH, (float)y/(float)HEIGHT); mouseStartX = x; mouseStartY = y; } @@ -1259,8 +1257,6 @@ void motionFunc( int x, int y) { mouseX = x; mouseY = y; - - lattice.mouseClick((float)x/(float)WIDTH,(float)y/(float)HEIGHT); } void mouseoverFunc( int x, int y) @@ -1270,8 +1266,7 @@ void mouseoverFunc( int x, int y) mouseY = y; if (mousePressed == 0) { -// lattice.mouseOver((float)x/(float)WIDTH,(float)y/(float)HEIGHT); -// myFinger.setTarget(mouseX, mouseY); + myFinger.setTarget(mouseX, mouseY); } } From 5ea6a9a69680b34fe636e41113c4e031b40d4252 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 18:57:09 -0700 Subject: [PATCH 2/4] Add little balls to the end of the world coordinate axis markers when shown --- interface/src/Util.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index fdd207ce48..3d58c6faa5 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -80,6 +80,23 @@ void render_world_box() glVertex3f(0,0,0); glVertex3f(0, 0, WORLD_SIZE); glEnd(); + // Draw little marker dots along the axis + glEnable(GL_LIGHTING); + glPushMatrix(); + glTranslatef(WORLD_SIZE,0,0); + glColor3f(1,0,0); + glutSolidSphere(0.125,10,10); + glPopMatrix(); + glPushMatrix(); + glTranslatef(0,WORLD_SIZE,0); + glColor3f(0,1,0); + glutSolidSphere(0.125,10,10); + glPopMatrix(); + glPushMatrix(); + glTranslatef(0,0,WORLD_SIZE); + glColor3f(0,0,1); + glutSolidSphere(0.125,10,10); + glPopMatrix(); } double diffclock(timeval *clock1,timeval *clock2) From e0a704935d282a815dbb54be555865575ca27ff9 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 10 Apr 2013 19:08:22 -0700 Subject: [PATCH 3/4] made display a bit cleaner --- interface/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index de5a731a39..59aac4c447 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -250,7 +250,7 @@ void displayStats(void) glm::vec3 avatarPos = myAvatar.getPos(); char stats[200]; - sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )", + sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)= %4.2f, %4.2f, %4.2f ", FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z); drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats); if (serialPort.active) { From 407da2aea8610f161cab31e727588b7f7aa676cf Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 11 Apr 2013 00:11:31 -0700 Subject: [PATCH 4/4] Added a startup timer --- interface/src/main.cpp | 13 ++++++++++++- shared/src/AgentList.cpp | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 0a356d746a..74987ba10f 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -196,6 +196,9 @@ float FPS = 120.f; timeval timerStart, timerEnd; timeval lastTimeIdle; double elapsedTime; +timeval applicationStartupTime; +bool justStarted = true; + #ifdef MARKER_CAPTURE @@ -783,7 +786,7 @@ void display(void) float sphereRadius = 0.25f; glColor3f(1,0,0); glPushMatrix(); - glTranslatef( 0.0f, sphereRadius, 0.0f ); + //glTranslatef( 0.0f, sphereRadius, 0.0f ); glutSolidSphere( sphereRadius, 15, 15 ); glPopMatrix(); @@ -915,6 +918,13 @@ void display(void) glutSwapBuffers(); frameCount++; + + // If application has just started, report time from startup to now (first frame display) + if (justStarted) { + printf("Startup Time: %4.2f\n", + (usecTimestampNow() - usecTimestamp(&applicationStartupTime))/1000000.0); + justStarted = false; + } } int setValue(int state, int *value) { @@ -1349,6 +1359,7 @@ void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort) { int main(int argc, const char * argv[]) { + gettimeofday(&applicationStartupTime, NULL); const char* domainIP = getCmdOption(argc, argv, "--domain"); if (domainIP) { strcpy(DOMAIN_IP,domainIP); diff --git a/shared/src/AgentList.cpp b/shared/src/AgentList.cpp index 1add03d6ff..ce4dc21223 100644 --- a/shared/src/AgentList.cpp +++ b/shared/src/AgentList.cpp @@ -327,7 +327,7 @@ void *checkInWithDomainServer(void *args) { sockaddr_in tempAddress; memcpy(&tempAddress.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length); strcpy(DOMAIN_IP, inet_ntoa(tempAddress.sin_addr)); - printf("Domain server %s: \n", DOMAIN_HOSTNAME); + printf("Domain server: %s \n", DOMAIN_HOSTNAME); } else { printf("Failed lookup domainserver\n");