Index: /trunk/src/lib/graphics/importer/height_map.cc
===================================================================
--- /trunk/src/lib/graphics/importer/height_map.cc	(revision 7498)
+++ /trunk/src/lib/graphics/importer/height_map.cc	(revision 7499)
@@ -35,9 +35,9 @@
 /**
  * default constructor
- *  @param i1
- */
-Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* heightMapReference )
-{
-  PRINTF(4)("Tile Constructor\n");
+ *  @param xOffset
+ */
+Tile::Tile(int xOffset, int yOffset, int i2, int j2, HeightMap* heightMapReference )
+{
+  PRINTF(0)("Tile Constructor\n");
 
   this->highResModel = new VertexArrayModel();
@@ -47,7 +47,7 @@
 
   // create high res model
-  this->load(i1, j1, i2, j2, this->highResModel, 4);
+  this->load(xOffset, yOffset, i2, j2, this->highResModel, 4);
   // create low res model
-  this->load(i1, j1, i2, j2, this->lowResModel, 8);
+  this->load(xOffset, yOffset, i2, j2, this->lowResModel, 8);
 }
 
@@ -84,5 +84,5 @@
  * loads a tile
  */
-void Tile::load(int i1, int j1, int i2, int j2, VertexArrayModel* model, int sampleRate)
+void Tile::load(int xOffset, int yOffset, int i2, int j2, VertexArrayModel* model, int sampleRate)
 {
 
@@ -99,10 +99,10 @@
 
   //FIXME: OLD implementation
-  this->x = this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((i1 + i2) / 2)) * scaleX;
-  this->z = this->heightMapReference->offsetZ + ((j1 + j2 ) / 2 ) * scaleZ;
+  this->x = this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((xOffset + i2) / 2)) * scaleX;
+  this->z = this->heightMapReference->offsetZ + ((yOffset + j2 ) / 2 ) * scaleZ;
   //NEW:
-  this->setAbsCoor(this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((i1 + i2) / 2)) * scaleX,
+  this->setAbsCoor(this->heightMapReference->offsetX + ( this->heightMapReference->heightMap->h - ((xOffset + i2) / 2)) * scaleX,
                    0,
-                   this->heightMapReference->offsetZ + ((j1 + j2 ) / 2 ) * scaleZ);
+                   this->heightMapReference->offsetZ + ((yOffset + j2 ) / 2 ) * scaleZ);
 
 
@@ -120,5 +120,5 @@
   SDL_LockSurface(this->heightMapReference->colorMap);
 
-  for( int i = i1 ; i <= i2  ; i +=sampleRate)
+  for( int i = xOffset ; i <= i2  ; i +=sampleRate)
   {
     int w = 0;
@@ -132,16 +132,18 @@
     }
 
-    w = j1;
+    w = yOffset;
+
+    PRINTF(0)("Values: i = %i, w = %i\n", i, w);
 
     // add a vertex to the list
