Index: /branches/height_map/src/lib/graphics/importer/height_map.cc
===================================================================
--- /branches/height_map/src/lib/graphics/importer/height_map.cc	(revision 6471)
+++ /branches/height_map/src/lib/graphics/importer/height_map.cc	(revision 6472)
@@ -29,4 +29,262 @@
 #include <SDL/SDL_image.h>
 #endif
+
+Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) 
+{
+
+PRINTF(0)("Tile Constructor\n");
+highResModel = new VertexArrayModel();
+lowResModel  = new VertexArrayModel();
+
+this->load(i1,j1,i2,j2,hm,highResModel,4);
+this->load(i1,j1,i2,j2,hm,lowResModel, 32);
+}
+
+Tile::Tile()
+{
+PRINTF(0)("ooops *********************************************************************************************************************************************************************************************************** \n");
+}
+
+Tile::~Tile()
+{
+ delete highResModel;
+ delete lowResModel;
+}
+
+void Tile::draw()
+{
+ lowResModel->draw(); 
+}
+
+void Tile::drawHighRes()
+{
+ highResModel->draw();
+}
+
+void Tile::drawLowRes()
+{
+ lowResModel->draw();
+}
+
+/*
+*/
+void Tile::load(int i1, int j1, int i2, int j2, HeightMap* hm, VertexArrayModel* model, int Res)
+{
+	
+	#define heightMap hm->heightMap
+	#define colours   hm->colours
+	#define scaleX hm->scaleX
+	#define scaleY hm->scaleY
+	#define scaleZ hm->scaleZ
+	#define shiftX hm->shiftX
+	#define shiftY hm->shiftY
+	#define shiftZ hm->shiftZ
+	#define normalVectorField hm->normalVectorField
+	
+	int sampleRate = Res;
+	
+	unsigned char height = 0;
+ 	int offset = 0;
+ 	
+	float r = 0.0;
+	float g = 0.0;
+	float b = 0.0;
+
+ 
+PRINTF(0)("loadin * \n");
+ 
+ if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
+	
+	SDL_LockSurface(heightMap);
+
+	for(int i = i1 ; i <= i2  ; i +=sampleRate)
+	{
+		int w = 0;
+
+		
+		
+		 if(hm->hasColourMap)
+		 {
+		 r = (float)colours[3*w+2 + 3*i*(heightMap->w )];
+		 g = (float)colours[3*w+1 + 3*i*(heightMap->w)];
+		 b = (float)colours[3*w+0 + 3*i*(heightMap->w)];
+		 }
+		
+		w = j1;
+	    	model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
+		model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x);
+		model->addTexCoor((((w -sampleRate)/sampleRate)%4)/4.0,(((i-sampleRate)/sampleRate)%4)/4.0);
+ 		model->addColor(r/255.0,g/255.0,b/255.0);
+		
+	    for(int j = j1  ; j <= j2    ;  j += sampleRate)
+	    {
+	    
+	    
+	    	 // To be fixed
+		 if(hm->hasColourMap)
+		 {
+		 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
+		 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
+		 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
+		 }
+		height =  hm->heights[j+sampleRate + i*(heightMap->w )];
+		model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right	
+		model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
+		model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),((i/sampleRate)%heightMap->h)/float(heightMap->h));
+
+ 		model->addColor(r/255.0,g/255.0,b/255.0);
+		
+		
+		w = j;
+	    }
+		
+		
+		model->addVertex(scaleX*(heightMap->h -i)+ shiftX,shiftY,scaleZ*(w)+ shiftZ); // Top Right
+		model->addNormal(normalVectorField[i][w].y,normalVectorField[i][w].z,normalVectorField[i][w].x);
+		model->addTexCoor((((w+sampleRate)/sampleRate)%4)/4.0,(((i+ sampleRate)/sampleRate)%4)/4.0);
+ 		model->addColor(r/255.0,g/255.0,b/255.0);
+		
+	}
+	
+	
+	
+
+
+	SDL_UnlockSurface(heightMap);
+	int cnt = 0;
+	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)
+	    {
+	    	int i = i1;
+	    
+	    	 // To be fixed
+		 if(hm->hasColourMap)
+		 {
+		 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
+		 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
+		 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
+		 }
+		
+		model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right	
+		model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
+		model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i - sampleRate)/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate) /sampleRate)%heightMap->h)/float(heightMap->h));
+ 		model->addColor(r/255.0,g/255.0,b/255.0);		
+	
+	    }
+
+	        for(int j = j1  ; j <= j2    ;  j += sampleRate)
+	    {
+	    	int i = i1;
+	    	height =  hm->heights[j+sampleRate + i*(heightMap->w )];
+		model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right	
+		model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
+		model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i)/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i)/sampleRate)%heightMap->h)/float(heightMap->h));
+ 		model->addColor(r/255.0,g/255.0,b/255.0);
+	    
+	    }
+	    
+	        
+	    
+	    for(int j = j1  ; j <= j2    ;  j += sampleRate)
+	    {
+	    	int i = i2;
+	    
+	    	 // To be fixed
+		 if(hm->hasColourMap)
+		 {
+		 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
+		 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
+		 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
+		 }
+		
+		model->addVertex(scaleX*(heightMap->h -i) + shiftX , shiftY ,scaleZ*(j) + shiftZ); // Top Right	
+		model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
+		model->addTexCoor(((j/sampleRate)%texRate)/texRatef,(((i- sampleRate)/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),(((i - sampleRate)/sampleRate)%heightMap->h)/float(heightMap->h));
+ 		model->addColor(r/255.0,g/255.0,b/255.0);		
+	
+	    }
+	    	    
+	    
+	    for(int j = j1 ; j <= j2    ;  j += sampleRate)
+	    {
+	    	int i = i2;
+	    	height =  hm->heights[j+sampleRate + i*(heightMap->w )];
+		model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right	
+		model->addNormal(normalVectorField[i][j].y,normalVectorField[i][j].z,normalVectorField[i][j].x);
+		model->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef, ((j/sampleRate)%heightMap->w)/float(heightMap->w),((i/sampleRate)%heightMap->h)/float(heightMap->h));
+ 		model->addColor(r/255.0,g/255.0,b/255.0);
+	    
+	    }
+	   
+
+	
+	
+	 // link Boarder Stripe
+	    for(int j = j1-sampleRate  ; j < j2    ;  j += sampleRate)
+	    {
+		
+	    	model->addIndice(cnt);
+		model->addIndice(cnt  + (j2 -j1 +  sampleRate  )/ sampleRate );
+		cnt++;
+		
+	    }
+	    	
+	    	cnt++;
+	    	
+		 model->newStripe();	
+		
+		
+	
+	
+	
+	 cnt += (j2-j1)/ sampleRate;
+	
+	// link 2nd BoarderStripe
+	    for(int j = j1-sampleRate  ; j < j2    ;  j += sampleRate)
+	    {
+		
+	    	model->addIndice(cnt);
+		model->addIndice(cnt  + (j2 -j1 +  sampleRate  )/ sampleRate );
+		cnt++;
+		
+	    }
+	 
+	    
+	
+	 model->finalize();
+	 
+	 
+	 
+	 
+	#undef heightMap 
+	#undef colours   
+	#undef scaleX 
+	#undef scaleY 
+	#undef scaleZ 
+	#undef shiftX 
+	#undef shiftY 
+	#undef shiftZ 
+	#undef normalVectorField 
+	 
+}
 
 HeightMap::HeightMap()
