front_processing/src/Interaction_examples/Hand_signal/TuioFunctions.pde
changeset 8 e4e7db2435f8
child 9 0f44b7360c8d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/front_processing/src/Interaction_examples/Hand_signal/TuioFunctions.pde	Thu Mar 22 16:00:17 2012 +0100
@@ -0,0 +1,62 @@
+/*
+* This file is part of the TraKERS\Front Processing package.
+*
+* (c) IRI <http://www.iri.centrepompidou.fr/>
+*
+* For the full copyright and license information, please view the LICENSE_FRONT
+* file that was distributed with this source code.
+*/
+
+/*FONCTION DE RECEPTION DES MESSAGES OSC
+Entrée :
+Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/
+void tuioInput()
+{
+    noFill();
+    Vector tuioCursorList = tuioClient.getTuioCursors();
+    	
+    if(tuioCursorList.size() == 1)
+    {
+        handleOneHand((TuioCursor)tuioCursorList.elementAt(0));
+    }
+    else if(tuioCursorList.size() == 2)
+    {
+        handleBothHands(tuioCursorList);
+    }
+}
+
+/*FONCTION DE GESTION DES COURBES POUR UNE MAIN DETECTEE
+Entrée : Un curseur TUIO
+Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/
+void handleOneHand(TuioCursor handCursor)
+{
+    boolean click;
+    TuioPoint pt = handCursor.getPosition();
+    fill(0);
+    
+    if(pt.getZ() > minClickHand && pt.getZ() < maxClickHand)
+      click = true;
+    else
+      click = false;
+    update((int)pt.getX(), (int)pt.getY(), click);
+}
+
+/*FONCTION DE GESTION DES COURBES POUR DEUX MAINS DETECTEES
+Entrée : La liste des curseurs TUIO
+Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/
+void handleBothHands(Vector tuioCursorList)
+{
+    boolean click;
+    TuioCursor handLeftCursor = (TuioCursor)tuioCursorList.elementAt(0);
+    TuioCursor handRightCursor = (TuioCursor)tuioCursorList.elementAt(1);
+    TuioPoint ptLeft = handLeftCursor.getPosition(), ptRight = handRightCursor.getPosition(), ptNearest;
+
+    ptNearest = (ptLeft.getZ() < ptRight.getZ()) ? ptLeft : ptRight;
+    if(ptNearest.getZ() > minClickHand && ptNearest.getZ() < maxClickHand)
+      click = true;
+    else
+      click = false;
+    update((int)ptNearest.getX(), (int)ptNearest.getY(), click);
+}
+
+