Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Revision:
30:d8af03f01cd4
Parent:
29:2fc8c12822eb
Child:
31:5f039cbddee8
--- a/main.cpp	Wed Jun 20 03:25:49 2012 +0000
+++ b/main.cpp	Fri Sep 21 10:02:35 2012 +0000
@@ -329,27 +329,27 @@
     // SIMPLE BEHAVIOUR MODES (to be read from an XML file in the future):
     else if (!strcmp(address[0], "elastic_following")) { //
         timerForRendering.detach();
-        // blobconf.computeBoundingBox();
-        blobconf.clearConfig();
-        blobconf.addOneElasticContourFollowing();
+        
+        blobconf.initConfig(ONE_ELASTIC_FOLLOWING);
+        
         lsr.setConfigToRender(&blobconf);
         timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
         // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL);
 
     } else if (!strcmp(address[0], "elastic_mouth")) { //
         timerForRendering.detach();
-        // blobconf.computeBoundingBox();
-        blobconf.clearConfig();
-        blobconf.addOneElasticLoopContractCentral();
+        
+        blobconf.initConfig(ONE_ELASTIC_MOUTH);
+        
         lsr.setConfigToRender(&blobconf);
         timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
         // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL);
     
      } else if (!strcmp(address[0], "elastic_mouth_small")) { //
         timerForRendering.detach();
-        // blobconf.computeBoundingBox();
-        blobconf.clearConfig();
-        blobconf.addOneElasticLoopContractCentralFast();
+        
+         blobconf.initConfig(ONE_ELASTIC_MOUTH_SMALL);
+         
         lsr.setConfigToRender(&blobconf);
         timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
         // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL);
@@ -357,20 +357,9 @@
     else if (!strcmp(address[0], "spot_bouncing")) {
         int value=data[0];
         if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)
-
             timerForRendering.detach();
-            // blobconf.computeBoundingBox();
-            blobconf.clearConfig();
-
-            // HACK for the time being: 
-            /*
-            int aux=rand()%100;
-           if (aux<70) value=1; 
-           else if (aux<80) value=2; 
-           else value=3;
-           */
-
-            for (int i=0; i<value ; i++) blobconf.addOneRigidLoopBouncing();
+            
+            blobconf.initConfig(BOUNCING_SPOTS, value); // value is the nb of spots instantiated
 
             lsr.setConfigToRender(&blobconf);
             timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
@@ -378,15 +367,12 @@
         }
     }
 
-else if (!strcmp(address[0], "spot_fountain")) {
+else if (!strcmp(address[0], "spot_lorentz")) {
         int value=data[0];
         if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)
-
             timerForRendering.detach();
-            // blobconf.computeBoundingBox();
-            blobconf.clearConfig();
-
-            for (int i=0; i<value ; i++) blobconf.addOneRigidLoopFountain();
+           
+            blobconf.initConfig(LORENTZ_SPOTS, value); // value is the nb of spots instantiated
 
             lsr.setConfigToRender(&blobconf);
             timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
@@ -397,12 +383,9 @@
    else if (!strcmp(address[0], "air_hockey")) {
         int value=data[0];
         if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)
-
             timerForRendering.detach();
-            // blobconf.computeBoundingBox();
-            blobconf.clearConfig();
-
-            for (int i=0; i<value ; i++) blobconf.addOneRigidLoopAirHockey();
+            
+            blobconf.initConfig(AIR_HOCKEY_GAME, value); // value is the nb of spots instantiated
 
             lsr.setConfigToRender(&blobconf);
             timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
@@ -415,19 +398,8 @@
         if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)
 
             timerForRendering.detach();
-            // blobconf.computeBoundingBox();
-            blobconf.clearConfig();
             
-           // HACK for the time being: 
-           /*
-           int aux=rand()%100;
-           if (aux<70) value=1; 
-           else if (aux<80) value=2; 
-           else value=6;
-           */
-            
-            for (int i=0; i<value ; i++) blobconf.addOneRigidLoopFollowing();
-            
+            blobconf.initConfig(FOLLOWING_SPOTS, value); // value is the nb of spots instantiated
             
             lsr.setConfigToRender(&blobconf);
             timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
@@ -435,6 +407,35 @@
         }
     }
 
+    else if (!strcmp(address[0], "circular_pong")) {
+        int value=data[0];
+        if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)
+
+            timerForRendering.detach();
+            
+            blobconf.initConfig(CIRCULAR_PONG_GAME, value); // value is the nb of spots instantiated
+            
+            lsr.setConfigToRender(&blobconf);
+            timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
+            // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL);
+        }
+    }
+
+    else if (!strcmp(address[0], "pac_man")) {
+        int value=data[0];
+        if (value!=-1) { // otherwise do nothing, this is a reception error (there was no data)
+
+            timerForRendering.detach();
+            
+            blobconf.initConfig(PAC_MAN_GAME); 
+            
+            lsr.setConfigToRender(&blobconf);
+            timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThread, RENDER_INTERVAL);
+            // timerForRendering.attach(&lsr, &simpleLaserSensingRenderer::laserRenderThreadONEBLOBONLY, RENDER_INTERVAL);
+        }
+    }
+
+
     else if (!strcmp(address[0], "spot_test")) {
         timerForRendering.detach();
         // blobconf.computeBoundingBox();