-    model->addVertex(scaleX*(this->heightMapReference->heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
+    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->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
+    model->addTexCoor((float)(yOffset-sampleRate) /(texRate), (float)(i %this->heightMapReference->heightMap->h)/(texRate));
     model->addColor(r/255.0f, g/255.0f, b/255.0f);
 
 
-    for(int j = j1; j <= j2; j += sampleRate)
+    for(int j = yOffset; j <= j2; j += sampleRate)
     {
       // adjust the colors acording to the color map
@@ -185,19 +187,19 @@
   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 = xOffset; i < i2; i +=sampleRate)
+  {
+    for( int j = yOffset-sampleRate; j < j2  + 2 * sampleRate; j += sampleRate)
     {
       model->addIndice(cnt);
-      model->addIndice(cnt  + (j2 -j1 + 3* sampleRate  )/ sampleRate );
+      model->addIndice(cnt  + (j2 -yOffset + 3* sampleRate  )/ sampleRate );
       cnt++;
     }
     model->newStripe();
   }
-  cnt += (j2 -j1 + 3* sampleRate)/ sampleRate;
-
-  for( int j = j1; j <= j2; j += sampleRate)
-  {
-    int i = i1;
+  cnt += (j2 -yOffset + 3* sampleRate)/ sampleRate;
+
+  for( int j = yOffset; j <= j2; j += sampleRate)
+  {
+    int i = xOffset;
 
     // To be fixed
@@ -220,7 +222,7 @@
 
 
-  for(int j = j1  ; j <= j2    ;  j += sampleRate)
-  {
-    int i = i1;
+  for(int j = yOffset  ; j <= j2    ;  j += sampleRate)
+  {
+    int i = xOffset;
     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) *
@@ -244,5 +246,5 @@
 
 
-  for(int j = j1; j <= j2; j += sampleRate)
+  for(int j = yOffset; j <= j2; j += sampleRate)
   {
     int i = i2;
@@ -266,5 +268,5 @@
 
 
-  for(int j = j1; j <= j2; j += sampleRate)
+  for(int j = yOffset; j <= j2; j += sampleRate)
   {
     int i = i2;
@@ -289,8 +291,8 @@
 
   // link Boarder Stripe
-  for(int j = j1 - sampleRate; j < j2; j += sampleRate)
+  for(int j = yOffset - sampleRate; j < j2; j += sampleRate)
   {
     model->addIndice(cnt);
-    model->addIndice(cnt + (j2 - j1 + sampleRate) / sampleRate );
+    model->addIndice(cnt + (j2 - yOffset + sampleRate) / sampleRate );
     cnt++;
   }
@@ -301,10 +303,10 @@
 
 
-  cnt += (j2-j1)/ sampleRate;
+  cnt += (j2-yOffset)/ sampleRate;
   // link 2nd BoarderStripe
-  for(int j = j1-sampleRate; j < j2;  j += sampleRate)
+  for(int j = yOffset-sampleRate; j < j2;  j += sampleRate)
   {
     model->addIndice(cnt);
-    model->addIndice(cnt + (j2 - j1 + sampleRate) / sampleRate);
+    model->addIndice(cnt + (j2 - yOffset + sampleRate) / sampleRate);
     cnt++;
   }
@@ -441,16 +443,14 @@
 void HeightMap::load()
 {
-  //Create a Dynamicly sized 2D-Array for Tiles
-  tiles =  new Tile** [heightMap->h/tileSize];
-  for(int i=0;i <    heightMap->h/tileSize ; i++)
-    tiles [i]= new (Tile* [heightMap->w /tileSize ]);
-
-  //SetUp Arrays
-  for(int i = 0; i < (heightMap->h  )/ tileSize; i ++)
-  {
-    for(int j = 0; j < (heightMap->w )/ tileSize; j ++)
-    {
-
-      tiles[i][j] =    new Tile( i*tileSize ,  j*tileSize , (i+1)*tileSize, (j+1)*tileSize , this ) ;
+  // create a dynamicly sized 2D-array for tiles
+  this->tiles =  new Tile**[this->heightMap->h / this->tileSize];
+
+  for( int i = 0;i < heightMap->h / tileSize; i++)
+    this->tiles [i]= new Tile*[this->heightMap->w / this->tileSize];
+
+  // setup arrays
+  for( int i = 0; i < this->heightMap->h / this->tileSize; i++)  {
+    for( int j = 0; j < this->heightMap->w / this->tileSize; j++) {
+      this->tiles[i][j] = new Tile( i * tileSize ,  j * tileSize , (i+1) * tileSize, (j+1) * tileSize , this);
     }
   }
Index: /trunk/src/lib/graphics/importer/height_map.h
===================================================================
--- /trunk/src/lib/graphics/importer/height_map.h	(revision 7498)
+++ /trunk/src/lib/graphics/importer/height_map.h	(revision 7499)
@@ -109,6 +109,6 @@
 
   private:
-    SDL_Surface*                          heightMap;
-    SDL_Surface*                          colorMap;
+    SDL_Surface*                          heightMap;                          //!< image of the height map
+    SDL_Surface*                          colorMap;                           //!< image of the color map
     unsigned char*                        heights;
     unsigned char*                        colors;
