diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 2 | ||||
| -rw-r--r-- | src/testApp.cpp | 64 | ||||
| -rw-r--r-- | src/testApp.h | 4 |
3 files changed, 59 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp index ad74a97..5e84581 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(&window, 450,800, OF_WINDOW ); // <-------- setup the GL context + ofSetupOpenGL(&window, 720,400, OF_WINDOW ); // <-------- setup the GL context printf("%ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight()); // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN diff --git a/src/testApp.cpp b/src/testApp.cpp index 3b0b9b1..ae42217 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -35,6 +35,18 @@ function to interpolate position */ +std::vector<std::string> split(std::string l, char delim) +{ + std::istringstream stm(l); + std::vector<std::string> tokens; + for (;;) { + std::string word; + if (!getline(stm, word, delim)) break; + tokens.push_back(word); + } + return tokens; +} + void testApp::setup(){ printf("setup: %ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight()); @@ -59,7 +71,7 @@ void testApp::setup(){ camera.cacheMatrices(); //stop error messages */ - ofSetFrameRate(60); + ofSetFrameRate(25); ofSetCircleResolution(windowWidth); ofEnableSmoothing(); @@ -69,7 +81,7 @@ void testApp::setup(){ camera.setFov(6.5); camera.cacheMatrices(); - numLines=20; + numLines=100; lines = new ofPoint[numLines]; imeis = new string[numLines]; @@ -83,6 +95,9 @@ void testApp::setup(){ } } + start=10; + end=15; + bgimg.allocate(256,256,OF_IMAGE_COLOR); @@ -129,17 +144,33 @@ void testApp::setup(){ //-------------------------------------------------------------- void testApp::update(){ - char udpMessage[1024]; + //check incoming messages + //create device or update as necessary + char udpMessage[1024]; udpConnection.Receive(udpMessage,1024); string message=udpMessage; - if(message!=""){ - printf("%s\n",message.c_str()); + if(message.length()){ + vector<string> tokens=split(message,','); + string imsi=tokens[0].substr(4); + //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")) { //not an event + if (!devices.count(imsi)) { + //create a new device at a random position + float a=ofRandom(TWO_PI); + float r=ofRandom(windowWidth/2); + devices[imsi]=obtsDevice(imsi,icons,ofVec2f(a,r)); + } + printf("%s\n",imsi.c_str()); + } + else printf("%s\n",tokens[0].c_str()); } - } //-------------------------------------------------------------- void testApp::draw(){ + if (ofRandom(1.0)>0.99) start=min(99,start+1); + if (ofRandom(1.0)>0.98) end=min(99,end+1); + glDisable(GL_LIGHTING); bgimg.draw(0,0,windowWidth,windowHeight); @@ -166,32 +197,45 @@ void testApp::draw(){ } - for (int i=0;i<numLines;i++) { + /* + for (int i=start;i<end;i++) { float rf=sin((lines[i].y/(windowWidth*0.9))*TWO_PI); ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf); ofLine(cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,0,cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,lines[i].z); } - ofPopMatrix(); - camera.end(); - for (int i=0;i<numLines;i++) { + + for (int i=start;i<end;i++) { float rf=sin((lines[i].y/(windowWidth*0.9))*TWO_PI); ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf); ofVec3f p=camera.worldToScreen(ofVec3f(cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,lines[i].z).rotated(ofGetElapsedTimef(),ofVec3f(0,0,1)),ofGetCurrentViewport()); ofDrawBitmapString(imeis[i],p.x-20,p.y,p.z); } + */ + float timeScale=windowHeight/ofGetElapsedTimef(); + + for (map<string,obtsDevice>::iterator i=devices.begin();i!=devices.end();i++){ + (*i).second.draw(timeScale); + } + + ofPopMatrix(); + camera.end(); ofSetHexColor(0xffffff); char reportStr[1024]; sprintf(reportStr, "fps: %f", ofGetFrameRate()); ofDrawBitmapString(reportStr, 10, windowHeight-10); + + //ofSaveFrame(); } //-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key){ case ' ': + ofSaveFrame(); + printf("[%8.2f] saved an image\n",ofGetElapsedTimef()); break; } } diff --git a/src/testApp.h b/src/testApp.h index bb7e6b1..29c9d03 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -25,10 +25,14 @@ class testApp : public ofBaseApp{ ofxUDPManager udpConnection; ofCamera camera; + + map<string,obtsDevice> devices; int numLines; ofPoint *lines; string *imeis; + + int start,end; ofImage bgimg; ofColor *cols; |
