Index: branches/terrain/src/lib/graphics/importer/terrain/frustum.h
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/frustum.h	(revision 9414)
+++ branches/terrain/src/lib/graphics/importer/terrain/frustum.h	(revision 9415)
@@ -1,15 +1,15 @@
 /*
 	orxonox - the future of 3D-vertical-scrollers
- 
+
 	Copyright (C) 2006 orx
- 
+
 	This program is free software; you can redistribute it and/or modify
 	it under the terms of the GNU General Public License as published by
 	the Free Software Foundation; either version 2, or (at your option)
 	any later version.
- 
+
 	### File Specific:
 	main programmer: Marco Biasini
- 
+
  */
 #ifndef _FRUSTUM_H
@@ -31,6 +31,6 @@
 	}\
 	while ( 0 )
-	
-/** 
+
+/**
  * Code borrowed from Lighthouse 3D. Its a very good tutorial on culling.
  */
@@ -40,8 +40,8 @@
 
 	public:
-		
+
 		enum { NEAR = 0 , FAR = 1, TOP = 2, BOTTOM = 3, LEFT = 4, RIGHT = 5 };
-		enum { OUTSIDE, INTERSECT, INSIDE };		
-		
+		enum { OUTSIDE, INTERSECT, INSIDE };
+
 		Frustum()
 		{
@@ -65,5 +65,5 @@
 			setFrustum( combined );
 		}
-		
+
 		inline int boxInFrustum( const ABox& _box )
 		{
@@ -75,5 +75,5 @@
 				if ( planes[i].distancePoint( _box.vertexP( planes[i].n ) ) < 0 )
 					return OUTSIDE;
-				// is the negative vertex outside?	
+				// is the negative vertex outside?
 				else if ( planes[i].distancePoint( _box.vertexN( planes[i].n ) ) < 0 )
 					result = INTERSECT;
@@ -81,5 +81,5 @@
 			return result;
 		}
-		
+
 		inline int pointInFrustum( const Vector& _point)
 		{
@@ -89,49 +89,49 @@
 					return OUTSIDE;
 			}
-			return result;		
+			return result;
 		}
-		
+
 		inline Plane getPlane( int _plane ) { return planes[_plane]; }
