Index: /branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
===================================================================
--- /branches/bsp_model/src/lib/graphics/importer/bsp_file.cc	(revision 7510)
+++ /branches/bsp_model/src/lib/graphics/importer/bsp_file.cc	(revision 7511)
@@ -1,12 +1,12 @@
 /*
    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: bottac@ee.ethz.ch
@@ -36,4 +36,8 @@
 {}
 
+/**
+ *  Loads a quake3 level (*.bsp)
+ * @param name the Name of the *.bsp file
+ */
 int BspFile::read(char* name)
 {
@@ -222,18 +226,18 @@
       PRINTF(4)("BSP FILE: Texture 0: %s. \n", &this->textures[8+ 72*i]);
     this->load_textures();
-
+    
     // Load the lightMaps
     this->glLightMapTextures = new GLuint[this->numLightMaps];
     for(int i = 0; i < this->numLightMaps; i++)
       this->glLightMapTextures[i] = this->loadLightMapToGL(this->lightMaps[i]);
-
+    
     //Create white texture for if no lightmap specified
     glGenTextures(1, &this->whiteLightMap);
     glBindTexture(GL_TEXTURE_2D, this->whiteLightMap);
-        //Create texture
+	//Create texture
     this->whiteTexture[0]=255;
     this->whiteTexture[1]=255;
     this->whiteTexture[2]=255;
-
+    
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
@@ -244,5 +248,5 @@
 
 
-
+  
     /* control the mipmap levels */
     glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MIN_LOD, 5);
@@ -252,5 +256,5 @@
     glTexImage2D(GL_TEXTURE_2D,
                  0,
-                 GL_RGBA8,
+                 GL_RGB,
                  1,
                  1,
@@ -260,8 +264,8 @@
                  (const GLvoid *)&(this->whiteTexture));
 
-    gluBuild2DMipmaps(  GL_TEXTURE_2D, GL_RGBA8, 1, 1,
+    gluBuild2DMipmaps(	GL_TEXTURE_2D, GL_RGB, 1, 1,
                        GL_RGB, GL_FLOAT,(const GLvoid *) &(this->whiteTexture));
-
-
+    
+    
 
     // Get the number of patches
@@ -313,4 +317,7 @@
 }
 
+/**
+ *  Called by BspFile::build_tree() only.
+ */
 BspTreeNode*   BspFile::build_tree_rec(int i)
 {
@@ -324,5 +331,5 @@
   float z1 =(((plane *) this->planes) [planeIndex]).z;
   thisNode->leafIndex = 0;
-  thisNode->d          = (((plane *) this->planes) [planeIndex]).d;
+  thisNode->d	       = (((plane *) this->planes) [planeIndex]).d;
 
   thisNode->plane = Vector(x1,y1,z1);
@@ -356,4 +363,7 @@
 }
 
+/**
+ *  returns the root node of the bsp-tree
+ */
 BspTreeNode* BspFile::get_root()
 {
@@ -464,5 +474,5 @@
       PRINTF(0)("BSP FILE: gefunden . \n");
       this->Materials[i] =this->loadMat(fileName);
-
+      
     }
 
@@ -480,5 +490,5 @@
       continue;
     }
-    //  Default Material
+    // 	Default Material
     this->Materials[i].mat = new Material();
     this->Materials[i].mat->setDiffuse(0.1,0.1,0.1);
@@ -503,5 +513,5 @@
   if(this->testSurf != NULL) {
     if(this->testSurf->format->Amask != 0 ) tmpAMat.alpha = true;
-    else                                       tmpAMat.alpha = false;
+    else 				       tmpAMat.alpha = false;
   } else   tmpAMat.alpha = false;
 
@@ -510,6 +520,6 @@
   tmp->setAmbient(1.0,1.0,1.0 );
   tmp->setSpecular(1.0,1.0,1.0);
-  //    tmp->setShininess(.5);
-  //    tmp->setTransparency(1.0);
+  //	tmp->setShininess(.5);
+  //	tmp->setTransparency(1.0);
 
   tmp->setDiffuseMap(mat);
@@ -539,9 +549,9 @@
   scale*=255.0;
   sc*=scale;
-    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc;
-
-
+    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc; 
+    
+  
   }
-
+  
   glGenTextures(1, &lightMap);
   glBindTexture(GL_TEXTURE_2D,  lightMap);
@@ -569,5 +579,5 @@
                    (const GLvoid *)&lightMapTexture);
 
