front_processing/src/Interaction_examples/Hand_signal/TuioFunctions.pde
changeset 8 e4e7db2435f8
child 9 0f44b7360c8d
equal deleted inserted replaced
7:8a21bec5d45f 8:e4e7db2435f8
       
     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 : Appel aux différentes fonctions de dessin si un message est reçu*/
       
    31 void handleOneHand(TuioCursor handCursor)
       
    32 {
       
    33     boolean click;
       
    34     TuioPoint pt = handCursor.getPosition();
       
    35     fill(0);
       
    36     
       
    37     if(pt.getZ() > minClickHand && pt.getZ() < maxClickHand)
       
    38       click = true;
       
    39     else
       
    40       click = false;
       
    41     update((int)pt.getX(), (int)pt.getY(), click);
       
    42 }
       
    43 
       
    44 /*FONCTION DE GESTION DES COURBES POUR DEUX MAINS DETECTEES
       
    45 Entrée : La liste des curseurs TUIO
       
    46 Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/
       
    47 void handleBothHands(Vector tuioCursorList)
       
    48 {
       
    49     boolean click;
       
    50     TuioCursor handLeftCursor = (TuioCursor)tuioCursorList.elementAt(0);
       
    51     TuioCursor handRightCursor = (TuioCursor)tuioCursorList.elementAt(1);
       
    52     TuioPoint ptLeft = handLeftCursor.getPosition(), ptRight = handRightCursor.getPosition(), ptNearest;
       
    53 
       
    54     ptNearest = (ptLeft.getZ() < ptRight.getZ()) ? ptLeft : ptRight;
       
    55     if(ptNearest.getZ() > minClickHand && ptNearest.getZ() < maxClickHand)
       
    56       click = true;
       
    57     else
       
    58       click = false;
       
    59     update((int)ptNearest.getX(), (int)ptNearest.getY(), click);
       
    60 }
       
    61 
       
    62