-		
+
 		inline void setFrustum( float *_m )
 		{
-			planes[NEAR] =  Plane( Vector( 
-				m(2,0) + m(3,0), 
-				m(2,1) + m(3,1), 
-				m(2,2) + m(3,2) ), 
+			planes[NEAR] =  Plane( Vector(
+				m(2,0) + m(3,0),
+				m(2,1) + m(3,1),
+				m(2,2) + m(3,2) ),
 				m(2,3) + m(3,3) );
-				
-			planes[FAR] = Plane( Vector( 
+
+			planes[FAR] = Plane( Vector(
 				-m(2,0) + m(3,0),
 				-m(2,1) + m(3,1),
 				-m(2,2) + m(3,2) ),
 				-m(2,3) + m(3,3) );
-									
-			planes[BOTTOM] = Plane( Vector( 
-				m(1,0) + m(3,0), 
-				m(1,1) + m(3,1), 
-				m(1,2) + m(3,2) ), 
+
+			planes[BOTTOM] = Plane( Vector(
+				m(1,0) + m(3,0),
+				m(1,1) + m(3,1),
+				m(1,2) + m(3,2) ),
 				m(1,3) + m(3,3) );
-			planes[TOP] = Plane( Vector(  
+			planes[TOP] = Plane( Vector(
 				-m(1,0) + m(3,0),
 				-m(1,1) + m(3,1),
 				-m(1,2) + m(3,2) ),
 				-m(1,3) + m(3,3) );
-			planes[LEFT] = Plane( Vector(  
+			planes[LEFT] = Plane( Vector(
 				m(0,0) + m(3,0),
 				m(0,1) + m(3,1),
 				m(0,2) + m(3,2) ),
 				m(0,3) + m(3,3) );
-			planes[RIGHT] =  Plane( Vector( 
+			planes[RIGHT] =  Plane( Vector(
 				-m(0,0) + m(3,0),
 				-m(0,1) + m(3,1),
 				-m(0,2) + m(3,2) ),
 				-m(0,3) + m(3,3) );
-							
+
 			if ( planes[NEAR].k +planes[FAR].k  > MAX_CLIP_DISTANCE ) {
 				planes[FAR].k = -planes[NEAR].k+MAX_CLIP_DISTANCE;
 			}
 		}
-		
+
 	protected:
 		Plane		*planes;
Index: branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc	(revision 9414)
+++ branches/terrain/src/lib/graphics/importer/terrain/terrain_page.cc	(revision 9415)
@@ -1,15 +1,15 @@
 /*
 	orxonox - the future of 3D-vertical-scrollers
- 
+
 	Copyright (C) 2006 orx
- 
+
 	This program is free software; you can redistribute it and/or modify
 	it under the terms of the GNU General Public License as published by
 	the Free Software Foundation; either version 2, or (at your option)
 	any later version.
- 
+
 	### File Specific:
 	main-programmer: Marco Biasini
- 
+
  */
 #include "terrain_page.h"
@@ -26,11 +26,11 @@
 	}\
 	while ( 0 )
-	
+
 TerrainPage::~TerrainPage( )
-{ 
+{
 	SAVE_DELETE_ARRAY( indices );
 	SAVE_DELETE_ARRAY( vertices );
-	SAVE_DELETE_ARRAY( indexHash );		
-	SAVE_DELETE_ARRAY( errors );	
+	SAVE_DELETE_ARRAY( indexHash );
+	SAVE_DELETE_ARRAY( errors );
 }
 
@@ -41,15 +41,15 @@
 	numVertices = numIndices = 0;
 	errors = new LODError[TerrainPage::MAX_LODS];
-	vertices = NULL; indices = NULL; 
+	vertices = NULL; indices = NULL;
 	left = top = bottom = right = NULL;
 	for ( int i = 0; i < 8; ++i )
-		layerVisibility[i] = LV_NO;	
-		
-	position = Vector( scale.x*_xOffset, 
+		layerVisibility[i] = LV_NO;
+
+	position = Vector( scale.x*_xOffset,
 		0.0f, scale.z*_zOffset );
 	isVisible = false;
 	next = NULL;
 	active = false;
-	previous = NULL; 
+	previous = NULL;
 	currentLOD = -1; wantedLOD = -1;
 	hasfull = false;
@@ -58,9 +58,9 @@
 }
 
-void TerrainPage::tesselateRow( int _z, int _xStride, int _zStride, 
+void TerrainPage::tesselateRow( int _z, int _xStride, int _zStride,
 	bool _adaptLeft, bool _adaptRight )
 {
-	
-	int xStart = 0, xEnd = owner->getPageSize();	
+
+	int xStart = 0, xEnd = owner->getPageSize();
 	int halfStride = _zStride >> 1;
 	assert( _xStride > 0 ); 	assert( _zStride > 0 );
@@ -70,5 +70,5 @@
 	}
 	if ( _adaptLeft ) {
-		assert( halfStride > 0 ); 		
+		assert( halfStride > 0 );
 		addIndex( getIndex( 0, _z ) );
 		addIndex( getIndex( 0, _z+halfStride ) );
@@ -79,17 +79,17 @@
 		xStart = _xStride;
 	}
-	
+
 	if ( _adaptRight )
 		xEnd-=_xStride;
-		
+
 	for ( int x = xStart; x < xEnd; x+=_xStride ) {
 		addIndex( getIndex( x, _z) );
 		addIndex( getIndex( x, _z+_zStride ) );
 	}
-	
+
 	int w = owner->getPageSize()-1;
-	
+
 	if ( _adaptRight ) {
-		assert( halfStride > 0 ); 		
+		assert( halfStride > 0 );
 		addIndex( getIndex( xEnd-1, _z ) );
 		addAgain();
@@ -106,22 +106,22 @@
 {
 	_adapt[0] = _adapt[1] = _adapt[2] = _adapt[3] = false;
-	
+
 	if ( left  && left->isActive() ) {
 		_adapt[TP_LEFT] = ( wantedLOD - left->getWantedLOD() ) > 0;
-		assert( std::abs( wantedLOD - left->wantedLOD ) < 2 );		
-	}	
+		assert( std::abs( wantedLOD - left->wantedLOD ) < 2 );
+	}
 	if ( right && right->isActive() ) {
 		_adapt[TP_RIGHT] = ( wantedLOD - right->getWantedLOD() ) > 0;
-		assert( std::abs( wantedLOD - right->wantedLOD ) < 2 );		
-	}	
-		
+		assert( std::abs( wantedLOD - right->wantedLOD ) < 2 );
+	}
+
 	if ( top && top->isActive() ) {
-		_adapt[TP_TOP] = ( wantedLOD - top->getWantedLOD() ) > 0;				
-		assert( std::abs( wantedLOD - top->wantedLOD ) < 2 );		
-	}	
+		_adapt[TP_TOP] = ( wantedLOD - top->getWantedLOD() ) > 0;
+		assert( std::abs( wantedLOD - top->wantedLOD ) < 2 );
+	}
 	if ( bottom && bottom->isActive() ) {
-		_adapt[TP_BOTTOM] = ( wantedLOD - bottom->getWantedLOD() ) > 0;		
+		_adapt[TP_BOTTOM] = ( wantedLOD - bottom->getWantedLOD() ) > 0;
 		assert( std::abs( wantedLOD - bottom->wantedLOD ) < 2 );
-	}	
+	}
 }
 
@@ -130,22 +130,22 @@
 	wantedLOD = -1;
 	Vector cam( owner->getCameraPosition() );
-	
+
 	for ( int i = TerrainPage::MAX_LODS-1; i >= 0; --i ) {
 		Vector distance( cam.x-errors[i].correct.x,
 						 cam.y-errors[i].correct.y,
 						 cam.z-errors[i].correct.z );
-		
+
 		float d = distance.len();
-		
+
 		float err =  errors[i].diff / d ;
-		
+
 		if ( err*scale.y < owner->getDetail() ) {
 			wantedLOD = i;
 			break;
-		}	
+		}
 	}
 	if ( wantedLOD < 0 ) {
 		wantedLOD = TerrainPage::MAX_LODS-1;
-	}	
+	}
 	return wantedLOD;
 }
@@ -153,5 +153,5 @@
 void TerrainPage::activate()
 {
-	
+
 	pTerrainPage list = owner->getActiveList();
 	next = list;
@@ -164,5 +164,5 @@
 {
 	pTerrainPage list = owner->getActiveList();
-	
+
 	if ( previous ) {
 		previous->next = next;
@@ -175,5 +175,5 @@
 	next = NULL;
 	previous = NULL;
-	
+
 }
 
@@ -186,6 +186,6 @@
 	{
 		int stride = 1 << _lod, x0, y0, xi, yi;
-		// Altough these four nested loops look very scary, they're not 
-		// that bad and require only about O(n^2). 
+		// Altough these four nested loops look very scary, they're not
+		// that bad and require only about O(n^2).
 		for( y0 = 0 ; y0 < size-stride; y0 += stride ) {
 			for( x0 = 0; x0 < size-stride; x0 += stride ) {
@@ -197,10 +197,10 @@
 						float	fx0 = ( float )xi/( float )stride, fx1 = 1.0f-fx0,
 								fy0 = ( float )yi/( float )stride, fy1 = 1.0f-fy0;
-						
+
 						float	height00 = getAltitude( x0, y0 ),
 								height10 = getAltitude( x0+stride,y0 ),
 								height01 = getAltitude( x0,y0+stride ),
 								height11 = getAltitude( x0+stride, y0+stride );
-						
+
 						float	paintHeight =	fx1*fy1 * height00 +
 							fx0*fy1 * height10 +
@@ -208,7 +208,7 @@
 							fx0*fy0 * height11,
 							correctHeight =  getAltitude( x, y );
-						
+
 						float	er = ( float )fabs( correctHeight - paintHeight );
-						
+
 						numErrors++;
 						sumError += er;
@@ -229,8 +229,8 @@
 	int size = owner->getPageSize();
 	float alt = 0.0f;
-	
-	Vector	min( xOffset*scale.x ,0.0f, zOffset*scale.z ), 
+
+	Vector	min( xOffset*scale.x ,0.0f, zOffset*scale.z ),
 			max( (xOffset+1)*scale.x, 0.0f, (zOffset+1)*scale.z);
-	
+
 	min.y = max.y = getAltitude( 0, 0 );
 	for ( int x = 0; x < size; ++x ) {
@@ -248,6 +248,6 @@
 	assert( _x >= 0 && _x < 17 );
 	assert( _z >= 0 && _z < 17 );
-	return position.y+scale.y*owner->getAltitude( 
-			_x+(owner->getPageSize()-1)*xOffset, 
+	return position.y+scale.y*owner->getAltitude(
+			_x+(owner->getPageSize()-1)*xOffset,
 			_z+(owner->getPageSize()-1)*zOffset );
 }
@@ -255,16 +255,16 @@
 bool TerrainPage::needsRetesselation()
 {
-	
+
 	bool 	leftChanged 	= ( left && left->isActive() ) &&
 	 			( left->wantedLOD != left->currentLOD ),
-			rightChanged	= ( right && right->isActive() ) && 
+			rightChanged	= ( right && right->isActive() ) &&
 				( right->wantedLOD != right->currentLOD ),
-			topChanged		= ( top && top->isActive() ) && 
+			topChanged		= ( top && top->isActive() ) &&
 				( top->wantedLOD != currentLOD ),
-			bottomChanged	= ( bottom && bottom->isActive() ) && 
+			bottomChanged	= ( bottom && bottom->isActive() ) &&
 				( bottom->wantedLOD != bottom->currentLOD ),
 			iChanged		=  wantedLOD != currentLOD;
-				
-	return ( leftChanged || rightChanged || topChanged || bottomChanged || 
+
+	return ( leftChanged || rightChanged || topChanged || bottomChanged ||
 		forceTesselation || iChanged );
 }
@@ -275,11 +275,11 @@
 	if ( needsRetesselation() ) {
 		tesselate( wantedLOD );
-	}	
+	}
 	currentLOD = wantedLOD;
-	
-	//Check if the page is a level four page. If yes, copy the vertex and index data into 
+
+	//Check if the page is a level four page. If yes, copy the vertex and index data into
 	//the shared level four page buffers.
 	if ( currentLOD == TerrainPage::MAX_LODS-1 ) {
-		owner->addLevelFourPage( numVertices, vertices, 
+		owner->addLevelFourPage( numVertices, vertices,
 			numIndices, indices );
 	}
@@ -287,5 +287,5 @@
 }
 
-void TerrainPage::tesselateTopRow(  int _z, int _stride, 
+void TerrainPage::tesselateTopRow(  int _z, int _stride,
 	bool _adaptLeft,  bool _adaptRight )
 {
@@ -293,5 +293,5 @@
 	int xStart = 0, xEnd= owner->getPageSize()-1;
 	int size = xEnd;
-	int z = xEnd-_stride ;	
+	int z = xEnd-_stride ;
 	addAgain();
 	addIndex( getIndex( 0, z ) );
@@ -331,5 +331,5 @@
 
 }
-void TerrainPage::tesselateBottomRow(  int _z,  int _stride,  
+void TerrainPage::tesselateBottomRow(  int _z,  int _stride,
 	bool _adaptLeft,  bool _adaptRight  )
 {
@@ -380,13 +380,13 @@
 	numIndices = numVertices = 0;
 	const int	halfStride = 8, stride = 16;
-	
+
 	enum { ADAPT_L = 1, ADAPT_R = 2, ADAPT_B = 4, ADAPT_T = 8,
-		ADAPT_LR = 3, ADAPT_LB = 5, ADAPT_LT = 9, ADAPT_RB = 6, 
-		ADAPT_RT = 10, ADAPT_BT = 12, ADAPT_LRB = 7, ADAPT_LBT = 13, ADAPT_LRT = 11, 
+		ADAPT_LR = 3, ADAPT_LB = 5, ADAPT_LT = 9, ADAPT_RB = 6,
+		ADAPT_RT = 10, ADAPT_BT = 12, ADAPT_LRB = 7, ADAPT_LBT = 13, ADAPT_LRT = 11,
 		ADAPT_RBT = 14, ADAPT_LRBT = 15, ADAPT_NONE = 0 };
-		
-	int			code =  ( _adapt[TP_LEFT] 	? ADAPT_L : 0 ) | 
-						( _adapt[TP_RIGHT] 	? ADAPT_R : 0 ) | 
-						( _adapt[TP_BOTTOM] ? ADAPT_B : 0 ) | 
+
+	int			code =  ( _adapt[TP_LEFT] 	? ADAPT_L : 0 ) |
+						( _adapt[TP_RIGHT] 	? ADAPT_R : 0 ) |
+						( _adapt[TP_BOTTOM] ? ADAPT_B : 0 ) |
 						( _adapt[TP_TOP]	? ADAPT_T : 0 );
 	switch( code ) {
@@ -397,5 +397,5 @@
 			addIndex( getIndex( stride, stride ) );
 			break;
-			
+
 	 	case ADAPT_L:
 			addIndex( getIndex( 0, 0 ) );
@@ -406,5 +406,5 @@
 			addAgain( );
 		 	break;
-		
+
 		case ADAPT_R:
 			addIndex( getIndex( stride, stride ) );
@@ -556,12 +556,12 @@
 {
 
-	memset( indexHash, 0xffff, 
+	memset( indexHash, 0xffff,
 			sizeof(unsigned short)*Terrain::MAX_VERTICES );
-	
+
 	numVertices = 0; numIndices = 0;
-	
+
 	//Calculate the pace, based on the lod.
 	int stride = 1 << _lod;
-		
+
 	bool adapt[4];
 	determineBorderAdaption( adapt );
@@ -573,6 +573,6 @@
 			vbIdentifier = ibIdentifier = 0;
 		}
-		if ( !vertices ) 
-			vertices =  new Vertex[8]; 
+		if ( !vertices )
+			vertices =  new Vertex[8];
 		if ( !indices )
 			indices = new unsigned short[8];
@@ -585,5 +585,5 @@
 			if ( indices )
 				delete[] indices;
-			vertices = NULL; indices = NULL;	
+			vertices = NULL; indices = NULL;
 		}
 		assert( vbIdentifier ); assert( ibIdentifier );
@@ -591,26 +591,26 @@
 
 		// The call to glBufferDataARB with a null argument for data is to make things faster.
-		// Then calling call glMapBuffer() tells the driver that the previous 
-		// data aren’t valid. As a consequence, if the GPU is still working on them, there won’t 
-		// be a conflict because we invalidated these data. The function glMapBuffer() returns a 
-		// new pointer that we can use while the GPU is working on the previous set of data.. 
-
-		glBufferDataARB( GL_ARRAY_BUFFER_ARB, Terrain::MAX_VERTICES*sizeof( Vertex ), 
+		// Then calling call glMapBuffer() tells the driver that the previous
+		// data aren’t valid. As a consequence, if the GPU is still working on them, there won’t
+		// be a conflict because we invalidated these data. The function glMapBuffer() returns a
+		// new pointer that we can use while the GPU is working on the previous set of data..
+
+		glBufferDataARB( GL_ARRAY_BUFFER_ARB, Terrain::MAX_VERTICES*sizeof( Vertex ),
 			NULL, GL_DYNAMIC_DRAW_ARB );
 
-		vertices = (Vertex*)glMapBufferARB( GL_ARRAY_BUFFER_ARB, 
+		vertices = (Vertex*)glMapBufferARB( GL_ARRAY_BUFFER_ARB,
 			GL_WRITE_ONLY_ARB );
 
 		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ibIdentifier );
 
-		glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 
-			Terrain::MAX_INDICES*sizeof( short ), NULL, GL_DYNAMIC_DRAW_ARB );	
-
-		indices = (unsigned short*)glMapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 
+		glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB,
+			Terrain::MAX_INDICES*sizeof( short ), NULL, GL_DYNAMIC_DRAW_ARB );
+
+		indices = (unsigned short*)glMapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB,
 			GL_WRITE_ONLY_ARB );
 
-	}	
-
-#endif	
+	}
+
+#endif
 
 	assert( indices ); 	assert( vertices );
@@ -619,24 +619,24 @@
 		return;
 	}
-	
+
 	int zStart = 0, zEnd = owner->getPageSize()-stride;
-	
+
 	if ( adapt[TP_BOTTOM] ) {
 		tesselateBottomRow( 0, stride, adapt[TP_LEFT], adapt[TP_RIGHT] );
 		zStart+= stride;
 	}
-	
+
 	if ( adapt[TP_TOP] )
 		zEnd-= stride;
-		
+
 	for ( int z = zStart; z < zEnd; z+=stride )
 		tesselateRow( z, stride, stride, adapt[TP_LEFT], adapt[TP_RIGHT] );
-	
+
 
 	if ( adapt[TP_TOP] ) {
-		tesselateTopRow( owner->getPageSize()-stride-1, 
+		tesselateTopRow( owner->getPageSize()-stride-1,
 			stride, adapt[TP_LEFT], adapt[TP_RIGHT] );
 	}
-	
+
 #ifdef USE_VBO
 	if ( vbIdentifier && ibIdentifier ) {
@@ -645,5 +645,5 @@
 		glUnmapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB );
 		vertices = NULL;
-	}	
+	}
 #endif
 
@@ -653,6 +653,6 @@
 void TerrainPage::show( )
 {
-	
-#ifdef USE_VBO	
+
+#ifdef USE_VBO
 	//This is done later on...
 	//owner->getBufferBroker()->acquire( vbIdentifier, ibIdentifier );
@@ -662,7 +662,7 @@
 	vertices = new Vertex[Terrain::MAX_VERTICES];
 	indices = new unsigned short[Terrain::MAX_INDICES];
-#endif	
+#endif
 	vbIdentifier = 0; ibIdentifier = 0;
-	indexHash = new unsigned short[Terrain::MAX_VERTICES];	
+	indexHash = new unsigned short[Terrain::MAX_VERTICES];
 	forceTesselation = true;
 	activate();
@@ -673,5 +673,5 @@
 {
 #ifdef USE_VBO
-	owner->getBufferBroker()->release( vbIdentifier, ibIdentifier );	
+	owner->getBufferBroker()->release( vbIdentifier, ibIdentifier );
 #endif
 	SAVE_DELETE_ARRAY( vertices );
@@ -692,19 +692,19 @@
 		glVertex3f( bounds.x, bounds.y, 0.0f );
 		glVertex3f( 0.0f, bounds.y, 0.0f );
-		
+
 		glVertex3f( 0.0f, 0.0f, bounds.z );
 		glVertex3f(  bounds.x, 0.0f, bounds.z );
 		glVertex3f( bounds.x, bounds.y, bounds.z );
-		glVertex3f( 0.0f, bounds.y, bounds.z );		
-		
+		glVertex3f( 0.0f, bounds.y, bounds.z );
+
 		glVertex3f( 0.0f, 0.0f, 0.0 );
 		glVertex3f(  0.0, 0.0f, bounds.z );
 		glVertex3f( 0.0f, bounds.y, bounds.z );
-		glVertex3f( 0.0f, bounds.y, 0.0f );				
-		
+		glVertex3f( 0.0f, bounds.y, 0.0f );
+
 		glVertex3f( bounds.x, 0.0f, 0.0 );
 		glVertex3f(  bounds.x, 0.0f, bounds.z );
 		glVertex3f( bounds.x, bounds.y, bounds.z );
-		glVertex3f( bounds.x, bounds.y, 0.0f );						
+		glVertex3f( bounds.x, bounds.y, 0.0f );
 	glEnd();
 	glPopMatrix();
@@ -716,41 +716,41 @@
 	assert( glIsEnabled( GL_VERTEX_ARRAY ) );
 	assert( !glIsEnabled( GL_NORMAL_ARRAY ) );
-	
+
 	if ( currentLOD == TerrainPage::MAX_LODS-1 )
 		return;
-		
+
 	assert( isVisible ); assert( numIndices > 0 );
 	active = false;
-	CHECK_GL_ERROR( "1" );	
+	CHECK_GL_ERROR( "1" );
 #ifdef USE_VBO
-	
+
 	glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbIdentifier );
 	glClientActiveTextureARB( GL_TEXTURE0_ARB );
 	glInterleavedArrays( GL_T2F_V3F, 0, NULL );
-	
+
 	glClientActiveTextureARB( GL_TEXTURE1_ARB );
 	glInterleavedArrays( GL_T2F_V3F, 0, NULL );
-	
-	glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ibIdentifier );	
-	
-	glDrawElements( GL_TRIANGLE_STRIP, numIndices, 
-					GL_UNSIGNED_SHORT, NULL );	
-#else	
+
+	glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ibIdentifier );
+
+	glDrawElements( GL_TRIANGLE_STRIP, numIndices,
+					GL_UNSIGNED_SHORT, NULL );
+#else
 	glClientActiveTextureARB( GL_TEXTURE0_ARB );
 	glInterleavedArrays( GL_T2F_V3F, 0, vertices );
-	
+
 	glClientActiveTextureARB( GL_TEXTURE1_ARB );
 	glInterleavedArrays( GL_T2F_V3F, 0, vertices );
-	
-	glDrawElements( GL_TRIANGLE_STRIP, numIndices, 
-					GL_UNSIGNED_SHORT, indices );	
+
+	glDrawElements( GL_TRIANGLE_STRIP, numIndices,
+					GL_UNSIGNED_SHORT, indices );
 #endif
-	
-
-	
+
+
+
 	if ( owner->debug() )
 		drawBox( );
-		
-	CHECK_GL_ERROR( "2" );	
+
+	CHECK_GL_ERROR( "2" );
 }
 
@@ -768,7 +768,7 @@
 }
 
-void TerrainPage::getCoord( int _x, int _z, TexCoord& _coord ) const 
-{
-	owner->getCoord( _x+xOffset*(owner->getPageSize()-1 ), 
+void TerrainPage::getCoord( int _x, int _z, TexCoord& _coord ) const
+{
+	owner->getCoord( _x+xOffset*(owner->getPageSize()-1 ),
 					 _z+zOffset*(owner->getPageSize()-1 ), _coord );
 }
@@ -789,10 +789,10 @@
 		if ( _layer )
 			hasfull = true;
-	}	
-	layerVisibility[_layer] = _lv;	
+	}
+	layerVisibility[_layer] = _lv;
 }
 
 bool TerrainPage::hasMaterial( int _layer )
-{ 
+{
 	return ( layerVisibility[_layer] != LV_NO );
 }
Index: branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h
===================================================================
--- branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h	(revision 9414)
+++ branches/terrain/src/lib/graphics/importer/terrain/terrain_page.h	(revision 9415)
@@ -1,15 +1,15 @@
 /*
 	orxonox - the future of 3D-vertical-scrollers
- 
+
 	Copyright (C) 2006 orx
- 
+
 	This program is free software; you can redistribute it and/or modify
 	it under the terms of the GNU General Public License as published by
 	the Free Software Foundation; either version 2, or (at your option)
 	any later version.
- 
+
 	### File Specific:
 	main programmer: Marco Biasini
- 
+
  */
 
@@ -27,5 +27,5 @@
 
 struct Vertex {
-	TexCoord 	t;	
+	TexCoord 	t;
 	Vector 		p;
 };
@@ -43,5 +43,5 @@
 		enum { TP_LEFT = 0, TP_RIGHT = 1, TP_BOTTOM = 2, TP_TOP = 3 };
 		const static int MAX_LODS 			= 5;
-		
+
 		/**
 		 * Creates a new terrain page with its lower left corner set
@@ -52,5 +52,5 @@
 		 */
 		TerrainPage( Terrain *_owner, int _xOffset, int _zOffset );
-		
+
 		/**
 		 * This is used only internally for communication between the TerrainPage and
@@ -58,25 +58,25 @@
 		 */
 		inline bool isActive() { return active; }
-		
+
 		virtual ~TerrainPage();
 		/**
-		 * @brief Makes the terrain look as if it were created with the given level of 
+		 * @brief Makes the terrain look as if it were created with the given level of
 		 * detail.
 		 */
 		void mimick( int _level ) {}
-		
+
 		/**
 		 * @brief Draws a box around the TerrainPage. For debugging purposes.
 		 */
 		void drawBox();
-		
-		/** 
+
+		/**
 		 * @brief Calculates the smallest fitting axis aligned bounding box for this TerrainPage.
 		 */
-		virtual void calculateBounds();		
-		
-		
-		/**
-		 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and 
+		virtual void calculateBounds();
+
+
+		/**
+		 * @brief Sets the visibility to _flag. If the visibility changed, the vertex and
 		 * index arrays are allocated or freed, respectively.
 		 */
@@ -87,37 +87,37 @@
 		 */
 		void show( );
-		
+
 		/**
 		 * @brief Frees most of the memory for economomical reasons.
 		 */
-		void hide( ); 
-		
+		void hide( );
+
 		/**
 		 * @brief Updates the tesselation if necessary.
 		 */
 		void updateTesselation( );
-		
+
 		/**
 		 * @return The current tesselation level.
 		 */
 		int getLOD() { return currentLOD; }
-		
-		/**
-		 * @return The curren tween factor. This is a floating point value  between 0.0f 
+
+		/**
+		 * @return The curren tween factor. This is a floating point value  between 0.0f
 		 * and 1.0f
 		 */
 		float getTween() { return 0.0f; }
-		
+
 		/**
 		 * @brief Determines the new LOD which should be used by this terrain page based on
-		 * the distance from the camera. 
+		 * the distance from the camera.
 		 *
-		 * No geometry is updated in this method. You need to call 
+		 * No geometry is updated in this method. You need to call
 		 * updateTesselation() in order to see a change in geometry. This method is
-		 * just a recommondation for the LOD. It might be invalid due to outer 
+		 * just a recommondation for the LOD. It might be invalid due to outer
 		 * constraints.
 		 */
 		int chooseLOD();
-		
+
 		/**
 		 * If the terrain pages tesselation level changed between the last and the
@@ -127,10 +127,10 @@
 		 */
 		bool isDirty() { return forceTesselation; }
-		
+
 		/**
 		 * @brief Calculates the maximal errors for every LOD.
 		 */
 		void calculateErrors();
-		
+
 		/**
 		 * @brief Calculates the error for the given LOD. We just need to know the "worst"
@@ -138,6 +138,6 @@
 		 */
 		void calculateError( int _lod );
-		
-		
+
+
 		/**
 		 * Tests if the terrain page would cull against the viewing frustum.
@@ -150,10 +150,10 @@
 		 * pages is at the border.
 		 */
-		inline void setNeighbors( pTerrainPage _left, pTerrainPage _right, 
+		inline void setNeighbors( pTerrainPage _left, pTerrainPage _right,
 			pTerrainPage _top, pTerrainPage _bottom )
 		{
 			left = _left; right = _right; top = _top; bottom = _bottom;
 		}
-		
+
 		/**
 		 * Sets the position of the TerrainPage. Is this needed?
@@ -169,11 +169,11 @@
 		pTerrainPage getRight() { return right; }
 		pTerrainPage getBottom() { return bottom; }
-		pTerrainPage getTop() { return top; }						
-		
+		pTerrainPage getTop() { return top; }
+
 		/**
 		 *  Does what exactly what the name says and nothing more.
 		 */
 		void draw( );
-		
+
 		/**
 		 * @return the next active page
@@ -181,9 +181,9 @@
 		inline pTerrainPage getNext() { return next; }
 		void setLayerVisibility( int _layer, LayerVisibility _lv );
-		bool hasMaterial( int _layer );		
+		bool hasMaterial( int _layer );
 		/**
 		 * Returns the previous active page
 		 */
-		inline pTerrainPage getPrevious() { return previous; }			
+		inline pTerrainPage getPrevious() { return previous; }
 		inline int getCurrentLOD() { return currentLOD; }
 		/**
@@ -192,14 +192,14 @@
 		 */
 		inline int getWantedLOD() { return wantedLOD; }
-		
+
 		/**
 	 	 * @brief Removes the page from the active page list.
 		 */
 		void deactivate();
-		
-		/** 
+
+		/**
 		 * @brief Inserts the page into the active page list.
 		 */
-		void activate();		
+		void activate();
 
 		inline void setWantedLOD( int _lod )
@@ -212,7 +212,7 @@
 				wantedLOD = _lod;
 		}
-				
+
 	protected:
-		
+
 		/**
 		 * @brief Tesselates one row of the terrain page.
@@ -221,5 +221,5 @@
 		 * @param _zStride		Defines the step-size vertically.
 		 * @param _adaptLeft	True if the left neighbor has a coarser
-		 *						tesselation level.		
+		 *						tesselation level.
 		 * @param _adaptRight	True if the right neighbor has a coarser
 		 *						tesselation level.
@@ -228,14 +228,14 @@
 		void tesselateTopRow( int _z, int _stride, bool _adaptLeft, bool _adaptRight );
 		void tesselateBottomRow( int _z, int _stride, bool _adaptLeft, bool _adaptRight );
-		/** 
+		/**
 		 * @brief Returns four boolean values in the oder
 		 */
 		void determineBorderAdaption( bool _adapt[] );
-		
+
 		/**
 		 * @brief Adds the given index to the index-array
 		 */
 		inline void addIndex( unsigned short _index );
-		
+
 		/**
 		 * @brief We programmers are very lazy :) This method just adds the last added index
@@ -243,17 +243,17 @@
 		 */
 		inline void addAgain();
-		
-		
+
+
 		void getCoord( int _x, int _z, TexCoord& _coord) const;
-		
-		/** 
+
+		/**
 		 * Fills _vertex with the vertex information at index.
 		 */
 		void getVertex( int _x, int _z, Vector& _vertex ) const;
-		
+
 	 	/**
 		 * Use this method to safely get a vertex at location ( _x, _z ). If it wasn't
-		 * created before, this method does that for you. 
-		 */			
+		 * created before, this method does that for you.
+		 */
 		unsigned short getIndex( int _x, int _z );
 		void tesselateLevelFourPage( bool _adapt[] );
@@ -261,11 +261,11 @@
 		* Generates the tesselation for the given level of detail.
 		*/
-		void tesselate( int _lod );			
+		void tesselate( int _lod );
 
 		float getAltitude( int _x, int _z ) const;
-		
+
 		int							currentLOD,
 									wantedLOD;
-		pTerrainPage 				left, 
+		pTerrainPage 				left,
 									right,
 									top,
@@ -283,5 +283,5 @@
 		GLuint						ibIdentifier,
 									vbIdentifier;
-#endif		
+#endif
 		bool						isVisible;
 		pTerrainPage				next;
@@ -313,7 +313,7 @@
 }
 
-inline void TerrainPage::addAgain() 
-{ 
-	indices[numIndices] = indices[numIndices-1]; numIndices++;				
+inline void TerrainPage::addAgain()
+{
+	indices[numIndices] = indices[numIndices-1]; numIndices++;
 }
 
Index: branches/terrain/src/lib/util/byte_order.h
===================================================================
--- branches/terrain/src/lib/util/byte_order.h	(revision 9414)
+++ branches/terrain/src/lib/util/byte_order.h	(revision 9415)
@@ -15,5 +15,5 @@
 #else
 #define NATIVE_BYTEORDER BigEndian
-#endif	
+#endif
 
 
Index: branches/terrain/src/lib/util/filesys/binary_file.cc
===================================================================
--- branches/terrain/src/lib/util/filesys/binary_file.cc	(revision 9414)
+++ branches/terrain/src/lib/util/filesys/binary_file.cc	(revision 9415)
@@ -46,5 +46,5 @@
 					delete chunk;
 					return NULL;
-				}	
+				}
 				break;
 			default:
@@ -64,7 +64,7 @@
 			case 's':
 				chunk->chunks[currChunk] = new DataSemantics();
-				chunk->chunks[currChunk]->isTerminal = true;	
+				chunk->chunks[currChunk]->isTerminal = true;
 				chunk->chunks[currChunk]->type = bytesize( *curr );
-				chunk->chunks[currChunk]->totalSize = bytesize( *curr );						
+				chunk->chunks[currChunk]->totalSize = bytesize( *curr );
 				currChunk++;
 				break;
@@ -89,5 +89,5 @@
 				*cp = '\0';
 				chunk->chunks[currChunk] = compileSemantics( tmp );
-				currChunk++;					
+				currChunk++;
 				break;
 			case ')':
@@ -111,9 +111,9 @@
 					delete[] tmp; delete chunk;
 					return NULL;
-				}				
+				}
 				if ( currChunk ) {
 					chunk->chunks[currChunk-1]->quantifier = quantifier;
-					chunk->chunks[currChunk-1]->totalSize*= quantifier;					
-				}	
+					chunk->chunks[currChunk-1]->totalSize*= quantifier;
+				}
 				else {
 					printf( "Syntax error: Quantifier without a preceding type\n" );
@@ -141,5 +141,5 @@
 		switch( _comp->type ) {
 			case TT_INT:
-				iptr = (int*)ptr;			
+				iptr = (int*)ptr;
 				for ( int i = 0; i < _comp->quantifier; ++i ) {
 					swap32( iptr );
@@ -152,5 +152,5 @@
 					swap16( sptr );
 					sptr++;
-				}			
+				}
 				break;
 			case TT_BYTE:
@@ -163,35 +163,35 @@
 				convert_data( _comp->chunks[i], ptr );
 				ptr+= _comp->chunks[i]->totalSize;
-			}			
-		}
-
-	}	
-}
-void BinaryFile::read( const char *_semantics, int _chunks, 
+			}
+		}
+
+	}
+}
+void BinaryFile::read( const char *_semantics, int _chunks,
 	void* _buf, size_t& _bytesRead )
 {
-	pDataSemantics comp = compileSemantics( _semantics );		
+	pDataSemantics comp = compileSemantics( _semantics );
 	fread( _buf, comp->totalSize, _chunks, this->handle() );
 	if ( byteorder != NATIVE_BYTEORDER ) {
 		for ( int i = 0; i < _chunks; ++i ) {
 			convert_data( comp, (char*)_buf+i*comp->totalSize );
-		}	
-	}	
+		}
+	}
 	_bytesRead = comp->totalSize*_chunks;
