Index: trunk/src/lib/graphics/effects/lense_flare.cc
===================================================================
--- trunk/src/lib/graphics/effects/lense_flare.cc	(revision 7013)
+++ trunk/src/lib/graphics/effects/lense_flare.cc	(revision 7014)
@@ -202,6 +202,6 @@
 
     //set the frustum plane
-  Vector psTarget = (State::getCameraTarget())->getAbsCoor();
-  Vector psCamera = (State::getCamera())->getAbsCoor();
+  Vector psTarget = (State::getCameraTargetNode())->getAbsCoor();
+  Vector psCamera = (State::getCameraNode())->getAbsCoor();
   Vector psCameraDir = psCamera - psTarget;
   //PRINTF(0)("camera Dir: %f %f %f, camera: %f %f %f\n", psCameraDir.x, psCameraDir.y, psCameraDir.z, psCamera.x, psCamera.y, psCamera.z);
Index: trunk/src/lib/graphics/importer/height_map.cc
===================================================================
--- trunk/src/lib/graphics/importer/height_map.cc	(revision 7013)
+++ trunk/src/lib/graphics/importer/height_map.cc	(revision 7014)
@@ -30,5 +30,5 @@
 #endif
 
-Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm ) 
+Tile::Tile(int i1, int j1, int i2, int j2, HeightMap* hm )
 {
 
@@ -54,8 +54,8 @@
 void Tile::draw()
 {
-	 // This Draws the LOD's
-	 							//FIXME
-    float cameraDistance = (State::getCamera()->getAbsCoor() - Vector(this->x, hmref->offsetY , this->z) ).len();
-	if(cameraDistance < 0) cameraDistance = -cameraDistance;
+         // This Draws the LOD's
+                                                                //FIXME
+    float cameraDistance = (State::getCameraNode()->getAbsCoor() - Vector(this->x, hmref->offsetY , this->z) ).len();
+        if(cameraDistance < 0) cameraDistance = -cameraDistance;
     if(cameraDistance > 5000 )
     {
@@ -66,5 +66,5 @@
       this->drawLowRes();
     }
-    else 
+    else
     {
       this->drawHighRes();
@@ -86,244 +86,244 @@
 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
-	
-	hmref = hm; // FIXME
-	
-	this->x = hm->offsetX + (heightMap->h - ((i1+i2)/2))*scaleX;
-	this->z = hm->offsetZ + ((j1 + j2 )/2 )	* scaleZ;
-	
-	int sampleRate = Res;
-	
-	float height = 0;
- 	int offset = 0;
- 	
-	float r = 0.0;
-	float g = 0.0;
-	float b = 0.0;
-
- 
-
- 
+
+        #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
+
+        hmref = hm; // FIXME
+
+        this->x = hm->offsetX + (heightMap->h - ((i1+i2)/2))*scaleX;
+        this->z = hm->offsetZ + ((j1 + j2 )/2 ) * scaleZ;
+
+        int sampleRate = Res;
+
+        float height = 0;
+        int offset = 0;
+
+        float r = 0.0;
+        float g = 0.0;
+        float b = 0.0;
+
+
+
+
  if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
-	
-	SDL_LockSurface(heightMap);
-	SDL_LockSurface(hm->colourMap);
-	
-	for(int i = i1 ; i <= i2  ; i +=sampleRate)
-	{
-		int w = 0;
-
-		
-		
-		 if(hm->hasColourMap)
-		 {
-		 r = colours[(3*w+2 + 3*i*(heightMap->w )) ];
-		 g = colours[(3*w+1 + 3*i*(heightMap->w)) ];
-		 b = 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 % heightMap->h][w % heightMap->w].y,normalVectorField[i % heightMap->h][w % heightMap->w].z,normalVectorField[i % heightMap->h][w % heightMap->w].x);
-		model->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %heightMap->h)/(texRate));
-		
- 		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 = colours[(3*j+2 + 3*i*(heightMap->w )) ];
-		 g =  colours[(3*j+1 + 3*i*(heightMap->w)) ];
-		 b =  colours[(3*j+0 + 3*i*(heightMap->w))];
-		 }
-		height = (float)(unsigned char) hm->heights[(j +sampleRate+ i*(heightMap->w )) ];
-		height += (float)(unsigned char) hm->heights[(j+ 1 + sampleRate + (i+1)*(heightMap->w )) ];
-		height +=  (float) (unsigned char) hm->heights[(j -1+ sampleRate   + (i+1)*(heightMap->w ))];
-		height +=  (float)(unsigned char)hm->heights[(j +sampleRate+ (i+2)*(heightMap->w )) ];
-		height +=  (float)(unsigned char)hm->heights[(j+sampleRate + (i)*(heightMap->w )) ];
-		height=height/5.0;
-		
-		model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right	
-		model->addNormal(normalVectorField[i % heightMap->h][j % heightMap->w].y,normalVectorField[i % heightMap->h][j % heightMap->w].z,normalVectorField[i % heightMap->h][j % heightMap->w].x);
-		model->addTexCoor((float)(j) /(texRate), (float)(i %heightMap->h)/(texRate));
-		
-		//PRINTF(0)("TexCoord:  %f %f \n",(float)j / 100.0, (float)(i %heightMap->h)/100.0);
-		
- 		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 % heightMap->h][w % heightMap->w].y,normalVectorField[i % heightMap->h][w % heightMap->w].z,normalVectorField[i% heightMap->h][w % heightMap->w].x);
-		model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %heightMap->h)/(texRate));
- 		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 % heightMap->h][j % heightMap->w].y,normalVectorField[i % heightMap->h][j % heightMap->w].z,normalVectorField[i % heightMap->h][j % heightMap->w].x);
-		model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %heightMap->h)/(texRate));
- 		model->addColor(r/255.0,g/255.0,b/255.0);		
-	
-	    }
-
-	        for(int j = j1  ; j <= j2    ;  j += sampleRate)
-	    {
-	    	int i = i1;
-		height = (float)(unsigned char) hm->heights[(j +sampleRate+ i*(heightMap->w )) ];
-		height += (float)(unsigned char) hm->heights[(j+ 1 + sampleRate + (i+1)*(heightMap->w )) ];
-		height +=  (float) (unsigned char) hm->heights[(j -1+ sampleRate   + (i+1)*(heightMap->w ))];
-		height +=  (float)(unsigned char)hm->heights[(j +sampleRate+ (i+2)*(heightMap->w )) ];
-		height +=  (float)(unsigned char)hm->heights[(j+sampleRate + (i)*(heightMap->w )) ];
-		height=height/5.0;
-		
-		model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right	
-		model->addNormal(normalVectorField[i % heightMap->h][j % heightMap->w].y,normalVectorField[i % heightMap->h][j% heightMap->w].z,normalVectorField[i%heightMap->h][j%heightMap->w].x);
-		model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate));
- 		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%heightMap->h][j%heightMap->w].y,normalVectorField[i%heightMap->h][j%heightMap->w].z,normalVectorField[i%heightMap->h][j%heightMap->w].x);
-		model->addTexCoor((float)j /(texRate), (float)((i+ sampleRate) %heightMap->h)/(texRate));
- 		model->addColor(r/255.0,g/255.0,b/255.0);		
-	
-	    }
-	    	    
-	    
-	    for(int j = j1 ; j <= j2    ;  j += sampleRate)
-	    {
-	    	int i = i2;
-		height = (float)(unsigned char) hm->heights[(j +sampleRate+ i*(heightMap->w )) ];
-		height += (float)(unsigned char) hm->heights[(j+ 1 + sampleRate + (i+1)*(heightMap->w )) ];
-		height +=  (float) (unsigned char) hm->heights[(j -1+ sampleRate   + (i+1)*(heightMap->w ))];
-		height +=  (float)(unsigned char)hm->heights[(j +sampleRate+ (i+2)*(heightMap->w ))];
-		height +=  (float)(unsigned char)hm->heights[(j+sampleRate + (i)*(heightMap->w )) ];
-		height=height/5.0;
-		model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right	
-		model->addNormal(normalVectorField[i%heightMap->h][j%heightMap->w].y,normalVectorField[i%heightMap->h][j%heightMap->w].z,normalVectorField[i%heightMap->h][j%heightMap->w].x);
-		model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate));
- 		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++;
-		
-	    }
-	 
-	    
-	    SDL_UnlockSurface(hm->colourMap);
-	
-	 model->finalize();
-	 
-	 
-	 
-	 
-	#undef heightMap 
-	#undef colours   
-	#undef scaleX 
-	#undef scaleY 
-	#undef scaleZ 
-	#undef shiftX 
-	#undef shiftY 
-	#undef shiftZ 
-	#undef normalVectorField 
-	 
+
+        SDL_LockSurface(heightMap);
+        SDL_LockSurface(hm->colourMap);
+
+        for(int i = i1 ; i <= i2  ; i +=sampleRate)
+        {
+                int w = 0;
+
+
+
+                 if(hm->hasColourMap)
+                 {
+                 r = colours[(3*w+2 + 3*i*(heightMap->w )) ];
+                 g = colours[(3*w+1 + 3*i*(heightMap->w)) ];
+                 b = 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 % heightMap->h][w % heightMap->w].y,normalVectorField[i % heightMap->h][w % heightMap->w].z,normalVectorField[i % heightMap->h][w % heightMap->w].x);
+                model->addTexCoor((float)(j1-sampleRate) /(texRate), (float)(i %heightMap->h)/(texRate));
+
+                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 = colours[(3*j+2 + 3*i*(heightMap->w )) ];
+                 g =  colours[(3*j+1 + 3*i*(heightMap->w)) ];
+                 b =  colours[(3*j+0 + 3*i*(heightMap->w))];
+                 }
+                height = (float)(unsigned char) hm->heights[(j +sampleRate+ i*(heightMap->w )) ];
+                height += (float)(unsigned char) hm->heights[(j+ 1 + sampleRate + (i+1)*(heightMap->w )) ];
+                height +=  (float) (unsigned char) hm->heights[(j -1+ sampleRate   + (i+1)*(heightMap->w ))];
+                height +=  (float)(unsigned char)hm->heights[(j +sampleRate+ (i+2)*(heightMap->w )) ];
+                height +=  (float)(unsigned char)hm->heights[(j+sampleRate + (i)*(heightMap->w )) ];
+                height=height/5.0;
+
+                model->addVertex(scaleX*(heightMap->h -i) + shiftX ,((double)(height)*scaleY) + shiftY ,scaleZ*(j) + shiftZ); // Top Right
+                model->addNormal(normalVectorField[i % heightMap->h][j % heightMap->w].y,normalVectorField[i % heightMap->h][j % heightMap->w].z,normalVectorField[i % heightMap->h][j % heightMap->w].x);
+                model->addTexCoor((float)(j) /(texRate), (float)(i %heightMap->h)/(texRate));
+
+                //PRINTF(0)("TexCoord:  %f %f \n",(float)j / 100.0, (float)(i %heightMap->h)/100.0);
+
+                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 % heightMap->h][w % heightMap->w].y,normalVectorField[i % heightMap->h][w % heightMap->w].z,normalVectorField[i% heightMap->h][w % heightMap->w].x);
+                model->addTexCoor((float)(j2+sampleRate) /(texRate), (float)(i %heightMap->h)/(texRate));
+                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 % heightMap->h][j % heightMap->w].y,normalVectorField[i % heightMap->h][j % heightMap->w].z,normalVectorField[i % heightMap->h][j % heightMap->w].x);
+                model->addTexCoor((float)j /(texRate), (float)((i - sampleRate) %heightMap->h)/(texRate));
+                model->addColor(r/255.0,g/255.0,b/255.0);
+
+            }
+
+                for(int j = j1  ; j <= j2    ;  j += sampleRate)
+            {
+                int i = i1;
+                height = (float)(unsigned char) hm->heights[(j +sampleRate+ i*(heightMap->w )) ];
+                height += (float)(unsigned char) hm->heights[(j+ 1 + sampleRate + (i+1)*(heightMap->w )) ];
+                height +=  (float) (unsigned char) hm->heights[(j -1+ sampleRate   + (i+1)*(heightMap->w ))];
+                height +=  (float)(unsigned char)hm->heights[(j +sampleRate+ (i+2)*(heightMap->w )) ];
+                height +=  (float)(unsigned char)hm->heights[(j+sampleRate + (i)*(heightMap->w )) ];
+                height=height/5.0;
+
+                model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right
+                model->addNormal(normalVectorField[i % heightMap->h][j % heightMap->w].y,normalVectorField[i % heightMap->h][j% heightMap->w].z,normalVectorField[i%heightMap->h][j%heightMap->w].x);
+                model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate));
+                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%heightMap->h][j%heightMap->w].y,normalVectorField[i%heightMap->h][j%heightMap->w].z,normalVectorField[i%heightMap->h][j%heightMap->w].x);
+                model->addTexCoor((float)j /(texRate), (float)((i+ sampleRate) %heightMap->h)/(texRate));
+                model->addColor(r/255.0,g/255.0,b/255.0);
+
+            }
+
+
+            for(int j = j1 ; j <= j2    ;  j += sampleRate)
+            {
+                int i = i2;
+                height = (float)(unsigned char) hm->heights[(j +sampleRate+ i*(heightMap->w )) ];
+                height += (float)(unsigned char) hm->heights[(j+ 1 + sampleRate + (i+1)*(heightMap->w )) ];
+                height +=  (float) (unsigned char) hm->heights[(j -1+ sampleRate   + (i+1)*(heightMap->w ))];
+                height +=  (float)(unsigned char)hm->heights[(j +sampleRate+ (i+2)*(heightMap->w ))];
+                height +=  (float)(unsigned char)hm->heights[(j+sampleRate + (i)*(heightMap->w )) ];
+                height=height/5.0;
+                model->addVertex(scaleX*(heightMap->h -i) + shiftX , ((double)(height)*scaleY) +shiftY ,scaleZ*(j) + shiftZ); // Top Right
+                model->addNormal(normalVectorField[i%heightMap->h][j%heightMap->w].y,normalVectorField[i%heightMap->h][j%heightMap->w].z,normalVectorField[i%heightMap->h][j%heightMap->w].x);
+                model->addTexCoor((float)j /(texRate), (float)(i %heightMap->h)/(texRate));
+                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++;
+
+            }
+
+
+            SDL_UnlockSurface(hm->colourMap);
+
+         model->finalize();
+
+
+
+
+        #undef heightMap
+        #undef colours
+        #undef scaleX
+        #undef scaleY
+        #undef scaleZ
+        #undef shiftX
+        #undef shiftY
+        #undef shiftZ
+        #undef normalVectorField
+
 }
 