@@ -86,8 +344,9 @@
     generateNormalVectorField();
 
-
+  colourMap=NULL;
   if(colour_map_name != NULL)
   {
   colourMap = IMG_Load(colour_map_name);
+  }
   if(colourMap != NULL)
   		{
@@ -102,5 +361,5 @@
 		 PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask);
 		 }
-		 else       PRINTF(4)("oops! couldn't load %s for some reason.\n", colour_map_name);
+		 else       PRINTF(0)("oops! couldn't load colorMap for some reason.\n");
 
 		 
@@ -114,8 +373,5 @@
   
 	
-  shiftX = 0;
-  shiftY = 0;
-  shiftZ = 0;
-  }
+   heights  = (unsigned char*) heightMap->pixels;
 
 
@@ -129,90 +385,88 @@
 {
 
-unsigned char height = 0;
- int offset = 0;
- int g = 0;
- 
-
- 
- heights  = (unsigned char*) heightMap->pixels;
-
-
-
- 
- if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
-	
-	SDL_LockSurface(heightMap);
-
-     
-	for(int i = 0 ; i < heightMap->h -sampleRate ; i +=sampleRate)
-	{
-		int j = 0;
-
-		float r;
-		float g;
-		float b;
-	    for(int j = 0 ; j < heightMap->w -sampleRate  ;  j += sampleRate)
-	    {
-	    	 // To be fixed
-		 r = (float)colours[3*j+2 + 3*i*(heightMap->w )];
-		 g = (float)colours[3*j+1 + 3*i*(heightMap->w)];
-		 b = (float)colours[3*j+0 + 3*i*(heightMap->w)];
-		
-			height =  heights[j+sampleRate + i*(heightMap->w )];
-		this->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j+sampleRate) + shiftZ); // Top Right
-
-	
-		this->addNormal(normalVectorField[i][j+sampleRate].y,normalVectorField[i][j+sampleRate].z,normalVectorField[i][j+sampleRate].x);
-		this->addTexCoor(((j/sampleRate)%texRate)/texRatef,((i/sampleRate)%texRate)/texRatef);
-
- 		this->addColor(r/255.0,g/255.0,b/255.0);
-
-
-	    }
-		
-	    
-		 j = (heightMap->w/sampleRate - sampleRate);
-
-		this->addVertex(scaleX*(heightMap->h -i)+ shiftX,-1000.0,scaleZ*(j+sampleRate)+ shiftZ); // Top Right
-
-		this->addNormal(normalVectorField[i][j+sampleRate].y,normalVectorField[i][j+sampleRate].z,normalVectorField[i][j+sampleRate].x);
-		this->addTexCoor(((j/sampleRate)%4)/4.0,((i/sampleRate)%4)/4.0);
- 		this->addColor(0.1,0.1,0.9);
-					
-
-		
-
-		}
-
-	SDL_UnlockSurface(heightMap);
-
-
-	int cnt = 0;
-	for(int i = 0 ; i < heightMap->h - 2*sampleRate ; i +=sampleRate)
-	{
-		
-	    for(int j = 0 ; j < heightMap->w - sampleRate  ;  j += sampleRate)
-	    {
-		
-	    	this->addIndice(cnt);
-		this->addIndice(cnt  + (heightMap->w)/ sampleRate );
-		cnt++;
-		
-	    }
-	    	
-	    	cnt++;
-		 this->newStripe();	
-		
-		
+//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 )/ tileSize; i ++)
+{
+	for(int j = 0; j < (heightMap->w - tileSize )/ tileSize; j ++)
+	{
+	 
+	 tiles[i][j] =    new Tile( i*tileSize ,  j*tileSize , (i+1)*tileSize, (j+1)*tileSize , this ) ;
 	}
-
-	this->finalize();
-
-
-}
-
-
-
-
+}
+
+}
+
+
+void HeightMap::draw() 
+{
+const PNode* camera = State::getCamera();
+Vector v = camera->getAbsCoor();
+
+int i_min = 1;
+int i_max = (heightMap->h - tileSize)/ tileSize;
+int j_min = 1;
+int j_max= (heightMap->w - tileSize) / tileSize;
+
+// calc i_min , i_max j_min and j_maxt 
+
+int centerX =  (int)((heightMap->h - ((v.x - shiftX)/ (float)scaleX ))/ tileSize);
+int  centerY = (int)((v.z - shiftZ)/ (float)scaleZ )/ tileSize;
+//PRINTF(0)("i_max %i \n" , i_max);
+//PRINTF(0)("CENTERY %i \n ",centerY );
+i_min = max(centerX  -1, i_min);
+i_max = min(centerX +2 , i_max );
+
+j_min = max(centerY -1,1);
+j_max = min(centerY +2, j_max);
+
+
+for(int i = 1; i <  i_min	 ; i ++)
+{
+	for(int j = 1; j < j_max ; j++)
+	{
+	 	
+	 tiles[i][j]->drawLowRes();
+	}	
+} 
+for(int i = i_min; i <  i_max	 ; i ++)
+{
+	for(int j = j_min; j < j_max ; j++)
+	{
+	 	
+	 tiles[i][j]->drawHighRes();
+	}	
+}
+
+for(int i = i_max; i <  (heightMap->h -tileSize)/tileSize	 ; i ++)
+{
+	for(int j = 1; j < j_max ; j++)
+	{
+	 	
+	 tiles[i][j]->drawLowRes();
+	}	
+}
+
+
+for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++ )
+{
+	for(int j = 1; j < j_min; j++)
+	{
+	 tiles[i][j]->drawLowRes();
+	}
+}
+for(int i = 1; i < (heightMap->h -tileSize)/tileSize; i++) 
+{
+	for(int j = j_max; j < (heightMap->w -tileSize)/tileSize; j++ )
+	{
+	tiles[i][j]->drawLowRes();
+	}
+}
+
+}
 void HeightMap::generateNormalVectorField()
 {
@@ -227,5 +481,5 @@
 
 
-// !!! Does not yet calculate any normals for some border points!!!!!
+// !!! Does not yet calculate the normals of some border points!!!!!
 
 if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
Index: /branches/height_map/src/lib/graphics/importer/height_map.h
===================================================================
--- /branches/height_map/src/lib/graphics/importer/height_map.h	(revision 6471)
+++ /branches/height_map/src/lib/graphics/importer/height_map.h	(revision 6472)
@@ -16,7 +16,8 @@
 #include "vertex_array_model.h"
 
-#define sampleRate 4
-#define texRate   4
-#define texRatef   4.0f
+
+#define texRate      4
+#define texRatef     4.0f
+#define tileSize     64
 
 class SDL_Surface;
@@ -25,9 +26,32 @@
 class PNode;
 class Texture;
+class HeightMap;
+
+class Tile 
+{
+public:
+void draw();
+void drawHighRes();
+void drawLowRes();
+int getRes();
+int setHighRes(bool b);
+Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) ;
+Tile();
+~Tile();
+
+
+
+private:
+VertexArrayModel* highResModel;
+VertexArrayModel* lowResModel; 
+int highRes;
+int lowRes;
+void load(int i1, int j1, int i2, int i2, HeightMap* hm, VertexArrayModel* model, int Res);
+};
 
 class HeightMap : public VertexArrayModel
 {
 public:
-
+void draw();
 void load();
 void load(int Mode);
@@ -41,4 +65,5 @@
 ~HeightMap();
 
+friend class Tile;
 
 private:
@@ -47,8 +72,10 @@
 unsigned char* heights; 
 unsigned char* colours;
+
 void generateNormalVectorField();
 void drawRect(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight );
 void fixBoarder(int xBottomLeft, int yBottomLeft, int xTopRight, int yTopRight);
 Vector  **  normalVectorField ; 
+Tile    ***  tiles;
 Vector     camCoords;
 Material * tmp_mat;
@@ -71,4 +98,11 @@
  return val;
 }