-	delete comp;	
-}
-void BinaryFile::read( const char *_semantics, 
+	delete comp;
+}
+void BinaryFile::read( const char *_semantics,
 	void* _buf, size_t& _bytesRead )
 {
-	pDataSemantics comp = compileSemantics( _semantics );		
+	pDataSemantics comp = compileSemantics( _semantics );
 	fread( _buf, comp->totalSize, 1, this->handle() );
-	
+
 	if ( byteorder != NATIVE_BYTEORDER ) {
 		convert_data( comp, _buf );
-	}	
-	delete comp;		
-}
-
-void BinaryFile::write( const char *_semantics, 
+	}
+	delete comp;
+}
+
+void BinaryFile::write( const char *_semantics,
 	void* _buf, size_t& _bytesWritten )
 {
@@ -199,5 +199,5 @@
 	if ( byteorder != NATIVE_BYTEORDER ) {
 		convert_data( comp, _buf );
-	}	
+	}
 	_bytesWritten = comp->totalSize;
 	fwrite( _buf, comp->totalSize, 1, this->handle() );
Index: branches/terrain/src/lib/util/filesys/binary_file.h
===================================================================
--- branches/terrain/src/lib/util/filesys/binary_file.h	(revision 9414)
+++ branches/terrain/src/lib/util/filesys/binary_file.h	(revision 9415)
@@ -22,9 +22,9 @@
 	}
 
