Index: /trunk/src/lib/graphics/importer/height_map.cc
===================================================================
--- /trunk/src/lib/graphics/importer/height_map.cc	(revision 7493)
+++ /trunk/src/lib/graphics/importer/height_map.cc	(revision 7494)
@@ -154,9 +154,9 @@
       height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
       height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) *
-                                                                        (this->heightMapReference->heightMap->w)];
+                                                                        this->heightMapReference->heightMap->w];
       height += (float)(unsigned char)this->heightMapReference->heights[j - 1 + sampleRate + (i + 1) *
-                                                                        (this->heightMapReference->heightMap->w )];
+                                                                        this->heightMapReference->heightMap->w];
       height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + (i + 2) *
-                                                                        (this->heightMapReference->heightMap->w)];
+                                                                        this->heightMapReference->heightMap->w];
       height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
       height /= 5.0;
@@ -174,10 +174,10 @@
       w = j;
     }
-
-
     model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
-    model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].y,normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].z,normalVectorField[i% this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x);
+    model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].y,
+                     normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].z,
+                     normalVectorField[i% this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x);
     model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
-    model->addColor(r/255.0,g/255.0,b/255.0);
+    model->addColor(r/255.0f, g/255.0f, b/255.0f);
   }
 
@@ -217,51 +217,59 @@
     model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %this->heightMapReference->heightMap->h)/(texRate));
     model->addColor(r/255.0f, g/255.0f, b/255.0f);
-
-  }
+  }
+
 
   for(int j = j1  ; j <= j2    ;  j += sampleRate)
   {
     int i = i1;
-    height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ];
-    height += (float)(unsigned char) this->heightMapReference->heights[(j+ 1 + sampleRate + (i+1)*(this->heightMapReference->heightMap->w )) ];
-    height +=  (float) (unsigned char) this->heightMapReference->heights[(j -1+ sampleRate   + (i+1)*(this->heightMapReference->heightMap->w ))];
-    height +=  (float)(unsigned char)this->heightMapReference->heights[(j +sampleRate+ (i+2)*(this->heightMapReference->heightMap->w )) ];
-    height +=  (float)(unsigned char)this->heightMapReference->heights[(j+sampleRate + (i)*(this->heightMapReference->heightMap->w )) ];
+    height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * this->heightMapReference->heightMap->w];
+    height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1) *
+                                                                      this->heightMapReference->heightMap->w];
+    height += (float)(unsigned char)this->heightMapReference->heights[j - 1 + sampleRate + (i + 1) *
+                                                                      this->heightMapReference->heightMap->w];
+    height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + (i + 2) *
+                                                                      this->heightMapReference->heightMap->w];
+    height += (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * this->heightMapReference->heightMap->w];
     height=height/5.0;
 
-    model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right
-    model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].y,normalVectorField[i % this->heightMapReference->heightMap->h][j% this->heightMapReference->heightMap->w].z,normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x);
+    model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX ,
+                     ((double)(height)*scaleY) +shiftY ,
+                     scaleZ*(j) + shiftZ); // Top Right
+    model->addNormal(normalVectorField[i % this->heightMapReference->heightMap->h][j % this->heightMapReference->heightMap->w].y,
+                     normalVectorField[i % this->heightMapReference->heightMap->h][j% this->heightMapReference->heightMap->w].z,
+                     normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x);
     model->addTexCoor((float)j /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
-    model->addColor(r/255.0,g/255.0,b/255.0);
-
-  }
-
-
-
-  for(int j = j1  ; j <= j2    ;  j += sampleRate)
+    model->addColor(r/255.0f, g/255.0f, b/255.0f);
+  }
+
+
+  for(int j = j1; j <= j2; j += sampleRate)
   {
     int i = i2;
-
     // To be fixed
-    if(this->heightMapReference->hasColourMap)
-    {
-      r = (float)colors[3*j+2 + 3*i*(this->heightMapReference->heightMap->w )];
-      g = (float)colors[3*j+1 + 3*i*(this->heightMapReference->heightMap->w)];
-      b = (float)colors[3*j+0 + 3*i*(this->heightMapReference->heightMap->w)];
-    }
-
-    model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right
-    model->addNormal(normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].y,normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].z,normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x);
+    if( this->heightMapReference->hasColourMap)
+    {
+      r = (float)colors[3 * j + 2 + 3 * i * this->heightMapReference->heightMap->w];
+      g = (float)colors[3 * j + 1 + 3 * i * this->heightMapReference->heightMap->w];
+      b = (float)colors[3 * j + 0 + 3 * i * this->heightMapReference->heightMap->w];
+    }
+
+    model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i) + shiftX ,
+                     shiftY ,
+                     scaleZ*(j) + shiftZ); // Top Right
+    model->addNormal(normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].y,
+                     normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].z,
+                     normalVectorField[i%this->heightMapReference->heightMap->h][j%this->heightMapReference->heightMap->w].x);
     model->addTexCoor((float)j /(texRate), (float)((i+ sampleRate) %this->heightMapReference->heightMap->h)/(texRate));
-    model->addColor(r/255.0,g/255.0,b/255.0);
-
-  }
-
-
-  for(int j = j1 ; j <= j2    ;  j += sampleRate)
+    model->addColor(r/255.0f, g/255.0f, b/255.0f);
+  }
+
+
+  for(int j = j1; j <= j2; j += sampleRate)
   {
     int i = i2;
-    height = (float)(unsigned char) this->heightMapReference->heights[(j +sampleRate+ i*(this->heightMapReference->heightMap->w )) ];
-    height += (float)(unsigned char) this->heightMapReference->heights[(j+ 1 + sampleRate + (i+1)*(this->heightMapReference->heightMap->w )) ];
+    height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * this->heightMapReference->heightMap->w];
+    height += (float)(unsigned char)this->heightMapReference->heights[j + 1 + sampleRate + (i + 1)
+                                                                      * this->heightMapReference->heightMap->w];
     height +=  (float) (unsigned char) this->heightMapReference->heights[(j -1+ sampleRate   + (i+1)*(this->heightMapReference->heightMap->w ))];
     height +=  (float)(unsigned char)this->heightMapReference->heights[(j +sampleRate+ (i+2)*(this->heightMapReference->heightMap->w ))];
