front_processing/src/Trakers/Trakers.pde
changeset 3 92f19af39024
parent 0 6fefd4afe506
child 5 d40f84d77db4
--- a/front_processing/src/Trakers/Trakers.pde	Fri Mar 09 18:15:12 2012 +0100
+++ b/front_processing/src/Trakers/Trakers.pde	Thu Mar 15 13:33:21 2012 +0100
@@ -1,4 +1,5 @@
 import TUIO.*;
+//import TrakersNavierStokes;
 TuioProcessing tuioClient;
 boolean oneHandLeft;
 
@@ -8,7 +9,7 @@
 void setup()
 {
     size (640, 480);
-    background(255);
+    showMask();
     tuioClient = new TuioProcessing(this, 80);
     textAlign(CENTER);
     imageMode(CENTER);
@@ -31,14 +32,41 @@
 void tuioInput()
 {
     noFill();
-    rect(0, 0, 50, 50);
+    //rect(0, 0, 50, 50);
   
     Vector tuioCursorList = tuioClient.getTuioCursors();
-    
+
+    if(tuioCursorList.size() <= 0)
+    {
+        showMask();
+        text("Les mains sont trop loin ou trop près.", width/2 - 20, 20);
+        text("Je ne détecte aucune main.", width/2 - 20, 40);
+    }
+        
     if(tuioCursorList.size() == 1)
+    {
         handleOneHand((TuioCursor)tuioCursorList.elementAt(0));
+        fill(255);
+        text("Les mains sont dans la zone de captation.", width/2 - 20, 20);
+        text("Je détecte une main.", width/2 - 20, 40);
+    }
     else if(tuioCursorList.size() == 2)
+    {
         handleBothHands(tuioCursorList);
+        fill(255);
+        text("Les mains sont dans la zone de captation.", width/2 - 20, 20);
+        text("Je détecte les deux mains.", width/2 - 20, 40);
+    }
+}
+
+/*FONCTION DE GENERATION DU MASQUE
+Entrée :
+Sortie : Place des rectangles autour de la zone de dessin*/
+void showMask()
+{
+    background(0);
+    fill(255);
+    rect(0, 80, width, height-130);
 }
 
 /*FONCTION DE GESTION DES COURBES POUR UNE MAIN DETECTEE
@@ -46,9 +74,8 @@
 Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/
 void handleOneHand(TuioCursor handCursor)
 {
-    fill(0, 0, 255);
-    rect(0, 0, 50, 50);
-    
+    showMask();
+
     Vector pointList = handCursor.getPath();
     for (int j=0;j<pointList.size();j++)
     {
@@ -66,9 +93,8 @@
 Sortie : Appel aux différentes fonctions de dessin si un message est reçu*/
 void handleBothHands(Vector tuioCursorList)
 {
-    fill(0);
-    rect(0, 0, 50, 50);
-    
+    showMask();
+
     TuioCursor handLeftCursor = (TuioCursor)tuioCursorList.elementAt(0);
     TuioCursor rightLeftCursor = (TuioCursor)tuioCursorList.elementAt(1);
     Vector handLeftPointList = handLeftCursor.getPath();
@@ -105,13 +131,27 @@
 Sortie : Le point est dessiné avec une épaisseur et une luminosité dépendant de Z*/
 void drawEllipse(float x, float y, float z, boolean leftHand)
 {
-    float weight = map(z, 1, 2, 50, 1);
-    float redColor = map(z, 1, 2, 255, 80);
+
+    fill(0, 0, 255);
+    stroke(0,0,0);
+
+    float weight = map(z, 1, 1.5, 50, 1);
+    float redColor = map(z, 1, 1.5, 255, 80);
+    
     if(leftHand)
         fill(redColor,0,0);
     else
         fill(0,redColor,0);
-    ellipse(x, y, weight, weight);
-}
- 
-
+    
+    if(weight < 30)
+    {
+        //strokeWeight(0);
+    }
+    else
+    {
+        fill(0, 0, redColor);
+    }
+    
+    
+    ellipse(x+20, y+100, weight, weight);
+}