Alvaro Cassinelli / Mbed 2 deprecated skinGames_forktest

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Revision:
1:a4050fee11f7
Parent:
0:345b3bc7a0ea
Child:
2:34157ebbf56b
diff -r 345b3bc7a0ea -r a4050fee11f7 blobConfig.cpp
--- a/blobConfig.cpp	Wed Mar 28 14:40:01 2012 +0000
+++ b/blobConfig.cpp	Sat Mar 31 08:19:31 2012 +0000
@@ -3,147 +3,164 @@
 #include "hardwareIO.h" // this is in fact only to get to know the initial position of the spots, as well as the mirror limits to set the bounding box for the blobs
 
 blobConfig::blobConfig(): numBlobs(0) {
-    //blobArray.clear();// there is no need to do this, the vector does not contains anything here. 
-   
+    //blobArray.clear();// there is no need to do this, the vector does not contains anything here.
+
 }
 
 blobConfig::~blobConfig() {
-  clearConfig();
- 
+    clearConfig();
+
 }
 
-
-
 // =========================================== STANDARD CONFIGURATIONS =============================================================================
 
 void blobConfig::computeBoundingBox() {
-for(int i=0; i<blobArray.size(); i++){
- blobArray[i]->computeBoundingBox();
-}
+    for (int i=0; i<blobArray.size(); i++) {
+        blobArray[i]->computeBoundingBox();
+    }
 }
 
 void blobConfig::clearConfig() {
- for(int i=0; i<blobArray.size(); i++) delete blobArray[i]; // we must delete the pointer created with new, so the memory for the object is liberated (calls its destructor)
- blobArray.clear();
- numBlobs=0;// this is just equal to blobArray.size()
+    for (int i=0; i<blobArray.size(); i++) delete blobArray[i]; // we must delete the pointer created with new, so the memory for the object is liberated (calls its destructor)
+    blobArray.clear();
+    numBlobs=0;// this is just equal to blobArray.size()
 }
 