-
+   
    // build the MipMaps automaticaly
    errorCode = gluBuild2DMipmaps(GL_TEXTURE_2D,
@@ -579,5 +589,5 @@
                                  (const GLvoid *)&lightMapTexture
                                 );
-
+   
 
 
@@ -587,4 +597,11 @@
 }
 
+/**
+ * Generates a vertex-array, a indice-array and a texture-coordinates-array for iface.
+ * @param iface integer index of face 
+ * @todo cleanup this function, let the user choose the level of tesselation
+ */
+ 
+ 
 void BspFile::tesselate(int iface)
 {
@@ -715,5 +732,5 @@
 
 
-          //Vertice[u*(tesselation+1)+v]=       temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px);
+          //Vertice[u*(tesselation+1)+v]=	temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px);
           Vertice[u*(level1)+v].position[0]=temp[0].position[0]*((1.0f-px)*(1.0f-px))+temp[1].position[0]*((1.0f-px)*px*2)+temp[2].position[0]*(px*px);
           Vertice[u*(level1)+v].position[1]=temp[0].position[1]*((1.0f-px)*(1.0f-px))+temp[1].position[1]*((1.0f-px)*px*2)+temp[2].position[1]*(px*px);
@@ -750,4 +767,5 @@
       // Debug Model
       //***********************************************************************************************************************
+      
       this->VertexArrayModels[this->patchOffset] = new VertexArrayModel();
       VertexArrayModel*  tmp = this->VertexArrayModels[this->patchOffset];
Index: /branches/bsp_model/src/lib/graphics/importer/bsp_file.h
===================================================================
--- /branches/bsp_model/src/lib/graphics/importer/bsp_file.h	(revision 7510)
+++ /branches/bsp_model/src/lib/graphics/importer/bsp_file.h	(revision 7511)
@@ -156,7 +156,7 @@
   brushside* brushSides;     //!<
   char* vertice;             //!<
-  meshvert* meshverts;       //!<
-  char* visData;             //!<
-  char* textures;            //!<
+  meshvert* meshverts;       //!< Buffer to store meshverice
+  char* visData;             //!< Buffer to store visibility data
+  char* textures;            //!< Holds all the texture filename strings
   char* patchVertice;        //!<
   char* patchIndexes;
Index: /branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- /branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 7510)
+++ /branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 7511)
@@ -1,12 +1,12 @@
 /*
    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: bottac@ee.ethz.ch
@@ -51,10 +51,10 @@
   // Draw Debug Terrain
   /*
-  this->bspFile->Materials[0]->select();
+  this->bspFile->Materials[0]->select(); 
   for(int i = 0; i <  this->bspFile->numPatches ; i++)
-        {
-                this->bspFile->VertexArrayModels[i]->draw();
-
-        }
+  	{
+  	 	this->bspFile->VertexArrayModels[i]->draw();
+   
+  	}
   */
 
@@ -103,10 +103,10 @@
         if (f >=0 && !this->isAlreadyVisible(f)) {
           this->alreadyVisible[f] = true;
-          /*    if(ActLeaf->leafIndex == i)public final double readLEDouble()
-                {
-                        this->alreadyVisible[i] = false;
-                        this->draw_debug_face(f);
-                        this->alreadyVisible[i] = true;
-                }
+          /*	if(ActLeaf->leafIndex == i)public final double readLEDouble()
+          	{
+          		this->alreadyVisible[i] = false;
+          		this->draw_debug_face(f);
+          		this->alreadyVisible[i] = true;
+          	}  
                 else */
           addFace(f); // "visibleFaces.append(f)"
@@ -131,10 +131,10 @@
       leaf& curLeaf =  (this->bspFile->leaves)[i] ;
       cluster =  curLeaf.cluster;
-
+      
       if(cluster <0) continue;
       v = ((viscluster *  ( ((int *)this->bspFile->visData)[1]) ) + (cluster / 8));
       visSet =((unsigned char*) (this->bspFile->visData))[v+8];
-
-
+   
+      
       if( ((visSet) & ((unsigned char)1 <<(unsigned char) (cluster &  7))) == 0 )
       {
@@ -194,9 +194,9 @@
   //   this->lastTex = curFace.texture;
   //}
-
-    if(curFace.lm_index < 0)
+    
+    if(curFace.lm_index < 0) 
     {
       glActiveTextureARB(GL_TEXTURE1_ARB);
-      glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[this->bspFile->whiteLightMap]);
+      glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap );
       glEnable(GL_TEXTURE_2D);
     }
