From 5fb03da0c11eb42d425974a145ffa4cf3edc82a7 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 27 Jun 2012 09:41:39 +0100 Subject: fps thing --- src/obtsDevice.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/obtsDevice.cpp (limited to 'src/obtsDevice.cpp') diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp new file mode 100644 index 0000000..70e60c3 --- /dev/null +++ b/src/obtsDevice.cpp @@ -0,0 +1,47 @@ +#include "obtsDevice.h" + +obtsDevice::obtsDevice() +{ +} + +obtsDevice::obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords) +{ + IMSI=imsi; + coords=_coords; + icon=_icon; + connect(); + printf("new device: IMSI%s\n",IMSI.c_str()); +} + +void obtsDevice::connect(){ + connectionHistory.push_back(timeseg(ofGetElapsedTimef(),0.0f)); +} + +void obtsDevice::disconnect(){ + connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef(); +} + +obtsDevice::~obtsDevice() +{ + //dtor +} + +void obtsDevice::draw(float timeScale) +{ + //draw a line at the angular position of the device + //z=0 is the 'surface' i.e. now. + //the device know the time now and when it was created + //needs to know the time the app began in order to scale the line vertically + //dynamic scaling or fixed vertical scale? + //for dynamic, just scale vertically based on time + //for fixed/dynamic, pass a scaling parameter when drawing + float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI); + ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf); + float now=ofGetElapsedTimef(); + for (vector::iterator i=connectionHistory.begin();i!=connectionHistory.end();i++){ + float startPos=(-now+(*i).startTime)/timeScale; + float endPos=(*i).endTime>0.0f?(-now+(*i).endTime)/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); + } +} -- cgit v1.2.3