-void blobConfig::addOneElasticLoopRelax(){
-  elasticLoop* pLoopRelax= new elasticLoop();
-  pLoopRelax->createBlob(blobArray.size(), RELAX, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
-  // add this relaxing loop to the present config:
-  blobArray.push_back(pLoopRelax);
-  
-  // update auxiliary variable numBlobs (just for easy reference): 
-  numBlobs=blobArray.size();
- 
+void blobConfig::addOneElasticLoopRelax() {
+    elasticLoop* pBlob= new elasticLoop();
+    pBlob->createBlob(blobArray.size(), RELAX, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+    // add this relaxing loop to the present config:
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
+
 }
 
 
-void blobConfig::addOneElasticLoopContract(){
-  elasticLoop* pLoopRelax= new elasticLoop();
-  pLoopRelax->createBlob(blobArray.size(), CONTRACT, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
-  // add this relaxing loop to the present config:
-  blobArray.push_back(pLoopRelax);
-  
-   // update auxiliary variable numBlobs (just for easy reference): 
-  numBlobs=blobArray.size();
+void blobConfig::addOneElasticLoopContract() {
+    elasticLoop* pBlob= new elasticLoop();
+    pBlob->createBlob(blobArray.size(), CONTRACT, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+    // add this relaxing loop to the present config:
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
 }
 
-void blobConfig::addOneElasticLoopContractCentral(){
-  elasticLoop* pLoopRelax= new elasticLoop();
-  pLoopRelax->createBlob(blobArray.size(), CONTRACT_CENTRAL, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
-   // add this relaxing loop to the present config:
-  blobArray.push_back(pLoopRelax);
-  
-   // update auxiliary variable numBlobs (just for easy reference): 
-  numBlobs=blobArray.size();
+void blobConfig::addOneElasticLoopContractCentral() {
+    elasticLoop* pBlob= new elasticLoop();
+    pBlob->createBlob(blobArray.size(), CONTRACT_CENTRAL, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+    // add this relaxing loop to the present config:
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
 }
 
-void blobConfig::addOneElasticContourFollowing(){
-  
-  elasticLoop* pLoopRelax= new elasticLoop();
-  pLoopRelax->createBlob(blobArray.size(), CONTOUR_FOLLOWING, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
-  // add this relaxing loop to the present config:
-  blobArray.push_back(pLoopRelax);
-  
-   // update auxiliary variable numBlobs (just for easy reference): 
-  numBlobs=blobArray.size();
+void blobConfig::addOneElasticContourFollowing() {
+
+    elasticLoop* pBlob= new elasticLoop();
+    pBlob->createBlob(blobArray.size(), CONTOUR_FOLLOWING, vector2D(CENTER_AD_MIRROR_X+100*blobArray.size(), CENTER_AD_MIRROR_Y+100*blobArray.size()));
+    // add this relaxing loop to the present config:
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
 }
 
 
-void blobConfig:: addOneElasticContourFollowingFAST(){
-  elasticLoop* pLoopRelax= new elasticLoop();
-  pLoopRelax->createBlob(blobArray.size(), CONTOUR_FOLLOWING_FAST, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+void blobConfig:: addOneElasticContourFollowingFAST() {
+    elasticLoop* pBlob= new elasticLoop();
+    pBlob->createBlob(blobArray.size(), CONTOUR_FOLLOWING_FAST, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
     // add this relaxing loop to the present config:
-  blobArray.push_back(pLoopRelax);
-  
-   // update auxiliary variable numBlobs (just for easy reference): 
-  numBlobs=blobArray.size();
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
+}
+
+void blobConfig::addOneElasticBouncing() {
+    elasticLoop* pBlob= new elasticLoop();
+    pBlob->createBlob(blobArray.size(), BOUNCING, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+    // add this relaxing loop to the present config:
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
 }
 
-void blobConfig::addOneElasticBouncing(){
-  elasticLoop* pLoopRelax= new elasticLoop();
-  pLoopRelax->createBlob(blobArray.size(), BOUNCING, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+void blobConfig::addOneRigidLoopBouncing() {
+    rigidLoop* pBlob= new rigidLoop();
+    pBlob->createBlob(blobArray.size(), SPOT_BOUNCING, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
     // add this relaxing loop to the present config:
-  blobArray.push_back(pLoopRelax);
-  
-   // update auxiliary variable numBlobs (just for easy reference): 
-  numBlobs=blobArray.size();
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
 }
 
+void blobConfig::addOneRigidLoopFollowing() {
+    rigidLoop* pBlob= new rigidLoop();
+    pBlob->createBlob(blobArray.size(), SPOT_FOLLOWING, vector2D(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y));
+    // add this relaxing loop to the present config:
+    blobArray.push_back(pBlob);
+
+    // update auxiliary variable numBlobs (just for easy reference):
+    numBlobs=blobArray.size();
+}
 
 
 // ==================================================================================================================================================
 
 
-void blobConfig::allKill() { // this put all the blobs in "dead" mode, meaning that neither rendering nor update is done (but they are not deleted). 
-   for(int i=0; i<blobArray.size(); i++){
-     blobArray[i]->render = false;
-     blobArray[i]->standByMode = false;
-     } 
- } 
+void blobConfig::allKill() { // this put all the blobs in "dead" mode, meaning that neither rendering nor update is done (but they are not deleted).
+    for (int i=0; i<blobArray.size(); i++) {
+        blobArray[i]->render = false;
+        blobArray[i]->standByMode = false;
+    }
+}
 void blobConfig::allAlive() {
-     for(int i=0; i<blobArray.size(); i++){
-     blobArray[i]->render = true;
-     blobArray[i]->standByMode = true;
-     } 
- }
-   
+    for (int i=0; i<blobArray.size(); i++) {
+        blobArray[i]->render = true;
+        blobArray[i]->standByMode = true;
+    }
+}
+
 void blobConfig::allStandBy() {
-  for(int i=0; i<blobArray.size(); i++) blobArray[i]->standByMode = true; 
+    for (int i=0; i<blobArray.size(); i++) blobArray[i]->standByMode = true;
 }
 
 void blobConfig::allResume() {
-  for(int i=0; i<blobArray.size(); i++) blobArray[i]->standByMode = false;
+    for (int i=0; i<blobArray.size(); i++) blobArray[i]->standByMode = false;
 }
 
-void blobConfig::allVisible() { 
-  for(int i=0; i<blobArray.size(); i++) blobArray[i]->render = true; 
+void blobConfig::allVisible() {
+    for (int i=0; i<blobArray.size(); i++) blobArray[i]->render = true;
 }
 
 void blobConfig::allInvisible() { // note that they may continue to evolve
-  for(int i=0; i<blobArray.size(); i++) blobArray[i]->render = false;
+    for (int i=0; i<blobArray.size(); i++) blobArray[i]->render = false;
 }
 
-void blobConfig::update(){ // update dynamics of the blob
-  for(int i=0; i<blobArray.size(); i++) {
-    if ((blobArray[i]->render==true)&&(blobArray[i]->standByMode==false)) blobArray[i]->update();
-  }
+void blobConfig::update() { // update dynamics of the blob
+    for (int i=0; i<blobArray.size(); i++) {
+        if ((blobArray[i]->render==true)&&(blobArray[i]->standByMode==false)) blobArray[i]->update();
+    }
 }
 
-void blobConfig::draw(){ // draw uses the opengl like renderer (if any), and save projected trajectory in the LaserSensingTrajectory object of each blob
-  for(int i=0; i<blobArray.size(); i++) {
-    if (blobArray[i]->render==true) blobArray[i]->draw(); 
-  }
+void blobConfig::draw() { // draw uses the opengl like renderer (if any), and save projected trajectory in the LaserSensingTrajectory object of each blob
+    for (int i=0; i<blobArray.size(); i++) {
+        if (blobArray[i]->render==true) blobArray[i]->draw();
+    }
 }
 
-void blobConfig::sendConfData(){
-// For the time being, only "per blob" data sending: 
-// (b) Per-spot sending of data (note: both are NOT exclusive; so if we want just packaged data, we need to make all the spot STOP sending data. 
-  for(int i=0; i<blobArray.size(); i++) {
-    if (blobArray[i]->render==true) blobArray[i]->sendData(); // a blob that is in stand-by mode may send data (good for testing with a fixed loop)
-  }
+void blobConfig::sendConfData() {
+// For the time being, only "per blob" data sending:
+// (b) Per-spot sending of data (note: both are NOT exclusive; so if we want just packaged data, we need to make all the spot STOP sending data.
+    for (int i=0; i<blobArray.size(); i++) {
+        if (blobArray[i]->render==true) blobArray[i]->sendData(); // a blob that is in stand-by mode may send data (good for testing with a fixed loop)
+    }
 }