@@ -339,18 +339,18 @@
    if(heightMap!=NULL) {
 
-		 PRINTF(0)("loading Image %s\n", height_map_name);
-		 PRINTF(0)("width : %i\n", heightMap->w);
-		 PRINTF(0)("height : %i\n", heightMap->h);
-		 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
-		 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
-		 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
-		 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
-		 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
-		 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
-		}
+                 PRINTF(0)("loading Image %s\n", height_map_name);
+                 PRINTF(0)("width : %i\n", heightMap->w);
+                 PRINTF(0)("height : %i\n", heightMap->h);
+                 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
+                 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
+                 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
+                 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
+                 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
+                 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
+                }
 
      else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
 
-	
+
   generateNormalVectorField();
 
@@ -368,14 +368,14 @@
    if(heightMap!=NULL) {
 
-		 PRINTF(0)("loading Image %s\n", height_map_name);
-		 PRINTF(0)("width : %i\n", heightMap->w);
-		 PRINTF(0)("height : %i\n", heightMap->h);
-		 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
-		 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
-		 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
-		 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
-		 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
-		 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
-		}
+                 PRINTF(0)("loading Image %s\n", height_map_name);
+                 PRINTF(0)("width : %i\n", heightMap->w);
+                 PRINTF(0)("height : %i\n", heightMap->h);
+                 PRINTF(0)("%i Byte(s) per Pixel \n", heightMap->format->BytesPerPixel);
+                 PRINTF(0)("Rshift : %i\n", heightMap->format->Rshift);
+                 PRINTF(0)("Bshift: %i\n", heightMap->format->Bshift);
+                 PRINTF(0)("Gshift: %i\n", heightMap->format->Gshift);
+                 PRINTF(0)("Rmask: %i\n", heightMap->format->Rmask);
+                 PRINTF(0)("Gmask: %i\n", heightMap->format->Gmask);
+                }
 
      else       PRINTF(4)("oops! couldn't load %s for some reason.\n", height_map_name);
