|
1 /* |
|
2 * This file is part of the TraKERS\Front Processing package. |
|
3 * |
|
4 * (c) IRI <http://www.iri.centrepompidou.fr/> |
|
5 * |
|
6 * For the full copyright and license information, please view the LICENSE_FRONT |
|
7 * file that was distributed with this source code. |
|
8 */ |
|
9 |
|
10 /*FONCTION DE RECEPTION DES MESSAGES OSC |
|
11 Entrée : |
|
12 Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/ |
|
13 void tuioInput() |
|
14 { |
|
15 noFill(); |
|
16 Vector tuioCursorList = tuioClient.getTuioCursors(); |
|
17 |
|
18 if(tuioCursorList.size() == 1) |
|
19 { |
|
20 handleOneHand((TuioCursor)tuioCursorList.elementAt(0)); |
|
21 } |
|
22 else if(tuioCursorList.size() == 2) |
|
23 { |
|
24 handleBothHands(tuioCursorList); |
|
25 } |
|
26 } |
|
27 |
|
28 /*FONCTION DE GESTION DES COURBES POUR UNE MAIN DETECTEE |
|
29 Entrée : Un curseur TUIO |
|
30 Sortie : Envoie les coordonnées du point au fichier principal*/ |
|
31 void handleOneHand(TuioCursor handCursor) |
|
32 { |
|
33 TuioPoint pt = handCursor.getPosition(); |
|
34 fill(0); |
|
35 update((int)pt.getX(), (int)pt.getY()); |
|
36 } |
|
37 |
|
38 /*FONCTION DE GESTION DES COURBES POUR DEUX MAINS DETECTEES |
|
39 Entrée : La liste des curseurs TUIO |
|
40 Sortie : Envoie les coordonnées du point le plus proche au fichier principal*/ |
|
41 void handleBothHands(Vector tuioCursorList) |
|
42 { |
|
43 TuioCursor handLeftCursor = (TuioCursor)tuioCursorList.elementAt(0); |
|
44 TuioCursor handRightCursor = (TuioCursor)tuioCursorList.elementAt(1); |
|
45 TuioPoint ptLeft = handLeftCursor.getPosition(), ptRight = handRightCursor.getPosition(), ptNearest; |
|
46 |
|
47 ptNearest = (ptLeft.getZ() < ptRight.getZ()) ? ptLeft : ptRight; |
|
48 update((int)ptNearest.getX(), (int)ptNearest.getY()); |
|
49 } |
|
50 |
|
51 |