27 * |
27 * |
28 * @author Martin Kaltenbrunner |
28 * @author Martin Kaltenbrunner |
29 * @version 1.4 |
29 * @version 1.4 |
30 */ |
30 */ |
31 abstract class TuioContainer extends TuioPoint { |
31 abstract class TuioContainer extends TuioPoint { |
32 |
32 |
33 /** |
33 /** |
34 * The unique session ID number that is assigned to each TUIO object or cursor. |
34 * The unique session ID number that is assigned to each TUIO object or cursor. |
35 */ |
35 */ |
36 protected long session_id; |
36 protected long session_id; |
37 /** |
37 /** |
38 * The X-axis velocity value. |
38 * The X-axis velocity value. |
39 */ |
39 */ |
40 protected float x_speed; |
40 protected float x_speed; |
41 /** |
41 /** |
42 * The Y-axis velocity value. |
42 * The Y-axis velocity value. |
43 */ |
43 */ |
44 protected float y_speed; |
44 protected float y_speed; |
45 /** |
45 /** |
46 * The motion speed value. |
46 * The motion speed value. |
47 */ |
47 */ |
48 protected float motion_speed; |
48 protected float motion_speed; |
49 /** |
49 /** |
50 * The motion acceleration value. |
50 * The motion acceleration value. |
51 */ |
51 */ |
52 protected float motion_accel; |
52 protected float motion_accel; |
53 /** |
53 /** |
54 * A Vector of TuioPoints containing all the previous positions of the TUIO component. |
54 * A Vector of TuioPoints containing all the previous positions of the TUIO component. |
55 */ |
55 */ |
56 protected Vector<TuioPoint> path; |
56 protected Vector<TuioPoint> path; |
57 /** |
57 /** |
58 * Defines the ADDED state. |
58 * Defines the ADDED state. |
59 */ |
59 */ |
60 public static final int TUIO_ADDED = 0; |
60 public static final int TUIO_ADDED = 0; |
61 /** |
61 /** |
62 * Defines the ACCELERATING state. |
62 * Defines the ACCELERATING state. |
63 */ |
63 */ |
64 public static final int TUIO_ACCELERATING = 1; |
64 public static final int TUIO_ACCELERATING = 1; |
65 /** |
65 /** |
66 * Defines the DECELERATING state. |
66 * Defines the DECELERATING state. |
67 */ |
67 */ |
68 public static final int TUIO_DECELERATING = 2; |
68 public static final int TUIO_DECELERATING = 2; |
69 /** |
69 /** |
70 * Defines the STOPPED state. |
70 * Defines the STOPPED state. |
71 */ |
71 */ |
72 public static final int TUIO_STOPPED = 3; |
72 public static final int TUIO_STOPPED = 3; |
73 /** |
73 /** |
74 * Defines the REMOVED state. |
74 * Defines the REMOVED state. |
75 */ |
75 */ |
76 public static final int TUIO_REMOVED = 4; |
76 public static final int TUIO_REMOVED = 4; |
77 /** |
77 /** |
78 * Reflects the current state of the TuioComponent |
78 * Reflects the current state of the TuioComponent |
79 */ |
79 */ |
80 protected int state; |
80 protected int state; |
81 |
81 |
82 /** |
82 /** |
83 * This constructor takes a TuioTime argument and assigns it along with the provided |
83 * This constructor takes a TuioTime argument and assigns it along with the provided |
84 * Session ID, X and Y coordinate to the newly created TuioContainer. |
84 * Session ID, X and Y coordinate to the newly created TuioContainer. |
85 * |
85 * |
86 * @param ttime the TuioTime to assign |
86 * @param ttime the TuioTime to assign |
87 * @param si the Session ID to assign |
87 * @param si the Session ID to assign |
88 * @param xp the X coordinate to assign |
88 * @param xp the X coordinate to assign |
89 * @param yp the Y coordinate to assign |
89 * @param yp the Y coordinate to assign |
90 */ |
90 */ |
91 TuioContainer(TuioTime ttime, long si, float xp, float yp) { |
91 TuioContainer(TuioTime ttime, long si, float xp, float yp) { |
92 super(ttime,xp,yp); |
92 super(ttime,xp,yp); |
93 |
93 |
94 session_id = si; |
94 session_id = si; |
95 x_speed = 0.0f; |
95 x_speed = 0.0f; |
96 y_speed = 0.0f; |
96 y_speed = 0.0f; |
97 motion_speed = 0.0f; |
97 motion_speed = 0.0f; |
98 motion_accel = 0.0f; |
98 motion_accel = 0.0f; |
99 |
99 |
100 path = new Vector<TuioPoint>(); |
100 path = new Vector<TuioPoint>(); |
101 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
101 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
102 state = TUIO_ADDED; |
102 state = TUIO_ADDED; |
103 } |
103 } |
104 |
104 |
105 /** |
105 /** |
106 * This constructor takes a TuioTime argument and assigns it along with the provided |
106 * This constructor takes a TuioTime argument and assigns it along with the provided |
107 * Session ID, X, Y and Z coordinate to the newly created TuioContainer. |
107 * Session ID, X, Y and Z coordinate to the newly created TuioContainer. |
108 * |
108 * |
109 * @param ttime the TuioTime to assign |
109 * @param ttime the TuioTime to assign |
110 * @param si the Session ID to assign |
110 * @param si the Session ID to assign |
111 * @param xp the X coordinate to assign |
111 * @param xp the X coordinate to assign |
112 * @param yp the Y coordinate to assign |
112 * @param yp the Y coordinate to assign |
113 * @param zp the Z coordinate to assign |
113 * @param zp the Z coordinate to assign |
114 */ |
114 */ |
115 TuioContainer(TuioTime ttime, long si, float xp, float yp, float zp) { |
115 TuioContainer(TuioTime ttime, long si, float xp, float yp, float zp) { |
116 super(ttime,xp,yp, zp); |
116 super(ttime,xp,yp, zp); |
117 |
117 |
118 session_id = si; |
118 session_id = si; |
119 x_speed = 0.0f; |
119 x_speed = 0.0f; |
120 y_speed = 0.0f; |
120 y_speed = 0.0f; |
121 motion_speed = 0.0f; |
121 motion_speed = 0.0f; |
122 motion_accel = 0.0f; |
122 motion_accel = 0.0f; |
123 |
123 |
124 path = new Vector<TuioPoint>(); |
124 path = new Vector<TuioPoint>(); |
125 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
125 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
126 state = TUIO_ADDED; |
126 state = TUIO_ADDED; |
127 } |
127 } |
128 |
128 |
129 /** |
129 /** |
130 * This constructor takes the provided Session ID, X and Y coordinate |
130 * This constructor takes the provided Session ID, X and Y coordinate |
131 * and assigs these values to the newly created TuioContainer. |
131 * and assigs these values to the newly created TuioContainer. |
132 * |
132 * |
133 * @param si the Session ID to assign |
133 * @param si the Session ID to assign |
134 * @param xp the X coordinate to assign |
134 * @param xp the X coordinate to assign |
135 * @param yp the Y coordinate to assign |
135 * @param yp the Y coordinate to assign |
136 */ |
136 */ |
137 TuioContainer(long si, float xp, float yp) { |
137 TuioContainer(long si, float xp, float yp) { |
138 super(xp,yp); |
138 super(xp,yp); |
139 |
139 |
140 session_id = si; |
140 session_id = si; |
141 x_speed = 0.0f; |
141 x_speed = 0.0f; |
142 y_speed = 0.0f; |
142 y_speed = 0.0f; |
143 motion_speed = 0.0f; |
143 motion_speed = 0.0f; |
144 motion_accel = 0.0f; |
144 motion_accel = 0.0f; |
145 |
145 |
146 path = new Vector<TuioPoint>(); |
146 path = new Vector<TuioPoint>(); |
147 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
147 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
148 state = TUIO_ADDED; |
148 state = TUIO_ADDED; |
149 } |
149 } |
150 |
150 |
151 /** |
151 /** |
152 * This constructor takes the provided Session ID, X, Y and Z coordinate |
152 * This constructor takes the provided Session ID, X, Y and Z coordinate |
153 * and assigs these values to the newly created TuioContainer. |
153 * and assigs these values to the newly created TuioContainer. |
154 * |
154 * |
155 * @param si the Session ID to assign |
155 * @param si the Session ID to assign |
156 * @param xp the X coordinate to assign |
156 * @param xp the X coordinate to assign |
157 * @param yp the Y coordinate to assign |
157 * @param yp the Y coordinate to assign |
158 * @param zp the Z coordinate to assign |
158 * @param zp the Z coordinate to assign |
159 */ |
159 */ |
160 TuioContainer(long si, float xp, float yp, float zp) { |
160 TuioContainer(long si, float xp, float yp, float zp) { |
161 super(xp,yp,zp); |
161 super(xp,yp,zp); |
162 |
162 |
163 session_id = si; |
163 session_id = si; |
164 x_speed = 0.0f; |
164 x_speed = 0.0f; |
165 y_speed = 0.0f; |
165 y_speed = 0.0f; |
166 motion_speed = 0.0f; |
166 motion_speed = 0.0f; |
167 motion_accel = 0.0f; |
167 motion_accel = 0.0f; |
168 |
168 |
169 path = new Vector<TuioPoint>(); |
169 path = new Vector<TuioPoint>(); |
170 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
170 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
171 state = TUIO_ADDED; |
171 state = TUIO_ADDED; |
172 } |
172 } |
173 |
173 |
174 /** |
174 /** |
175 * This constructor takes the atttibutes of the provided TuioContainer |
175 * This constructor takes the atttibutes of the provided TuioContainer |
176 * and assigs these values to the newly created TuioContainer. |
176 * and assigs these values to the newly created TuioContainer. |
177 * |
177 * |
178 * @param tcon the TuioContainer to assign |
178 * @param tcon the TuioContainer to assign |
179 */ |
179 */ |
180 TuioContainer(TuioContainer tcon) { |
180 TuioContainer(TuioContainer tcon) { |
181 super(tcon); |
181 super(tcon); |
182 |
182 |
183 session_id = tcon.getSessionID(); |
183 session_id = tcon.getSessionID(); |
184 x_speed = 0.0f; |
184 x_speed = 0.0f; |
185 y_speed = 0.0f; |
185 y_speed = 0.0f; |
186 motion_speed = 0.0f; |
186 motion_speed = 0.0f; |
187 motion_accel = 0.0f; |
187 motion_accel = 0.0f; |
188 |
188 |
189 path = new Vector<TuioPoint>(); |
189 path = new Vector<TuioPoint>(); |
190 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
190 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
191 state = TUIO_ADDED; |
191 state = TUIO_ADDED; |
192 } |
192 } |
193 |
193 |
194 /** |
194 /** |
195 * Takes a TuioTime argument and assigns it along with the provided |
195 * Takes a TuioTime argument and assigns it along with the provided |
196 * X and Y coordinate to the private TuioContainer attributes. |
196 * X and Y coordinate to the private TuioContainer attributes. |
197 * The speed and accleration values are calculated accordingly. |
197 * The speed and accleration values are calculated accordingly. |
198 * |
198 * |
199 * @param ttime the TuioTime to assign |
199 * @param ttime the TuioTime to assign |
200 * @param xp the X coordinate to assign |
200 * @param xp the X coordinate to assign |
201 * @param yp the Y coordinate to assign |
201 * @param yp the Y coordinate to assign |
202 */ |
202 */ |
203 public void update(TuioTime ttime, float xp, float yp) { |
203 public void update(TuioTime ttime, float xp, float yp) { |
204 TuioPoint lastPoint = path.lastElement(); |
204 TuioPoint lastPoint = path.lastElement(); |
205 super.update(ttime,xp,yp); |
205 super.update(ttime,xp,yp); |
206 |
206 |
207 TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); |
207 TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); |
208 float dt = diffTime.getTotalMilliseconds()/1000.0f; |
208 float dt = diffTime.getTotalMilliseconds()/1000.0f; |
209 float dx = this.xpos - lastPoint.getX(); |
209 float dx = this.xpos - lastPoint.getX(); |
210 float dy = this.ypos - lastPoint.getY(); |
210 float dy = this.ypos - lastPoint.getY(); |
211 float dist = (float)Math.sqrt(dx*dx+dy*dy); |
211 float dist = (float)Math.sqrt(dx*dx+dy*dy); |
212 float last_motion_speed = this.motion_speed; |
212 float last_motion_speed = this.motion_speed; |
213 |
213 |
214 this.x_speed = dx/dt; |
214 this.x_speed = dx/dt; |
215 this.y_speed = dy/dt; |
215 this.y_speed = dy/dt; |
216 this.motion_speed = dist/dt; |
216 this.motion_speed = dist/dt; |
217 this.motion_accel = (motion_speed - last_motion_speed)/dt; |
217 this.motion_accel = (motion_speed - last_motion_speed)/dt; |
218 |
218 |
219 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
219 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
220 if (motion_accel>0) state = TUIO_ACCELERATING; |
220 if (motion_accel>0) state = TUIO_ACCELERATING; |
221 else if (motion_accel<0) state = TUIO_DECELERATING; |
221 else if (motion_accel<0) state = TUIO_DECELERATING; |
222 else state = TUIO_STOPPED; |
222 else state = TUIO_STOPPED; |
223 } |
223 } |
224 |
224 |
225 /** |
225 /** |
226 * Takes a TuioTime argument and assigns it along with the provided |
226 * Takes a TuioTime argument and assigns it along with the provided |
227 * X, Y and Z coordinate to the private TuioContainer attributes. |
227 * X, Y and Z coordinate to the private TuioContainer attributes. |
228 * The speed and accleration values are calculated accordingly. |
228 * The speed and accleration values are calculated accordingly. |
229 * |
229 * |
230 * @param ttime the TuioTime to assign |
230 * @param ttime the TuioTime to assign |
231 * @param xp the X coordinate to assign |
231 * @param xp the X coordinate to assign |
232 * @param yp the Y coordinate to assign |
232 * @param yp the Y coordinate to assign |
233 * @param zp the Z coordinate to assign |
233 * @param zp the Z coordinate to assign |
234 */ |
234 */ |
235 public void update(TuioTime ttime, float xp, float yp, float zp) { |
235 public void update(TuioTime ttime, float xp, float yp, float zp) { |
236 TuioPoint lastPoint = path.lastElement(); |
236 TuioPoint lastPoint = path.lastElement(); |
237 super.update(ttime,xp,yp,zp); |
237 super.update(ttime,xp,yp,zp); |
238 |
238 |
239 TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); |
239 TuioTime diffTime = currentTime.subtract(lastPoint.getTuioTime()); |
240 float dt = diffTime.getTotalMilliseconds()/1000.0f; |
240 float dt = diffTime.getTotalMilliseconds()/1000.0f; |
241 float dx = this.xpos - lastPoint.getX(); |
241 float dx = this.xpos - lastPoint.getX(); |
242 float dy = this.ypos - lastPoint.getY(); |
242 float dy = this.ypos - lastPoint.getY(); |
243 float dz = this.zpos - lastPoint.getZ(); |
243 float dz = this.zpos - lastPoint.getZ(); |
244 float dist = (float)Math.sqrt(dx*dx+dy*dy+dz*dz); |
244 float dist = (float)Math.sqrt(dx*dx+dy*dy+dz*dz); |
245 float last_motion_speed = this.motion_speed; |
245 float last_motion_speed = this.motion_speed; |
246 |
246 |
247 this.x_speed = dx/dt; |
247 this.x_speed = dx/dt; |
248 this.y_speed = dy/dt; |
248 this.y_speed = dy/dt; |
249 this.motion_speed = dist/dt; |
249 this.motion_speed = dist/dt; |
250 this.motion_accel = (motion_speed - last_motion_speed)/dt; |
250 this.motion_accel = (motion_speed - last_motion_speed)/dt; |
251 |
251 |
252 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
252 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
253 if (motion_accel>0) state = TUIO_ACCELERATING; |
253 if (motion_accel>0) state = TUIO_ACCELERATING; |
254 else if (motion_accel<0) state = TUIO_DECELERATING; |
254 else if (motion_accel<0) state = TUIO_DECELERATING; |
255 else state = TUIO_STOPPED; |
255 else state = TUIO_STOPPED; |
256 } |
256 } |
257 |
257 |
258 /** |
258 /** |
259 * This method is used to calculate the speed and acceleration values of |
259 * This method is used to calculate the speed and acceleration values of |
260 * TuioContainers with unchanged positions. |
260 * TuioContainers with unchanged positions. |
261 */ |
261 */ |
262 public void stop(TuioTime ttime) { |
262 public void stop(TuioTime ttime) { |
263 update(ttime,xpos,ypos,zpos); |
263 update(ttime,xpos,ypos,zpos); |
264 } |
264 } |
265 |
265 |
266 /** |
266 /** |
267 * Takes a TuioTime argument and assigns it along with the provided |
267 * Takes a TuioTime argument and assigns it along with the provided |
268 * X and Y coordinate, X and Y velocity and acceleration |
268 * X and Y coordinate, X and Y velocity and acceleration |
269 * to the private TuioContainer attributes. |
269 * to the private TuioContainer attributes. |
270 * |
270 * |
271 * @param ttime the TuioTime to assign |
271 * @param ttime the TuioTime to assign |
272 * @param xp the X coordinate to assign |
272 * @param xp the X coordinate to assign |
273 * @param yp the Y coordinate to assign |
273 * @param yp the Y coordinate to assign |
274 * @param xs the X velocity to assign |
274 * @param xs the X velocity to assign |
275 * @param ys the Y velocity to assign |
275 * @param ys the Y velocity to assign |
276 * @param ma the acceleration to assign |
276 * @param ma the acceleration to assign |
277 */ |
277 */ |
278 public void update(TuioTime ttime, float xp, float yp , float xs, float ys, float ma) { |
278 public void update(TuioTime ttime, float xp, float yp , float xs, float ys, float ma) { |
279 super.update(ttime,xp,yp); |
279 super.update(ttime,xp,yp); |
280 x_speed = xs; |
280 x_speed = xs; |
281 y_speed = ys; |
281 y_speed = ys; |
282 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
282 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
283 motion_accel = ma; |
283 motion_accel = ma; |
284 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
284 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
285 if (motion_accel>0) state = TUIO_ACCELERATING; |
285 if (motion_accel>0) state = TUIO_ACCELERATING; |
286 else if (motion_accel<0) state = TUIO_DECELERATING; |
286 else if (motion_accel<0) state = TUIO_DECELERATING; |
287 else state = TUIO_STOPPED; |
287 else state = TUIO_STOPPED; |
288 } |
288 } |
289 |
289 |
290 /** |
290 /** |
291 * Takes a TuioTime argument and assigns it along with the provided |
291 * Takes a TuioTime argument and assigns it along with the provided |
292 * X, Y and Z coordinate, X and Y velocity and acceleration |
292 * X, Y and Z coordinate, X and Y velocity and acceleration |
293 * to the private TuioContainer attributes. |
293 * to the private TuioContainer attributes. |
294 * |
294 * |
295 * @param ttime the TuioTime to assign |
295 * @param ttime the TuioTime to assign |
296 * @param xp the X coordinate to assign |
296 * @param xp the X coordinate to assign |
297 * @param yp the Y coordinate to assign |
297 * @param yp the Y coordinate to assign |
298 * @param zp the Z coordinate to assign |
298 * @param zp the Z coordinate to assign |
299 * @param xs the X velocity to assign |
299 * @param xs the X velocity to assign |
300 * @param ys the Y velocity to assign |
300 * @param ys the Y velocity to assign |
301 * @param ma the acceleration to assign |
301 * @param ma the acceleration to assign |
302 */ |
302 */ |
303 public void update(TuioTime ttime, float xp, float yp, float zp , float xs, float ys, float ma) { |
303 public void update(TuioTime ttime, float xp, float yp, float zp , float xs, float ys, float ma) { |
304 super.update(ttime,xp,yp,zp); |
304 super.update(ttime,xp,yp,zp); |
305 x_speed = xs; |
305 x_speed = xs; |
306 y_speed = ys; |
306 y_speed = ys; |
307 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
307 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
308 motion_accel = ma; |
308 motion_accel = ma; |
309 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
309 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
310 if (motion_accel>0) state = TUIO_ACCELERATING; |
310 if (motion_accel>0) state = TUIO_ACCELERATING; |
311 else if (motion_accel<0) state = TUIO_DECELERATING; |
311 else if (motion_accel<0) state = TUIO_DECELERATING; |
312 else state = TUIO_STOPPED; |
312 else state = TUIO_STOPPED; |
313 } |
313 } |
314 |
314 |
315 /** |
315 /** |
316 * Assigns the provided X and Y coordinate, X and Y velocity and acceleration |
316 * Assigns the provided X and Y coordinate, X and Y velocity and acceleration |
317 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
317 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
318 * |
318 * |
319 * @param xp the X coordinate to assign |
319 * @param xp the X coordinate to assign |
320 * @param yp the Y coordinate to assign |
320 * @param yp the Y coordinate to assign |
321 * @param xs the X velocity to assign |
321 * @param xs the X velocity to assign |
322 * @param ys the Y velocity to assign |
322 * @param ys the Y velocity to assign |
323 * @param ma the acceleration to assign |
323 * @param ma the acceleration to assign |
324 */ |
324 */ |
325 public void update(float xp, float yp,float xs,float ys,float ma) { |
325 public void update(float xp, float yp,float xs,float ys,float ma) { |
326 super.update(xp,yp); |
326 super.update(xp,yp); |
327 x_speed = xs; |
327 x_speed = xs; |
328 y_speed = ys; |
328 y_speed = ys; |
329 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
329 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
330 motion_accel = ma; |
330 motion_accel = ma; |
331 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
331 path.addElement(new TuioPoint(currentTime,xpos,ypos)); |
332 if (motion_accel>0) state = TUIO_ACCELERATING; |
332 if (motion_accel>0) state = TUIO_ACCELERATING; |
333 else if (motion_accel<0) state = TUIO_DECELERATING; |
333 else if (motion_accel<0) state = TUIO_DECELERATING; |
334 else state = TUIO_STOPPED; |
334 else state = TUIO_STOPPED; |
335 } |
335 } |
336 |
336 |
337 /** |
337 /** |
338 * Assigns the provided X, Y and Z coordinate, X and Y velocity and acceleration |
338 * Assigns the provided X, Y and Z coordinate, X and Y velocity and acceleration |
339 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
339 * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged. |
340 * |
340 * |
341 * @param xp the X coordinate to assign |
341 * @param xp the X coordinate to assign |
342 * @param yp the Y coordinate to assign |
342 * @param yp the Y coordinate to assign |
343 * @param zp the Z coordinate to assign |
343 * @param zp the Z coordinate to assign |
344 * @param xs the X velocity to assign |
344 * @param xs the X velocity to assign |
345 * @param ys the Y velocity to assign |
345 * @param ys the Y velocity to assign |
346 * @param ma the acceleration to assign |
346 * @param ma the acceleration to assign |
347 */ |
347 */ |
348 public void update(float xp, float yp, float zp,float xs,float ys,float ma) { |
348 public void update(float xp, float yp, float zp,float xs,float ys,float ma) { |
349 super.update(xp,yp,zp); |
349 super.update(xp,yp,zp); |
350 x_speed = xs; |
350 x_speed = xs; |
351 y_speed = ys; |
351 y_speed = ys; |
352 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
352 motion_speed = (float)Math.sqrt(x_speed*x_speed+y_speed*y_speed); |
353 motion_accel = ma; |
353 motion_accel = ma; |
354 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
354 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
355 if (motion_accel>0) state = TUIO_ACCELERATING; |
355 if (motion_accel>0) state = TUIO_ACCELERATING; |
356 else if (motion_accel<0) state = TUIO_DECELERATING; |
356 else if (motion_accel<0) state = TUIO_DECELERATING; |
357 else state = TUIO_STOPPED; |
357 else state = TUIO_STOPPED; |
358 } |
358 } |
359 |
359 |
360 /** |
360 /** |
361 * Takes the atttibutes of the provided TuioContainer |
361 * Takes the atttibutes of the provided TuioContainer |
362 * and assigs these values to this TuioContainer. |
362 * and assigs these values to this TuioContainer. |
363 * The TuioTime time stamp of this TuioContainer remains unchanged. |
363 * The TuioTime time stamp of this TuioContainer remains unchanged. |
364 * |
364 * |
365 * @param tcon the TuioContainer to assign |
365 * @param tcon the TuioContainer to assign |
366 */ |
366 */ |
367 public void update (TuioContainer tcon) { |
367 public void update (TuioContainer tcon) { |
368 super.update(tcon); |
368 super.update(tcon); |
369 x_speed = tcon.getXSpeed(); |
369 x_speed = tcon.getXSpeed(); |
370 y_speed = tcon.getYSpeed(); |
370 y_speed = tcon.getYSpeed(); |
371 motion_speed = tcon.getMotionSpeed(); |
371 motion_speed = tcon.getMotionSpeed(); |
372 motion_accel = tcon.getMotionAccel(); |
372 motion_accel = tcon.getMotionAccel(); |
373 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
373 path.addElement(new TuioPoint(currentTime,xpos,ypos,zpos)); |
374 if (motion_accel>0) state = TUIO_ACCELERATING; |
374 if (motion_accel>0) state = TUIO_ACCELERATING; |
375 else if (motion_accel<0) state = TUIO_DECELERATING; |
375 else if (motion_accel<0) state = TUIO_DECELERATING; |
376 else state = TUIO_STOPPED; |
376 else state = TUIO_STOPPED; |
377 } |
377 } |
378 |
378 |
379 /** |
379 /** |
380 * Assigns the REMOVE state to this TuioContainer and sets |
380 * Assigns the REMOVE state to this TuioContainer and sets |
381 * its TuioTime time stamp to the provided TuioTime argument. |
381 * its TuioTime time stamp to the provided TuioTime argument. |
382 * |
382 * |
383 * @param ttime the TuioTime to assign |
383 * @param ttime the TuioTime to assign |
384 */ |
384 */ |
385 public void remove(TuioTime ttime) { |
385 public void remove(TuioTime ttime) { |
386 currentTime = new TuioTime(ttime); |
386 currentTime = new TuioTime(ttime); |
387 state = TUIO_REMOVED; |
387 state = TUIO_REMOVED; |
388 } |
388 } |
389 |
389 |
390 /** |
390 /** |
391 * Returns the Session ID of this TuioContainer. |
391 * Returns the Session ID of this TuioContainer. |
392 * @return the Session ID of this TuioContainer |
392 * @return the Session ID of this TuioContainer |
393 */ |
393 */ |
394 public long getSessionID() { |
394 public long getSessionID() { |
395 return session_id; |
395 return session_id; |
396 } |
396 } |
397 |
397 |
398 /** |
398 /** |
399 * Returns the X velocity of this TuioContainer. |
399 * Returns the X velocity of this TuioContainer. |
400 * @return the X velocity of this TuioContainer |
400 * @return the X velocity of this TuioContainer |
401 */ |
401 */ |
402 public float getXSpeed() { |
402 public float getXSpeed() { |
403 return x_speed; |
403 return x_speed; |
404 } |
404 } |
405 |
405 |
406 /** |
406 /** |
407 * Returns the Y velocity of this TuioContainer. |
407 * Returns the Y velocity of this TuioContainer. |
408 * @return the Y velocity of this TuioContainer |
408 * @return the Y velocity of this TuioContainer |
409 */ |
409 */ |
410 public float getYSpeed() { |
410 public float getYSpeed() { |
411 return y_speed; |
411 return y_speed; |
412 } |
412 } |
413 |
413 |
414 /** |
414 /** |
415 * Returns the position of this TuioContainer. |
415 * Returns the position of this TuioContainer. |
416 * @return the position of this TuioContainer |
416 * @return the position of this TuioContainer |
417 */ |
417 */ |
418 public TuioPoint getPosition() { |
418 public TuioPoint getPosition() { |
419 return new TuioPoint(xpos,ypos,zpos); |
419 return new TuioPoint(xpos,ypos,zpos); |
420 } |
420 } |
421 |
421 |
422 /** |
422 /** |
423 * Returns the path of this TuioContainer. |
423 * Returns the path of this TuioContainer. |
424 * @return the path of this TuioContainer |
424 * @return the path of this TuioContainer |
425 */ |
425 */ |
426 public Vector<TuioPoint> getPath() { |
426 public Vector<TuioPoint> getPath() { |
427 return path; |
427 return path; |
428 } |
428 } |
429 |
429 |
430 /** |
430 /** |
431 * Returns the motion speed of this TuioContainer. |
431 * Returns the motion speed of this TuioContainer. |
432 * @return the motion speed of this TuioContainer |
432 * @return the motion speed of this TuioContainer |
433 */ |
433 */ |
434 public float getMotionSpeed() { |
434 public float getMotionSpeed() { |
435 return motion_speed; |
435 return motion_speed; |
436 } |
436 } |
437 |
437 |
438 /** |
438 /** |
439 * Returns the motion acceleration of this TuioContainer. |
439 * Returns the motion acceleration of this TuioContainer. |
440 * @return the motion acceleration of this TuioContainer |
440 * @return the motion acceleration of this TuioContainer |
441 */ |
441 */ |
442 public float getMotionAccel() { |
442 public float getMotionAccel() { |
443 return motion_accel; |
443 return motion_accel; |
444 } |
444 } |
445 |
445 |
446 /** |
446 /** |
447 * Returns the TUIO state of this TuioContainer. |
447 * Returns the TUIO state of this TuioContainer. |
448 * @return the TUIO state of this TuioContainer |
448 * @return the TUIO state of this TuioContainer |
449 */ |
449 */ |
450 public int getTuioState() { |
450 public int getTuioState() { |
451 return state; |
451 return state; |
452 } |
452 } |
453 |
453 |
454 /** |
454 /** |
455 * Returns true of this TuioContainer is moving. |
455 * Returns true of this TuioContainer is moving. |
456 * @return true of this TuioContainer is moving |
456 * @return true of this TuioContainer is moving |
457 */ |
457 */ |
458 public boolean isMoving() { |
458 public boolean isMoving() { |
459 if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING)) return true; |
459 if ((state==TUIO_ACCELERATING) || (state==TUIO_DECELERATING)) return true; |
460 else return false; |
460 else return false; |
461 } |
461 } |
462 |
462 |
463 } |
463 } |