@@ -389,21 +389,21 @@
   colourMap = IMG_Load(colour_map_name);
   }
-  
+
   if(colourMap != NULL)
-  		{
-  		 PRINTF(0)("loading Image %s\n", colour_map_name);
-		 PRINTF(0)("width : %i\n", colourMap->w);
-		 PRINTF(0)("height : %i\n", colourMap->h);
-		 PRINTF(0)("%i Byte(s) per Pixel \n", colourMap->format->BytesPerPixel);
-		 PRINTF(0)("Rshift : %i\n", colourMap->format->Rshift);
-		 PRINTF(0)("Bshift: %i\n", colourMap->format->Bshift);
-		 PRINTF(0)("Gshift: %i\n", colourMap->format->Gshift);
-		 PRINTF(0)("Rmask: %i\n", colourMap->format->Rmask);
-		 PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask);
-		 }
-		 else       PRINTF(0)("oops! couldn't load colorMap for some reason.\n");
-
-		 
-		   
+                {
+                 PRINTF(0)("loading Image %s\n", colour_map_name);
+                 PRINTF(0)("width : %i\n", colourMap->w);
+                 PRINTF(0)("height : %i\n", colourMap->h);
+                 PRINTF(0)("%i Byte(s) per Pixel \n", colourMap->format->BytesPerPixel);
+                 PRINTF(0)("Rshift : %i\n", colourMap->format->Rshift);
+                 PRINTF(0)("Bshift: %i\n", colourMap->format->Bshift);
+                 PRINTF(0)("Gshift: %i\n", colourMap->format->Gshift);
+                 PRINTF(0)("Rmask: %i\n", colourMap->format->Rmask);
+                 PRINTF(0)("Gmask: %i\n", colourMap->format->Gmask);
+                 }
+                 else       PRINTF(0)("oops! couldn't load colorMap for some reason.\n");
+
+
+
   if(colourMap != NULL)
   {
@@ -412,6 +412,6 @@
   }
   else hasColourMap = false;