-	~DataSemantics() 
+	~DataSemantics()
 	{
 		delete[] chunks;
 	}
-	
+
 	int 			totalSize;
 	int 			quantifier;
@@ -33,6 +33,6 @@
 	union {
 		int				type;
-		DataSemantics	**chunks; 
-	};	
+		DataSemantics	**chunks;
+	};
 };
 
@@ -40,20 +40,20 @@
 
 class BinaryFile : public File {
-	public:		
+	public:
 		BinaryFile()
 			: 	File( "" ),
 				byteorder( NATIVE_BYTEORDER )
 		{ /* nothing to be done */ }
-		
+
 		BinaryFile( const std::string& _file )
-			: 	File( _file ), 
+			: 	File( _file ),
 				byteorder( NATIVE_BYTEORDER )
 		{ /* nothing to be done */ }
 
 		BinaryFile( const BinaryFile& _file )
-			: 	File( _file.name() ), 
+			: 	File( _file.name() ),
 				byteorder( _file.getByteorder() )
 		{ /* nothing to be done */ }
-		
+
 		/**
 		 * Reads a chunk of data based on the _semantics string. The string contains
@@ -70,11 +70,11 @@
 		 */
 		void read( const char *_semantics, void* _buf, size_t& _bytesRead );
-		
+
 		/**
 		 * The same as the read above, but with the ability to read multiple
-		 * chunks once. Very useful if you don't know how many chunks you're 
+		 * chunks once. Very useful if you don't know how many chunks you're
 		 * going to read at compile time.
 		 */
-		void read( const char *_semantics, int _chunks, 
+		void read( const char *_semantics, int _chunks,
 			void* _buf, size_t& _bytesRead );
 		/**
@@ -93,7 +93,7 @@
 		 * in the middle of reading a file. You're totally on your own.
 		 */
-		inline void setByteorder( ByteOrder _order ) 
+		inline void setByteorder( ByteOrder _order )
 		{ byteorder = _order; }
-		
+
 		/**
 		 * Returns the file's byte-order.
@@ -101,7 +101,7 @@
 		inline ByteOrder getByteorder() const
 		{ return byteorder; }
-		
+
 	private:
-		pDataSemantics compileSemantics( const char *_semantics );	
+		pDataSemantics compileSemantics( const char *_semantics );
 		ByteOrder 		byteorder;
 };
