/
ofxThermitrackPoints.h
executable file
·89 lines (71 loc) · 2.28 KB
/
ofxThermitrackPoints.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
Thermitrack Camera addon
http://www.thermitrack.com
v1.5
May 2011
*/
/*
#ifndef _OFX_THERMITRACK_POINT
#define _OFX_THERMITRACK_POINT
class ofxThermitrackPoint{
public:
ofxThermitrackPoint();
~ofxThermitrackPoint();
irisysTrackPoint(){
timeBorn = ofGetElapsedTimeMillis();
maxHistorySize = 50;
}
~irisysTrackPoint(){
}
void draw(int x, int y){
int arrowsize = 3;
char tstring[300];
ofSetColor(0,255,0);
ofNoFill();
glPushMatrix();
glTranslatef( x, y, 0.0 );
// arrow
ofLine(pos.x-arrowsize, pos.y, pos.x+arrowsize, pos.y);
ofLine(pos.x, pos.y-arrowsize, pos.x, pos.y+arrowsize);
// id
sprintf(tstring, "%i", (int)id);
ofDrawBitmapString(tstring, pos.x, pos.y + 12);
// age
sprintf(tstring, "%i", (int)(millisAge/1000.0));
ofDrawBitmapString(tstring, pos.x, pos.y + 22);
// history
ofEnableAlphaBlending();
ofSetColor(0,255,0, 200);
int histSize = posHistory.size();
if(histSize > 2){
for(int i=0; i<histSize-1; i++){
ofLine(posHistory[i].x, posHistory[i].y, posHistory[i+1].x, posHistory[i+1].y);
}
}
ofDisableAlphaBlending();
glPopMatrix();
}
void update(ofxPoint2f newpos){
int now = ofGetElapsedTimeMillis();
millisAge = now - timeBorn;
// push current pos into history
if(posHistory.size() < maxHistorySize){
posHistory.push_back( pos );
}else{
for(int i=0; i<posHistory.size()-1; i++){
posHistory[i] = posHistory[i+1];
}
posHistory[maxHistorySize-1] = pos;
}
// update current pos
pos = newpos;
}
int id;
ofxPoint2f pos;
ofxPoint2f posNormalised;
vector <ofxPoint2f> posHistory;
int timeBorn;
int millisAge;
int maxHistorySize;
};
*/