-  
-	
+
+
   heights  = (unsigned char*) heightMap->pixels;
   shiftX = 0;
@@ -423,21 +423,21 @@
 HeightMap::~HeightMap()
 {
-	delete heightMap;
-	delete colourMap;
-	
-
-	for(int i=0;i <    heightMap->h/tileSize ; i++)
-	{
-	for(int j = 0; j < heightMap->w/ tileSize; j++)
-	{
-	 delete tiles [i][j];
-	}
-	}
-	for(int i=0;i <    heightMap->h/tileSize ; i++)
-	delete[] tiles[i];
-	delete[] tiles;
-	
-	
-	
+        delete heightMap;
+        delete colourMap;
+
+
+        for(int i=0;i <    heightMap->h/tileSize ; i++)
+        {
+        for(int j = 0; j < heightMap->w/ tileSize; j++)
+        {
+         delete tiles [i][j];
+        }
+        }
+        for(int i=0;i <    heightMap->h/tileSize ; i++)
+        delete[] tiles[i];
+        delete[] tiles;
+
+
+
 
 
@@ -449,7 +449,7 @@
 
 
-	
-	
-	
+
+
+
 }
 
@@ -465,17 +465,17 @@
 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 ) ;
-	}
-}
-
-}
-
-
-void HeightMap::draw() 
-{
-const PNode* camera = State::getCamera();
+        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 ) ;
+        }
+}
+
+}
+
+
+void HeightMap::draw()
+{
+const PNode* camera = State::getCameraNode();
 Vector v = camera->getAbsCoor();
 
@@ -487,11 +487,11 @@
 
 
-for(int i = 0; i <  i_max	 ; i ++)
-{
-	for(int j = 0; j < j_max ; j++)
-	{
-	 tiles[i][j]->draw();
-	}	
-} 
+for(int i = 0; i <  i_max        ; i ++)
+{
+        for(int j = 0; j < j_max ; j++)
+        {
+         tiles[i][j]->draw();
+        }
+}
 
 }
