Index: trunk/src/lib/graphics/importer/height_map.cc
===================================================================
--- trunk/src/lib/graphics/importer/height_map.cc	(revision 7491)
+++ trunk/src/lib/graphics/importer/height_map.cc	(revision 7492)
@@ -127,7 +127,7 @@
     if( this->heightMapReference->hasColourMap)
     {
-      r = colors[3 * w + 2 + 3 * i * (this->heightMapReference->heightMap->w)];
-      g = colors[3 * w + 1 + 3 * i * (this->heightMapReference->heightMap->w)];
-      b = colors[3 * w + 0 + 3 * i * (this->heightMapReference->heightMap->w)];
+      r = colors[3 * w + 2 + 3 * i * this->heightMapReference->heightMap->w];
+      g = colors[3 * w + 1 + 3 * i * this->heightMapReference->heightMap->w];
+      b = colors[3 * w + 0 + 3 * i * this->heightMapReference->heightMap->w];
     }
 
@@ -140,5 +140,5 @@
                      normalVectorField[i % this->heightMapReference->heightMap->h][w % this->heightMapReference->heightMap->w].x);
     model->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
-    model->addColor(r/255.0f,g/255.0f,b/255.0f);
+    model->addColor(r/255.0f, g/255.0f, b/255.0f);
 
 
@@ -148,7 +148,7 @@
       if( this->heightMapReference->hasColourMap)
       {
-        r = colors[3 * j + 2 + 3 * i * (this->heightMapReference->heightMap->w)];
-        g = colors[3 * j + 1 + 3 * i * (this->heightMapReference->heightMap->w)];
-        b = colors[3 * j + 0 + 3 * i * (this->heightMapReference->heightMap->w)];
+        r = colors[3 * j + 2 + 3 * i * this->heightMapReference->heightMap->w];
+        g = colors[3 * j + 1 + 3 * i * this->heightMapReference->heightMap->w];
+        b = colors[3 * j + 0 + 3 * i * this->heightMapReference->heightMap->w];
       }
       height =  (float)(unsigned char)this->heightMapReference->heights[j + sampleRate + i * (this->heightMapReference->heightMap->w)];
@@ -162,11 +162,14 @@
       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.0f, g/255.0f, b/255.0f);
       //PRINTF(0)("TexCoord:  %f %f \n",(float)j / 100.0, (float)(i %this->heightMapReference->h)/100.0);
 
-      model->addColor(r/255.0,g/255.0,b/255.0);
       w = j;
     }
@@ -177,34 +180,22 @@
     model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
     model->addColor(r/255.0,g/255.0,b/255.0);
-
-  }
-
-
-
-
+  }
 
   SDL_UnlockSurface(this->heightMapReference->heightMap);
   int cnt = 0;
-  for(int i = i1   ; i < i2  ; i +=sampleRate)
-  {
-
-    for(int j = j1-sampleRate  ; j < j2  + 2*sampleRate  ;  j += sampleRate)
-    {
-
+
+  for( int i = i1; i < i2; i +=sampleRate)
+  {
+    for( int j = j1-sampleRate; j < j2  + 2 * sampleRate; j += sampleRate)
+    {
       model->addIndice(cnt);
       model->addIndice(cnt  + (j2 -j1 + 3* sampleRate  )/ sampleRate );
       cnt++;
-
-    }
-
-
-
+    }
     model->newStripe();
-
-
   }
   cnt += (j2 -j1 + 3* sampleRate)/ sampleRate;
 
-  for(int j = j1 ; j <= j2    ;  j += sampleRate)
+  for( int j = j1; j <= j2; j += sampleRate)
   {
     int i = i1;
@@ -213,13 +204,17 @@
     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);
+      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);
+    model->addColor(r/255.0f, g/255.0f, b/255.0f);
 
   }