-
+inline int max(int x, int y)
+{
+ return (x>y)? x:y;
+}
+inline int min(int x, int y)
+{
+return (x<y)? x: y;
+}
 };
Index: /branches/height_map/src/lib/graphics/importer/static_model.cc
===================================================================
--- /branches/height_map/src/lib/graphics/importer/static_model.cc	(revision 6471)
+++ /branches/height_map/src/lib/graphics/importer/static_model.cc	(revision 6472)
@@ -227,4 +227,8 @@
 void StaticModel::draw () const
 {
+
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
   PRINTF(4)("drawing the 3D-Models\n");
   ModelGroup* tmpGroup = this->firstGroup;
@@ -246,4 +250,8 @@
 void StaticModel::draw (int groupNumber) const
 {
+
+	 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
   if (unlikely(groupNumber >= this->groupCount))
     {
@@ -278,4 +286,8 @@
 void StaticModel::draw (char* groupName) const
 {
+
+	 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
   if (groupName == NULL)
      return;
Index: /branches/height_map/src/lib/graphics/importer/texture.cc
===================================================================
--- /branches/height_map/src/lib/graphics/importer/texture.cc	(revision 6471)
+++ /branches/height_map/src/lib/graphics/importer/texture.cc	(revision 6472)
@@ -252,5 +252,5 @@
   glBindTexture(GL_TEXTURE_2D, texture);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
   // build the Texture
   glTexImage2D(GL_TEXTURE_2D,
@@ -271,4 +271,7 @@
                     surface->pixels);
   glBindTexture(GL_TEXTURE_2D, 0);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
   return texture;
 }
Index: /branches/height_map/src/lib/graphics/importer/vertex_array_model.cc
===================================================================
--- /branches/height_map/src/lib/graphics/importer/vertex_array_model.cc	(revision 6471)
+++ /branches/height_map/src/lib/graphics/importer/vertex_array_model.cc	(revision 6472)
@@ -17,5 +17,5 @@
 
 #include "vertex_array_model.h"
-
+#include "texture.h"
 #include "stdlibincl.h"
 #include <stdarg.h>
@@ -33,4 +33,12 @@
 VertexArrayModel::VertexArrayModel()
 {
+
+   this->tex1 = new Texture("pictures/ground.tga");
+  this->tex1->setName("test1");
+  this->tex2 = new Texture("pictures/heightmapHelloCM.bmp");
+  this->tex2->setName("test2");
+
+  
+  
   this->setClassID(CL_MODEL, "VertexArrayModel");
 
@@ -67,14 +75,40 @@
 {
   PRINTF(4)("drawing 3D-VertexArrayModel %s\n", this->getName());
+  //1glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ 
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+   
+// glEnable(GL_LIGHTING);
+ glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
+  glEnable (GL_COLOR_MATERIAL) ;
+
+ 
+
+   // glBindTexture(GL_TEXTURE_2D, this->tex1->getTexture());
+
+ // glEnable(GL_TEXTURE_2D);
+
+  
+    
+    
+   
+   
+   
+  glEnableClientState(GL_TEXTURE_COORD_ARRAY );
+  glTexCoordPointer(2, GL_FLOAT, 0, &this->texCoords1[0]);
+  
+ 
+ 
   glEnableClientState(GL_VERTEX_ARRAY );
-  glEnableClientState(GL_TEXTURE_COORD_ARRAY );
+   glVertexPointer(3, GL_FLOAT, 0, &this->vertices[0]);
   glEnableClientState(GL_NORMAL_ARRAY );
+    glNormalPointer(GL_FLOAT, 0, &this->normals[0]);
   glEnableClientState(GL_COLOR_ARRAY );
-
-
-  glVertexPointer(3, GL_FLOAT, 0, &this->vertices[0]);
-  glNormalPointer(GL_FLOAT, 0, &this->normals[0]);
-  glTexCoordPointer(2, GL_FLOAT, 0, &this->texCoords[0]);
-  glColorPointer(3, GL_FLOAT, 0, &this->colors[0]);
+glColorPointer(3, GL_FLOAT, 0, &this->colors[0]);
+//glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ 
+
+
+  
 
   for (GLuint i = 1; i < this->stripes.size(); ++i)
@@ -85,4 +119,7 @@
                       &this->indices[this->stripes[i-1]] );
     }
+    
+    
+    glPopAttrib();
 }
 
@@ -141,8 +178,18 @@
  *  If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
  */
+void VertexArrayModel::addTexCoor(float u, float v, float w, float x)
+{
+  this->texCoords1.push_back(u);
+  this->texCoords1.push_back(v);
+  this->texCoords2.push_back(w);
+  this->texCoords2.push_back(x);
+  this->pModelInfo.numTexCoor++;
+}
 void VertexArrayModel::addTexCoor(float u, float v)
 {
-  this->texCoords.push_back(u);
-  this->texCoords.push_back(v);
+  this->texCoords1.push_back(u);
+  this->texCoords1.push_back(v);
+  this->texCoords2.push_back(0.0);
+  this->texCoords2.push_back(0.0);
   this->pModelInfo.numTexCoor++;
 }
@@ -291,5 +338,5 @@
             this->vertices.size()/3,
             this->normals.size()/3,
-            this->texCoords.size()/2,
+            this->texCoords1.size()/2,
             this->colors.size() )/3;
   for (GLuint i = 1; i < this->stripes.size(); ++i)
Index: /branches/height_map/src/lib/graphics/importer/vertex_array_model.h
===================================================================
--- /branches/height_map/src/lib/graphics/importer/vertex_array_model.h	(revision 6471)
+++ /branches/height_map/src/lib/graphics/importer/vertex_array_model.h	(revision 6472)
@@ -15,5 +15,5 @@
 /* Forward Declaration */
 class Material;
-
+class Texture;
 
 /////////////
@@ -37,5 +37,6 @@
   void addVertex(float x, float y, float z);
   void addNormal(float x, float y, float z);
-  void addTexCoor(float u, float v);
+  void addTexCoor(float u, float v, float w, float x);
+   void addTexCoor(float u, float v);
   void addColor(float r, float g, float b);
 
@@ -58,5 +59,6 @@
   std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
   std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
-  std::vector<GLfloat>       texCoords;       //!< The Array that handles the VertexTextureCoordinates.
+  std::vector<GLfloat>       texCoords1;       //!< The Array that handles the VertexTextureCoordinates.
+  std::vector<GLfloat>       texCoords2;       //!< The Array that handles the VertexTextureCoordinates.  
   std::vector<GLfloat>       colors;          //!< The Array that handles Colors.
 
@@ -64,5 +66,8 @@
 
   std::vector<GLuint>        stripes;         //!< A lsit of Stripes of this Model.
-
+  
+  Texture* tex1;
+  Texture* tex2;
+ 
 };
 
Index: /branches/height_map/src/world_entities/terrain.cc
===================================================================
--- /branches/height_map/src/world_entities/terrain.cc	(revision 6471)
+++ /branches/height_map/src/world_entities/terrain.cc	(revision 6472)
@@ -58,5 +58,5 @@
   tmp_mat->specularTexture = NULL;
   
-    const  char* texture_name = "pictures/ground1.tga";
+    const  char* texture_name = "pictures/ground.tga";
   tmp_mat->setDiffuseMap(texture_name);
   tmp_mat->setAmbientMap(texture_name);
@@ -67,6 +67,6 @@
  char* colourmapName = ResourceManager::getFullName("pictures/heightmapHelloCM.bmp");
  hm = new HeightMap(heightmapName, colourmapName);
- hm->scale(Vector(43.0f,1.10f,43.0f));
- hm->shift(Vector(-1000.0,-1500.0,-1000.0));
+ hm->scale(Vector(23.0f,0.7f,23.0f));
+ hm->shift(Vector(-1000.0,-90.0,-4000.0));
  hm->load();
  this->model=hm;
@@ -235,4 +235,5 @@
  
  this->tmp_mat->select();
+    
  hm->draw();
  /* if (this->objectList)