@@ -509,12 +509,12 @@
 
 
-// Initialize 
+// Initialize
 for(int i=0; i< heightMap->h; i++)
 {
-	for(int j = 0; j> heightMap->w; j++)
-	{
-	Vector v = Vector(0.0, 1.0, 0.0);
-	 normalVectorField[i][j] = v;
-	}
+        for(int j = 0; j> heightMap->w; j++)
+        {
+        Vector v = Vector(0.0, 1.0, 0.0);
+         normalVectorField[i][j] = v;
+        }
 }
 
@@ -522,29 +522,29 @@
 
 if(heightMap != NULL && heightMap->format->BitsPerPixel == 8 )
-	{
-	SDL_LockSurface(heightMap);
-	for(int i = 0 ; i < heightMap->h - 1  ; i ++)
-	{
-	    for(int j = 0; j < heightMap->w  - 1  ;  j ++)
-	    {
-
-
-		delta = (int)heights[j + (i+1)*(heightMap->w )] -  (int) heights[j + i*(heightMap->w )];
-		Vector a =  Vector(-scaleX,(float)delta*scaleY  ,0.0f);
-
-		delta = (int)heights[j+1 + i*(heightMap->w )] - (int)heights[j + i*(heightMap->w )];
-		Vector b =  Vector(0.0f,(float) delta*scaleY ,scaleZ);
-
-
-		 normalVectorField[i][j] = b.cross(a);
-		 normalVectorField[i][j].normalize();
-		  
-	     }
-	}
-	SDL_UnlockSurface(heightMap);
-
-}
-
- 	
+        {
+        SDL_LockSurface(heightMap);
+        for(int i = 0 ; i < heightMap->h - 1  ; i ++)
+        {
+            for(int j = 0; j < heightMap->w  - 1  ;  j ++)
+            {
+
+
+                delta = (int)heights[j + (i+1)*(heightMap->w )] -  (int) heights[j + i*(heightMap->w )];
+                Vector a =  Vector(-scaleX,(float)delta*scaleY  ,0.0f);
+
+                delta = (int)heights[j+1 + i*(heightMap->w )] - (int)heights[j + i*(heightMap->w )];
+                Vector b =  Vector(0.0f,(float) delta*scaleY ,scaleZ);
+
+
+                 normalVectorField[i][j] = b.cross(a);
+                 normalVectorField[i][j].normalize();
+
+             }
+        }
+        SDL_UnlockSurface(heightMap);
+
+}
+
+
 
 
@@ -568,35 +568,35 @@
 
 
-float HeightMap::getHeight(float x, float y) 
+float HeightMap::getHeight(float x, float y)
 {
 
  x -= offsetX;
- y -= offsetZ; 
- 
- 
+ y -= offsetZ;
+
+
  int xInt = (int)x / scaleX;  x -= (float)((int)x); xInt = heightMap->h - xInt;
  int yInt = (int)y / scaleZ;    y -= (float) ((int) y); /*yInt = heightMap->w - yInt;*/
- 
+
  //PRINTF(0)("xInt: %i, yInt: %i, x: %f, y: %f\n", xInt, yInt, x, y);
- 
+
  if(xInt <= 0 || xInt >= heightMap->h || yInt <= 0 || yInt >= heightMap->w  ) return 0;
  if( y >= 0.5*x)
  {
-	// Check for ... 
+        // Check for ...
  }
 
  float height = heights[yInt + (xInt)*heightMap->w]*scaleY;
- 
- 
+
+
  float a = normalVectorField[(xInt)][yInt].x;
  float b = normalVectorField [(xInt)][yInt].z;
  float c = normalVectorField [(xInt)][yInt].y;
- 
+
  PRINTF(0)("a: %f \n" ,a);
   PRINTF(0)("b: %f \n" ,b);
    PRINTF(0)("c: %f \n" ,c);
- 
+
  height -= ( (a/c)*(x) + (b/c)*(y));
-  
+
  PRINTF(0)("height: %f \n" ,height );
  return (height + offsetZ);
Index: trunk/src/lib/particles/sprite_particles.cc
===================================================================
--- trunk/src/lib/particles/sprite_particles.cc	(revision 7013)
+++ trunk/src/lib/particles/sprite_particles.cc	(revision 7014)
@@ -135,7 +135,7 @@
     //! @todo implement a faster code for the look-at Camera algorithm.
 
-    const PNode* camera = State::getCamera();  //!< @todo MUST be different
+    const PNode* camera = State::getCameraNode();  //!< @todo MUST be different
     Vector cameraPos = camera->getAbsCoor();
-    Vector cameraTargetPos = State::getCameraTarget()->getAbsCoor();
+    Vector cameraTargetPos = State::getCameraTargetNode()->getAbsCoor();
     Vector view = cameraTargetPos - cameraPos;
     Vector up = Vector(0, 1, 0);
Index: trunk/src/story_entities/multi_player_world_data.cc
===================================================================
--- trunk/src/story_entities/multi_player_world_data.cc	(revision 7013)
+++ trunk/src/story_entities/multi_player_world_data.cc	(revision 7014)
@@ -265,5 +265,5 @@
 
 
-  PNode* cam = State::getCameraTarget();
+  PNode* cam = State::getCameraTargetNode();
   PRINT(0)("Camera has target - class: %s, name: %s, uid: %i\n", cam->getClassName(), cam->getName(), cam->getUniqueID());
 
Index: trunk/src/util/state.cc
===================================================================
--- trunk/src/util/state.cc	(revision 7013)
+++ trunk/src/util/state.cc	(revision 7014)
@@ -18,4 +18,7 @@
 #include "state.h"
 
+
+#include "camera.h"
+
 #ifndef NULL
 #define NULL 0
@@ -26,6 +29,9 @@
 
 
-PNode* State::camera = NULL;
-PNode* State::cameraTarget = NULL;
+Camera* State::camera = NULL;
+CameraTarget* State::cameraTarget = NULL;
+
+PNode* State::cameraNode = NULL;
+PNode* State::cameraTargetNode = NULL;
 
 SkyBox* State::skyBox = NULL;
@@ -49,7 +55,9 @@
  *  sets camera and target of the current Camera
 */
-void State::setCamera(PNode* camera, PNode* cameraTarget)
+void State::setCamera(Camera* camera, CameraTarget* cameraTarget)
 {
   State::camera = camera;
   State::cameraTarget = cameraTarget;
+  State::cameraNode = camera;
+  State::cameraTargetNode = cameraTarget;
 }
Index: trunk/src/util/state.h
===================================================================
--- trunk/src/util/state.h	(revision 7013)
+++ trunk/src/util/state.h	(revision 7014)
@@ -10,4 +10,6 @@
 // FORWARD DECLARATION
 class PNode;
+class Camera;
+class CameraTarget;
 class WorldEntity;
 class Player;
@@ -30,9 +32,11 @@
    //////////////
   /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
-  static void setCamera(PNode* camera, PNode* cameraTarget);
+  static void setCamera(Camera* camera, CameraTarget* cameraTarget);
+  static inline Camera* getCamera() { return State::camera; };
+  static inline CameraTarget* getCameraTarget() { return State::cameraTarget; };
   /** @returns a Pointer to the PNode of the Camera */
-  static inline PNode* getCamera() { return State::camera; };
+  static inline PNode* getCameraNode() { return State::cameraNode; };
   /** @returns a Pointer to the CameraTarget */
-  static inline PNode* getCameraTarget() { return State::cameraTarget; };
+  static inline PNode* getCameraTargetNode() { return State::cameraTargetNode; };
 
   ////////////////
@@ -95,6 +99,8 @@
   State();
 
-  static PNode*                 camera;             //!< A reference to the camera
-  static PNode*                 cameraTarget;       //!< A reference to the cameraTarget
+  static Camera*                camera;             //!< The current Camera.
+  static CameraTarget*          cameraTarget;       //!< The Camera Target.
+  static PNode*                 cameraNode;         //!< A reference to the camera
+  static PNode*                 cameraTargetNode;   //!< A reference to the cameraTarget
   static PNode*                 nullParent;         //!< A reference to the Null-PNode.
   static ObjectManager*         objectManager;      //!< A reference to the current ObjectManager
Index: trunk/src/world_entities/camera.cc
===================================================================
--- trunk/src/world_entities/camera.cc	(revision 7013)
+++ trunk/src/world_entities/camera.cc	(revision 7014)
@@ -65,5 +65,5 @@
  * @returns The PNode of the Target (from there you can get position and so on
 */
-PNode* Camera::getTarget()
+PNode* Camera::getTargetNode() const
 {
   return (PNode*)this->target;
@@ -146,6 +146,6 @@
 {
   //update frustum plane
-  this->viewVector = (this->getAbsCoor() -  this->target->getAbsCoor()).getNormalized();
-  this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 3.0);
+  this->viewVector = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized();
+  this->frustumPlane = Plane(this->viewVector, this->getAbsCoor() + this->viewVector * 0.1);
 
   this->upVector =  this->getAbsDirV();
Index: trunk/src/world_entities/camera.h
===================================================================
--- trunk/src/world_entities/camera.h	(revision 7013)
+++ trunk/src/world_entities/camera.h	(revision 7014)
@@ -37,5 +37,6 @@
 
   void lookAt(PNode* target);
-  PNode* getTarget();
+  CameraTarget* getTarget() const { return this->target; };
+  PNode* getTargetNode() const;
 
   void setAspectRatio(float aspectRatio);
Index: trunk/src/world_entities/creatures/md2_creature.cc
===================================================================
--- trunk/src/world_entities/creatures/md2_creature.cc	(revision 7013)
+++ trunk/src/world_entities/creatures/md2_creature.cc	(revision 7014)
@@ -119,7 +119,7 @@
   this->cameraConnNode.setName("CameraConnectorNode");
   this->addChild(&this->cameraConnNode);
-  this->cameraConnNode.addChild(State::getCameraTarget());
-  this->cameraConnNode.addChild(State::getCamera());
-  State::getCameraTarget()->setRelCoor(10,0,0);
+  this->cameraConnNode.addChild(State::getCameraTargetNode());
+  this->cameraConnNode.addChild(State::getCameraNode());
+  State::getCameraTargetNode()->setRelCoor(10,0,0);
 
   travelSpeed = 15.0;
Index: trunk/src/world_entities/playable.cc
===================================================================
--- trunk/src/world_entities/playable.cc	(revision 7013)
+++ trunk/src/world_entities/playable.cc	(revision 7014)
@@ -285,6 +285,6 @@
 void  Playable::attachCamera()
 {
-  State::getCamera()->setParentSoft(this);
-  State::getCameraTarget()->setParentSoft(this);
+  State::getCameraNode()->setParentSoft(this);
+  State::getCameraTargetNode()->setParentSoft(this);
 
 }
Index: trunk/src/world_entities/space_ships/helicopter.cc
===================================================================
--- trunk/src/world_entities/space_ships/helicopter.cc	(revision 7013)
+++ trunk/src/world_entities/space_ships/helicopter.cc	(revision 7014)
@@ -203,6 +203,6 @@
 {
   dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
-  State::getCamera()->setParentSoft(this->getWeaponManager()->getFixedTarget());
-  State::getCameraTarget()->setParentSoft(this->getWeaponManager()->getFixedTarget());
+  State::getCameraNode()->setParentSoft(this->getWeaponManager()->getFixedTarget());
+  State::getCameraTargetNode()->setParentSoft(this->getWeaponManager()->getFixedTarget());
 }
 
Index: trunk/src/world_entities/space_ships/hover.cc
===================================================================
--- trunk/src/world_entities/space_ships/hover.cc	(revision 7013)
+++ trunk/src/world_entities/space_ships/hover.cc	(revision 7014)
@@ -192,7 +192,7 @@
   dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
 
-  State::getCamera()->setParentSoft(&this->cameraNode);
-  State::getCamera()->setRelCoorSoft(-10, 0,0);
-  State::getCameraTarget()->setParentSoft(&this->cameraNode);
+  State::getCameraNode()->setParentSoft(&this->cameraNode);
+  State::getCameraNode()->setRelCoorSoft(-10, 0,0);
+  State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
 }
 
Index: trunk/src/world_entities/space_ships/turbine_hover.cc
===================================================================
--- trunk/src/world_entities/space_ships/turbine_hover.cc	(revision 7013)
+++ trunk/src/world_entities/space_ships/turbine_hover.cc	(revision 7014)
@@ -222,7 +222,7 @@
   dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
 
-  State::getCamera()->setParentSoft(&this->cameraNode);
-  State::getCamera()->setRelCoorSoft(-10, 0,0);
-  State::getCameraTarget()->setParentSoft(&this->cameraNode);
+  State::getCameraNode()->setParentSoft(&this->cameraNode);
+  State::getCameraNode()->setRelCoorSoft(-10, 0,0);
+  State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
 }
 
Index: trunk/src/world_entities/terrain.cc
===================================================================
--- trunk/src/world_entities/terrain.cc	(revision 7013)
+++ trunk/src/world_entities/terrain.cc	(revision 7014)
@@ -241,5 +241,5 @@
 glPushMatrix();
 glLoadIdentity();
- Vector camera =   State::getCamera()->getAbsCoor(); // Go on here ..........!!!
+ Vector camera =   State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!
 
     /*
Index: trunk/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 7013)
+++ trunk/src/world_entities/world_entity.cc	(revision 7014)
@@ -30,4 +30,5 @@
 
 #include "state.h"
+#include "camera.h"
 
 using namespace std;
@@ -319,5 +320,6 @@
 
     // This Draws the LOD's
-    float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len();
+    float cameraDistance = State::getCamera()->distance(this);
+    printf("%s::%s, distance %f\n", this->getClassName(), this->getName(), cameraDistance);
     if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
     {
