|
21
|
1 |
/* |
|
|
2 |
TUIO C++ Library - part of the reacTIVision project |
|
|
3 |
http://reactivision.sourceforge.net/ |
|
|
4 |
|
|
|
5 |
Copyright (c) 2005-2008 Martin Kaltenbrunner <mkalten@iua.upf.edu> |
|
|
6 |
|
|
|
7 |
This program is free software; you can redistribute it and/or modify |
|
|
8 |
it under the terms of the GNU General Public License as published by |
|
|
9 |
the Free Software Foundation; either version 2 of the License, or |
|
|
10 |
(at your option) any later version. |
|
|
11 |
|
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
15 |
GNU General Public License for more details. |
|
|
16 |
|
|
|
17 |
You should have received a copy of the GNU General Public License |
|
|
18 |
along with this program; if not, write to the Free Software |
|
|
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
20 |
*/ |
|
|
21 |
|
|
|
22 |
#ifndef INCLUDED_TUIOCONTAINER_H |
|
|
23 |
#define INCLUDED_TUIOCONTAINER_H |
|
|
24 |
|
|
|
25 |
#include <list> |
|
|
26 |
#include <math.h> |
|
|
27 |
#include "TuioPoint.h" |
|
|
28 |
#include <iostream> |
|
|
29 |
|
|
|
30 |
#define TUIO_ADDED 0 |
|
|
31 |
#define TUIO_UPDATED 1 |
|
|
32 |
#define TUIO_REMOVED 2 |
|
|
33 |
|
|
|
34 |
class TuioContainer: public TuioPoint { |
|
|
35 |
|
|
|
36 |
protected: |
|
|
37 |
long session_id; |
|
24
|
38 |
float xpos, ypos, zpos; |
|
21
|
39 |
float x_speed, y_speed; |
|
|
40 |
float motion_speed, motion_accel; |
|
|
41 |
std::list<TuioPoint> path; |
|
|
42 |
|
|
|
43 |
int state; |
|
|
44 |
|
|
|
45 |
public: |
|
|
46 |
TuioContainer (long s_id, float xpos, float ypos):TuioPoint(xpos,ypos) { |
|
|
47 |
this->session_id = s_id; |
|
|
48 |
this->x_speed = 0.0f; |
|
|
49 |
this->y_speed = 0.0f; |
|
|
50 |
this->motion_speed = 0.0f; |
|
|
51 |
this->motion_accel = 0.0f; |
|
|
52 |
TuioPoint p(xpos,ypos); |
|
|
53 |
path.push_back(p); |
|
|
54 |
|
|
|
55 |
state = TUIO_ADDED; |
|
|
56 |
}; |
|
|
57 |
|
|
24
|
58 |
/* |
|
|
59 |
* Surcharg� par alexandre.bastien@iri.centrepompidou.fr |
|
|
60 |
*/ |
|
|
61 |
TuioContainer (long s_id, float xpos, float ypos, float zpos):TuioPoint(xpos,ypos,zpos) { |
|
|
62 |
this->session_id = s_id; |
|
|
63 |
this->x_speed = 0.0f; |
|
|
64 |
this->y_speed = 0.0f; |
|
|
65 |
this->motion_speed = 0.0f; |
|
|
66 |
this->motion_accel = 0.0f; |
|
|
67 |
TuioPoint p(xpos,ypos,zpos); |
|
|
68 |
path.push_back(p); |
|
|
69 |
|
|
|
70 |
state = TUIO_ADDED; |
|
|
71 |
}; |
|
|
72 |
|
|
|
73 |
/* |
|
|
74 |
* Modifi� par alexandre.bastien@iri.centrepompidou.fr |
|
|
75 |
*/ |
|
21
|
76 |
TuioContainer (TuioContainer *tuioContainer):TuioPoint(tuioContainer) { |
|
|
77 |
this->session_id = tuioContainer->getSessionID(); |
|
|
78 |
this->x_speed = 0.0f; |
|
|
79 |
this->y_speed = 0.0f; |
|
|
80 |
this->motion_speed = 0.0f; |
|
|
81 |
this->motion_accel = 0.0f; |
|
24
|
82 |
TuioPoint p(xpos,ypos,zpos); |
|
21
|
83 |
path.push_back(p); |
|
|
84 |
|
|
|
85 |
state = TUIO_ADDED; |
|
|
86 |
}; |
|
|
87 |
|
|
|
88 |
virtual ~TuioContainer(){}; |
|
|
89 |
|
|
|
90 |
virtual void update (float xpos, float ypos,float xspeed, float yspeed,float maccel) { |
|
|
91 |
TuioPoint::update(xpos, ypos); |
|
|
92 |
this->x_speed = xspeed; |
|
|
93 |
this->y_speed = yspeed; |
|
|
94 |
this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed); |
|
|
95 |
this->motion_accel = maccel; |
|
|
96 |
TuioPoint p(xpos,ypos); |
|
|
97 |
path.push_back(p); |
|
|
98 |
|
|
|
99 |
state = TUIO_UPDATED; |
|
|
100 |
}; |
|
|
101 |
|
|
24
|
102 |
/* |
|
|
103 |
* Surcharg� par alexandre.bastien@iri.centrepompidou.fr |
|
|
104 |
*/ |
|
|
105 |
virtual void update (float xpos, float ypos, float zpos, float xspeed, float yspeed,float maccel) { |
|
|
106 |
TuioPoint::update(xpos, ypos, zpos); |
|
|
107 |
this->x_speed = xspeed; |
|
|
108 |
this->y_speed = yspeed; |
|
|
109 |
this->motion_speed = (float)sqrt(xspeed*xspeed+yspeed*yspeed); |
|
|
110 |
this->motion_accel = maccel; |
|
|
111 |
TuioPoint p(xpos,ypos,zpos); |
|
|
112 |
path.push_back(p); |
|
|
113 |
|
|
|
114 |
state = TUIO_UPDATED; |
|
|
115 |
}; |
|
|
116 |
|
|
|
117 |
/* |
|
|
118 |
* Modifi� par alexandre.bastien@iri.centrepompidou.fr |
|
|
119 |
*/ |
|
21
|
120 |
virtual void update (TuioContainer *tuioContainer) { |
|
|
121 |
TuioPoint::update(tuioContainer); |
|
|
122 |
this->x_speed = tuioContainer->getXSpeed(); |
|
|
123 |
this->y_speed = tuioContainer->getYSpeed(); |
|
|
124 |
this->motion_speed = tuioContainer->getMotionSpeed(); |
|
|
125 |
this->motion_accel = tuioContainer->getMotionAccel(); |
|
24
|
126 |
TuioPoint p(xpos,ypos,zpos); |
|
21
|
127 |
path.push_back(p); |
|
|
128 |
|
|
|
129 |
state = TUIO_UPDATED; |
|
|
130 |
}; |
|
|
131 |
|
|
|
132 |
virtual long getSessionID() { return session_id; }; |
|
24
|
133 |
|
|
|
134 |
/* |
|
|
135 |
* Modifi� par alexandre.bastien@iri.centrepompidou.fr |
|
|
136 |
*/ |
|
21
|
137 |
virtual TuioPoint getPosition() { |
|
24
|
138 |
TuioPoint p(xpos,ypos,zpos); |
|
21
|
139 |
return p; |
|
|
140 |
}; |
|
|
141 |
|
|
|
142 |
virtual std::list<TuioPoint> getPath() { |
|
|
143 |
return path; |
|
|
144 |
}; |
|
|
145 |
|
|
|
146 |
virtual void remove() { |
|
|
147 |
state = TUIO_REMOVED; |
|
|
148 |
timestamp = TUIO_UNDEFINED; |
|
|
149 |
} |
|
|
150 |
|
|
|
151 |
virtual float getXSpeed() { return x_speed; }; |
|
|
152 |
virtual float getYSpeed() { return y_speed; }; |
|
|
153 |
virtual float getMotionSpeed() { return motion_speed; }; |
|
|
154 |
virtual float getMotionAccel() { return motion_accel; }; |
|
|
155 |
|
|
|
156 |
virtual int getState() { return state; }; |
|
|
157 |
virtual void setUpdateTime(long timestamp) { |
|
|
158 |
this->timestamp = timestamp; |
|
|
159 |
TuioPoint *lastPoint = &path.back(); |
|
|
160 |
if (lastPoint!=NULL) lastPoint->setUpdateTime(timestamp); |
|
|
161 |
}; |
|
|
162 |
|
|
|
163 |
}; |
|
|
164 |
|
|
|
165 |
#endif |