Index: /orxonox/trunk/src/world.cc
===================================================================
--- /orxonox/trunk/src/world.cc	(revision 3198)
+++ /orxonox/trunk/src/world.cc	(revision 3199)
@@ -191,45 +191,125 @@
   glBegin(GL_QUADS);
   float height [500][100];
-  float size = 2.0;
-    for ( int i = 0; i<=200; i+=1)
+  Vector normal_vectors[500][100];
+  float size = 2;
+  
+  
+  for ( int i = 0; i<400; i+=1)
+    {
+      for (int j = 0; j<100;j+=1)
+	{
+	    //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
+#ifdef __WIN32__
+	  height[i][j]=(sin((float)j/3)*rand()*i/182400)*.2;
+#else
+	  height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.2;
+#endif
+	}
+    }
+  //Die Hügel ein wenig glätten
+  for (int h=1; h<2;h++)
+    for (int i=1;i<399 ;i+=1 )
+      for(int j=1;j<99;j+=1)
+	height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
+  
+  //Berechnung von normalen Vektoren
+  
+  for(int i=1;i<399;i+=1){
+    for(int j=1;j<99 ;j+=1)
+      
       {
-	for (int j = 0; j<=50;j+=1)
-	  {
-	    height[i][j] = rand()/200321400 + (j-25)*(j-25)/30;
+	Vector* v1 = new Vector (size*i,size*(j-25)-50,height[i][j]-20 );
+	Vector* v2 = new Vector (size*(i+1),size*(j-25)-50,height[i+1][j]-20);
+	Vector* v3 = new Vector (size*(i),size*(j-24)-50,height[i][j+1]-20);
+	Vector* v4 = new Vector (size*(i-1),size*(j-25)-50,height[i-1][j]-20);
+	Vector* v5 = new Vector (size*(i),size*(j-26)-50,height[i][j-1]-20);
+	
+	Vector c1 = *v1 - *v2;
+	Vector c2 = *v1 - *v3;
+	Vector c3= *v1 - *v4;
+	Vector c4 = *v1 - *v5;
+	normal_vectors[i][j]=c1.cross(*v1-*v3)+c2.cross(*v1-*v4)+c3.cross(*v1-*v5)+c4.cross(*v1-*v2);
+	normal_vectors[i][j].normalize();
+	
+	
+	
+	
+	}
+  }
+  int snowheight=3;
+  for ( int i = 0; i<400; i+=1)
+    {
+      for (int j = 0; j<100;j+=1)
+	{	  
+	  Vector* v1 = new Vector (size*i,        size*(j-25)-50,      height[i][j]-20 );
+	  Vector* v2 = new Vector (size*(i+1),    size*(j-25)-50,      height[i+1][j]-20);
+	  Vector* v3 = new Vector (size*(i+1),    size*(j-24)-50,  height[i+1][j+1]-20);
+	  Vector* v4 = new Vector (size*(i),        size*(j-24)-50,  height[i][j+1]-20);
+	  float a[3];
+	  if(height[i][j]<snowheight){
+	    a[0]=0;
+	    a[1]=1.0-height[i][j]/10-.3;
+	    a[2]=0;
+	    glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+	  }
+	  else{
+	    a[0]=1.0;
+	    a[1]=1.0;
+	    a[2]=1.0;
+	    glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
 	    
 	  }
-      }
-    for ( int i = 0; i<=200; i+=1)
-      {
-	for (int j = 0; j<=50;j+=1)
-	  {	  
-	    Vector* v1 = new Vector (size*i,        size*j-25*size,      height[i][j] -20);
-	    Vector* v2 = new Vector (size*i+size,    size*j-25*size,      height[i+1][j]-20);
-	    Vector* v3 = new Vector (size*i+size,    size*j+size-25*size,  height[i+1][j+1]-20);
-	    Vector* v4 = new Vector (size*i,        size*j+size -25*size,  height[i][j+1]-20);
-	    
-	    Vector c1 = *v2 - *v1;
-	    Vector c2 = *v3 - *v2;
-	    Vector c3 = *v4 - *v3;
-	    Vector c4 = *v1 - *v4;
-	    
-	    c1.cross(*v4 - *v1);
-	    c2.cross(*v1 - *v2);
-	    c3.cross(*v2 - *v3);
-	    c4.cross(*v3 - *v4);
-
-
-	    glVertex3f(v1->x, v1->y, v1->z);
-
-	    glVertex3f(v2->x, v2->y, v2->z);
-
-	    glVertex3f(v3->x, v3->y, v3->z);
-	    glNormal3f(c4.x, c4.y, c4.z);
-	    glVertex3f(v4->x, v4->y, v4->z);
-
-	  }
-      }
-glEnd();
-/*  
+		glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
+		glVertex3f(v1->x, v1->y, v1->z);
+		if(height[i+1][j]<snowheight){
+		  a[0]=0;
+		  a[1] =1.0-height[i+1][j]/10-.3;
+		  a[2]=0;
+		  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+		}
+		else{
+		  a[0]=1.0;
+		  a[1]=1.0;
+		  a[2]=1.0;
+		  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+		  
+		}
+		glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
+		glVertex3f(v2->x, v2->y, v2->z);
+		if(height[i+1][j+1]<snowheight){
+		  a[0]=0;
+		  a[1] =1.0-height[i+1][j+1]/10-.3;
+		  a[2]=0;
+		  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+		}
+		else{
+		  a[0]=1.0;
+		  a[1]=1.0;
+		  a[2]=1.0;
+		  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+		  
+		  
+		}
+		glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
+		glVertex3f(v3->x, v3->y, v3->z);
+		if(height[i][j+1]<snowheight){
+		  a[0]=0;
+		  a[1] =1.0-height[i+1][j+1]/10-.3;
+		  a[2]=0;
+		  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+		}
+		else{
+		  a[0]=1.0;
+		  a[1]=1.0;
+		  a[2]=1.0;
+		  glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+		}
+		glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
+		glVertex3f(v4->x, v4->y, v4->z);
+		
+	}
+    }
+  glEnd();
+  /*  
   glBegin(GL_LINES);
   for( float x = -128.0; x < 128.0; x += 25.0)
