Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.cc	(revision 10586)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.cc	(revision 10591)
@@ -53,10 +53,14 @@
         center_ = NULL;
         upgrade_ = 0;
-        setPosition(0,0,0);        
-        model_ = new Model(getContext());
-        model_->setScale(25);
-        model_->pitch(Degree(90));
-        attach(model_);
-        setAngle(0); 
+        setPosition(0,0,0);                            
+        modelGround_ = new Model(getContext());
+        modelGround_->setScale(25);
+        modelGround_->pitch(Degree(90));
+        attach(modelGround_);
+        modelObject_ = new Model(getContext());
+        modelObject_->setScale(25);
+        modelObject_->pitch(Degree(90));
+        attach(modelObject_);
+        setAngle(0);
     }
 
@@ -125,28 +129,50 @@
     void TowerDefenseField::setAngle(int newAngle)
     {
-        if (model_ == NULL)
-        {
-            return;
-        }
-
-        switch (newAngle)
-        {
+        if (modelGround_ != NULL)
+        {
+            switch (newAngle)
+            {
             case 0:
-                model_->yaw(Degree(0));
+                modelGround_->yaw(Degree(0));
                 angle_ = 0;
                 break;
             case 1:
-                model_->yaw(Degree(90));
+                modelGround_->yaw(Degree(90));
                 angle_ = 1;
                 break;    
             case 2:
-                model_->yaw(Degree(180));
+                modelGround_->yaw(Degree(180));
                 angle_ = 2;
                 break;   
             case 3:
-                model_->yaw(Degree(270));
+                modelGround_->yaw(Degree(270));
                 angle_ = 3;
                 break;                                           
-        }
+            }
+        }
+
+        if (modelObject_ != NULL)
+        {
+            switch (newAngle)
+            {
+            case 0:
+                modelObject_->yaw(Degree(0));
+                angle_ = 0;
+                break;
+            case 1:
+                modelObject_->yaw(Degree(90));
+                angle_ = 1;
+                break;    
+            case 2:
+                modelObject_->yaw(Degree(180));
+                angle_ = 2;
+                break;   
+            case 3:
+                modelObject_->yaw(Degree(270));
+                angle_ = 3;
+                break;                                           
+            }
+        }
+        
     }
 
@@ -158,5 +184,5 @@
     void TowerDefenseField::createFree(int orientation)
     {            
-        model_->setMeshSource("TD_F1.mesh");
+        modelGround_->setMeshSource("TD_F1.mesh");
         tower_ = NULL;
         type_ = FREE;
@@ -167,5 +193,5 @@
     void TowerDefenseField::createStart(int orientation)
     {      
-        model_->setMeshSource("TD_S5.mesh");
+        modelGround_->setMeshSource("TD_S5.mesh");
         tower_ = NULL;
         type_ = START;
@@ -177,5 +203,5 @@
     void TowerDefenseField::createEnd(int orientation)
     {     
-        model_->setMeshSource("TD_S4.mesh");
+        modelGround_->setMeshSource("TD_S4.mesh");
         tower_ = NULL;
         type_ = END;
@@ -186,5 +212,5 @@
     void TowerDefenseField::createStraight(int orientation)
     {      
-        model_->setMeshSource("TD_S1.mesh");
+        modelGround_->setMeshSource("TD_S1.mesh");
         tower_ = NULL;
         type_ = STREET;
@@ -195,5 +221,5 @@
     void TowerDefenseField::createRCurve(int orientation)
     {     
-        model_->setMeshSource("TD_S2.mesh");
+        modelGround_->setMeshSource("TD_S2.mesh");
         tower_ = NULL;
         type_ = STREET;
@@ -204,5 +230,5 @@
     void TowerDefenseField::createLCurve(int orientation)
     {    
-        model_->setMeshSource("TD_S3.mesh");
+        modelGround_->setMeshSource("TD_S3.mesh");
         tower_ = NULL;
         type_ = STREET;
@@ -210,4 +236,14 @@
         setAngle(orientation);
     } 
+
+    void TowerDefenseField::createObstacle(int orientation)
+    {    
+        modelGround_->setMeshSource("TD_F1.mesh");
+        modelObject_->setMeshSource("TD_O1.mesh");
+        tower_ = NULL;
+        type_ = OBSTACLE;
+        setUpgrade(0);
+        setAngle(orientation);
+    }
 
     void TowerDefenseField::createTower(int upgrade)
@@ -215,30 +251,31 @@
         if (tower_ == NULL)
         {
+            modelGround_->setMeshSource("TD_F1.mesh");
             tower_ = new TowerDefenseTower(center_->getContext());
             attach(tower_);
             type_ = TOWER;
             setUpgrade(upgrade);
-            if (upgrade_ > 0 && model_ != NULL)
+            if (upgrade_ > 0 && modelObject_ != NULL)
             {
                 switch (upgrade_)
                 {
                     case 1:
-                        model_->setMeshSource("TD_T1.mesh");                    
+                        modelObject_->setMeshSource("TD_T1.mesh");                    
                         tower_->addTemplate(center_->getTower1Template());
                         break;
                     case 2:
-                        model_->setMeshSource("TD_T2.mesh");
+                        modelObject_->setMeshSource("TD_T2.mesh");
                         tower_->addTemplate(center_->getTower2Template());
                         break;
                     case 3:
-                        model_->setMeshSource("TD_T3.mesh");
+                        modelObject_->setMeshSource("TD_T3.mesh");
                         tower_->addTemplate(center_->getTower3Template());
                         break;
                     case 4:
-                        model_->setMeshSource("TD_T4.mesh");
+                        modelObject_->setMeshSource("TD_T4.mesh");
                         tower_->addTemplate(center_->getTower4Template());
                         break;
                     case 5:
-                        model_->setMeshSource("TD_T5.mesh");
+                        modelObject_->setMeshSource("TD_T5.mesh");
                         tower_->addTemplate(center_->getTower5Template());
                         break;
@@ -279,5 +316,8 @@
             case 'O':               
                 createEnd(paramInt);
-                break;    
+                break;
+            case 'Y':               
+                createObstacle(paramInt);
+                break;                 
             case 'T':                               
                 createTower(paramInt);               
