diff options
| -rw-r--r-- | src/obtsDevice.cpp | 19 | ||||
| -rw-r--r-- | src/obtsDevice.h | 2 | ||||
| -rw-r--r-- | src/testApp.cpp | 34 | ||||
| -rw-r--r-- | src/testApp.h | 3 |
4 files changed, 39 insertions, 19 deletions
diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp index 85d5f18..c8255b4 100644 --- a/src/obtsDevice.cpp +++ b/src/obtsDevice.cpp @@ -13,7 +13,7 @@ obtsDevice::obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVe icon=_icon;
active=false;
calling=false;
- exciteLevel=1.0;
+ exciteLevel=0.99;
lastTime=ofGetElapsedTimef();
printf("new device: IMSI%s\n",IMSI.c_str());
}
@@ -76,7 +76,7 @@ void obtsDevice::excite(float amount) { void obtsDevice::draw(float timeScale)
{
- float decay=1.0;
+ float decay=2.0;
float now=ofGetElapsedTimef();
float timeSeg=now-lastTime;
lastTime=now;
@@ -91,21 +91,21 @@ void obtsDevice::draw(float timeScale) ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
float endPos;
for (vector<timeseg>::iterator i=connectionHistory.begin();i!=connectionHistory.end();i++){
- float startPos=((*i).startTime-now)/timeScale;
- endPos=(*i).endTime>0.0f?((*i).endTime-now)/timeScale:0.0f;
+ float startPos=((*i).startTime-now)*timeScale;
+ endPos=(*i).endTime>0.0f?((*i).endTime-now)*timeScale:0.0f;
ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
//printf("%f drawing %f,%f,%f to %f,%f,%f\n",ofGetElapsedTimef(),cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
}
ofSetColor(0xff,0x8f,0x8f);
for (vector<tsms>::iterator i=smsHistory.begin();i!=smsHistory.end();i++){
- float timepos=((*i).time-now)/timeScale;
+ float timepos=((*i).time-now)*timeScale;
ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,timepos,cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,timepos);
}
for (vector<tcall>::iterator i=callHistory.begin();i!=callHistory.end();i++){
- ofSetColor(0xff,0xff,0x8f);
- float stimepos=((*i).startTime-now)/timeScale;
- float etimepos=((*i).endTime>0.0f?((*i).endTime-now)/timeScale:0.0f);
+ ofSetColor(0xff,0xff,0x8f,0x7f);
+ float stimepos=((*i).startTime-now)*timeScale;
+ float etimepos=((*i).endTime>0.0f?((*i).endTime-now)*timeScale:0.0f);
glBegin(GL_QUADS);
glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,stimepos);
glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,stimepos);
@@ -115,7 +115,8 @@ void obtsDevice::draw(float timeScale) }
int greylev=0x7f+((int)(128.0f*exciteLevel));
- ofSetHexColor(greylev+(greylev<<8)+(greylev<<16));
+ //printf("%s %i\n",number.c_str(),greylev);
+ ofSetColor(greylev,greylev,greylev,0xff);
ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
ofDrawBitmapString(number,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE);
diff --git a/src/obtsDevice.h b/src/obtsDevice.h index b300d64..33c130e 100644 --- a/src/obtsDevice.h +++ b/src/obtsDevice.h @@ -77,7 +77,7 @@ class obtsDevice void connectCall();
void endCall();
void sms(obtsDevice *to);
- void excite(float amount=1.0);
+ void excite(float amount=0.99);
protected:
private:
float exciteLevel;
diff --git a/src/testApp.cpp b/src/testApp.cpp index 3ce4f36..cc15122 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -127,9 +127,12 @@ void testApp::setup(){ udpConnection.Bind(7888); udpConnection.SetNonBlocking(true); - string def="default"; + string def=""; devices["base"]=obtsDevice(def,def,def,icons,ofVec2f(0,0)); + + message=""; + messageTime=0.0f; } @@ -184,11 +187,14 @@ void testApp::update(){ */ char udpMessage[1024]; udpConnection.Receive(udpMessage,1024); - string message=udpMessage; - if(message.length()){ - vector<string> tokens=split(message,','); + string mess=udpMessage; + if(mess.length()){ + messageTime=ofGetElapsedTimef(); + printf("%s\n",mess.c_str()); + vector<string> tokens=split(mess,','); //long dev=atol(n.c_str()); something crazy going on. this always seems to read out 32 bits if (!tokens[0].substr(0,4).compare("IMSI")) { //this is an event + message=tokens[0]+" "+tokens[3]; string number=tokens[2]; if (!devices.count(number)) { string imei=string(tokens[1]); @@ -199,7 +205,6 @@ void testApp::update(){ devices[number]=obtsDevice(imsi,imei,number,icons,ofVec2f(a,r)); } devices[number].excite(); //whenever an event concerns a device it brightens - if(tokens[3].find("joined network")!=string::npos) devices[number].connect(); if(tokens[3].find("leaving network")!=string::npos) devices[number].disconnect(); if(tokens[3].find("queued")!=string::npos) { @@ -235,7 +240,6 @@ void testApp::update(){ } - else printf("%s\n",tokens[0].c_str()); } } @@ -245,6 +249,7 @@ void testApp::draw(){ ofSetLineWidth(1.5f); glDisable(GL_LIGHTING); + ofSetHexColor(0xffffff); bgimg.draw(0,0,windowWidth,windowHeight); camera.begin(); @@ -285,7 +290,7 @@ void testApp::draw(){ ofDrawBitmapString(imeis[i],p.x-20,p.y,p.z); } */ - float timeScale=windowHeight/ofGetElapsedTimef(); + float timeScale=windowHeight/ofGetElapsedTimef(); //pixels per second for (map<string,obtsDevice>::iterator i=devices.begin();i!=devices.end();i++){ (*i).second.draw(timeScale); @@ -296,9 +301,20 @@ void testApp::draw(){ ofSetHexColor(0xffffff); char reportStr[1024]; - sprintf(reportStr, "fps: %f", ofGetFrameRate()); - ofDrawBitmapString(reportStr, 10, windowHeight-10); + sprintf(reportStr, "fps: %3.0f", ofGetFrameRate()); + ofDrawBitmapString(reportStr, windowWidth-70, 12); + + int amt=255-((ofGetElapsedTimef()-messageTime)*25.0f); + if (amt>0) { + //ofEnableAlphaBlending(); + ofSetColor(amt,amt,amt); + sprintf(reportStr, "%s", message.c_str()); + ofDrawBitmapString(reportStr, 10, windowHeight-10); + //ofDisableAlphaBlending(); + } + + //ofSaveFrame(); } diff --git a/src/testApp.h b/src/testApp.h index cfb6f0a..cbcb8b0 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -32,6 +32,9 @@ class testApp : public ofBaseApp{ ofColor *cols; ofImage *icons; + + string message; + float messageTime; }; |