@@ -207,23 +207,23 @@
     glEnable(GL_TEXTURE_2D);
     }
-
+    
     glColor4f(3.0,3.0,3.0,0.9);
-  glEnableClientState(GL_VERTEX_ARRAY );
+  glEnableClientState(GL_VERTEX_ARRAY );  
   //glEnableClientState(GL_TEXTURE_COORD_ARRAY );
   glEnableClientState(GL_NORMAL_ARRAY );
   //  glEnableClientState(GL_COLOR_ARRAY);
-
+  
 
   glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0]));
-
+  
   glClientActiveTextureARB(GL_TEXTURE0_ARB);
   glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0]));
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-
+  
   glClientActiveTextureARB(GL_TEXTURE1_ARB);
   glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1]));
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-
+  
   glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0]));
   // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0]));
@@ -287,15 +287,15 @@
 void BspManager::draw_patch(face* Face)
 {
-  if(this->lastTex != Face->texture) {
+  //if(this->lastTex != Face->texture) {
     this->bspFile->Materials[Face->texture].mat->select();
-    this->lastTex = Face->texture;
-  }
-
-
-
-  if(Face->lm_index < 0)
+    //this->lastTex = Face->texture;
+  //}
+  
+  
+  
+  if(Face->lm_index < 0) 
   {
     glActiveTextureARB(GL_TEXTURE1_ARB);
-    glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[this->bspFile->whiteLightMap]);
+    glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap);
     glEnable(GL_TEXTURE_2D);
   }
@@ -307,5 +307,5 @@
 }
     glColor4f(3.0,3.0,3.0,0.9);
-
+  
   glEnable( GL_AUTO_NORMAL);
   glEnableClientState(GL_VERTEX_ARRAY );
@@ -314,28 +314,24 @@
     glFrontFace(GL_CW);
     //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]);
-
-
+  
+ 
     glEnableClientState(GL_NORMAL_ARRAY );
 
     glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0]));
-
-
+    
+    
     glClientActiveTextureARB(GL_TEXTURE0_ARB);
     glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0]));
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-
+    
     glClientActiveTextureARB(GL_TEXTURE1_ARB);
     glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[1][0]));
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-
+    
     glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) );
 
-    // We'll need multitexture suport for lightning
-    //glClientActiveTextureARB(GL_TEXTURE0_ARB);
-    //glTexCoordPointer(2, GL_FLOAT,0, &vertex[0].textureCoord);
-    //glClientActiveTextureARB(GL_TEXTURE1_ARB);
-    //glTexCoordPointer(2, GL_FLOAT, sizeof(BSPVertex), &vertex[0].lightmapCoord);
+  
 
 
@@ -344,5 +340,5 @@
                      & (     (((GLuint*)  (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8]  ))  );
     }
-
+   
     glFrontFace(GL_CCW);
   }
@@ -352,7 +348,7 @@
   glDisableClientState(GL_VERTEX_ARRAY );
   glDisableClientState(GL_TEXTURE_COORD_ARRAY );
-
+  
   glBegin(GL_QUADS);
-
+  
   glEnd();
 }
@@ -406,23 +402,23 @@
 
     /*
-        for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ )
-        {
-                brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes];
-                if(curBrush.n_brushsides < 0) return;
-                for(int j = 0; j < curBrush.n_brushsides; j++)
-                {
-                float dist = -0.1;
-                brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides];
-                plane&      testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes];
-                dist = testPlane.x * this->cam.x +  testPlane.y * this->cam.y  +  testPlane.z * this->cam.z   -testPlane.d ;
-
-                if(dist < -0.01f) dist = -1.0f *dist;
-                if(dist < 1.0f){
-                                this->drawDebugCube(&this->cam);
-                                return;
-                              }
-                }
-
-        } */
+    	for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ )
+    	{
+    		brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes];
+    		if(curBrush.n_brushsides < 0) return;
+    		for(int j = 0; j < curBrush.n_brushsides; j++)
+    		{
+    		float dist = -0.1;
+    		brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides];
+    		plane& 	    testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes];
+    		dist = testPlane.x * this->cam.x +  testPlane.y * this->cam.y  +  testPlane.z * this->cam.z   -testPlane.d ; 
+    		
+    		if(dist < -0.01f) dist = -1.0f *dist;
+    		if(dist < 1.0f){
+    				this->drawDebugCube(&this->cam);
+    				return;
+    			      }
+    		}
+    			
+    	} */
 
   }
