Index: branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_file.cc	(revision 7800)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_file.cc	(revision 7801)
@@ -25,4 +25,5 @@
 #include "vector.h"
 #include "util/loading/resource_manager.h"
+#include "movie_player.h"
 
 #include <SDL/SDL_endian.h>
@@ -45,5 +46,5 @@
   int size;
   struct stat results;
-  // name = "/root/data/Kanti175.bsp";
+
 
   if (stat( name , &results) == 0) {
@@ -393,12 +394,51 @@
     this->Materials[i].mat->setSpecular(0.4,0.4,1.0);
     //this->Materials[i]->setShininess(100.0);
-    this->Materials[i].mat->setTransparency(1.0);
+   // this->Materials[i].mat->setTransparency(1.0);
     this->Materials[i].mat->setDiffuseMap("pictures/ground.tga");
     this->Materials[i].mat->setAmbientMap("pictures/ground.tga");
     this->Materials[i].mat->setSpecularMap("pictures/ground.tga");
     this->Materials[i].alpha = false;
+    this->Materials[i].animated = false;
      continue;
     } 
+    
+      // Check for mov
+    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(ext, ".mov");
+    strncat (fileName, ext, strlen(fileName));
+
+    absFileName = ResourceManager::getFullName(fileName);
+
+    if(ResourceManager::isFile(absFileName)) {
+      PRINTF(0)("BSP FILE: gefunden . \n");
+      this->Materials[i] = this->loadAVI(fileName);
+      continue;
+    }
      
+    // Check for avi
+    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(ext, ".avi");
+    strncat (fileName, ext, strlen(fileName));
+
+    absFileName = ResourceManager::getFullName(fileName);
+
+    if(ResourceManager::isFile(absFileName)) {
+      PRINTF(0)("BSP FILE: gefunden . \n");
+      this->Materials[i] = this->loadAVI(fileName);
+      continue;
+    }
+    
+       // Check for mpg
+    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(ext, ".mpg");
+    strncat (fileName, ext, strlen(fileName));
+
+    absFileName = ResourceManager::getFullName(fileName);
+
+    if(ResourceManager::isFile(absFileName)) {
+      PRINTF(0)("BSP FILE: gefunden . \n");
+      this->Materials[i] = this->loadAVI(fileName);
+      continue;
+    }
     
     // Check for tga
@@ -481,9 +521,10 @@
     this->Materials[i].mat->setSpecular(0.4,0.4,0.4);
     //this->Materials[i]->setShininess(100.0);
-    this->Materials[i].mat->setTransparency(1.0);
-    this->Materials[i].mat->setDiffuseMap("pictures/ground.tga");
-    this->Materials[i].mat->setAmbientMap("pictures/ground.tga");
-    this->Materials[i].mat->setSpecularMap("pictures/ground.tga");
-    this->Materials[i].alpha = false;
+    //this->Materials[i].mat->setTransparency(1.0);
+    this->Materials[i].mat->setDiffuseMap("pictures/error_texture.png");
+    this->Materials[i].mat->setAmbientMap("pictures/error_texture.png");
+    this->Materials[i].mat->setSpecularMap("pictures/error_texture.png");
+    this->Materials[i].alpha = true;
+    this->Materials[i].animated = false;
     
   }
@@ -503,14 +544,37 @@
 
   Material* tmp = new Material();
-  tmp->setDiffuse(1.0,1.0,1.0);
-  tmp->setAmbient(1.0,1.0,1.0 );
+   tmp->setDiffuse(1.0,1.0,1.0);
+   tmp->setAmbient(1.0,1.0,1.0 );
   tmp->setSpecular(1.0,1.0,1.0);
   //	tmp->setShininess(.5);
-  //	tmp->setTransparency(1.0);
+  //	tmp->setTransparency(0.0);
 
   tmp->setDiffuseMap(mat);
 
   tmpAMat.mat = tmp;
-
+  tmpAMat.animated = false;
+  return tmpAMat;
+}
+
+AMat BspFile::loadAVI(char* mat)
+{
+  AMat tmpAMat;
+
+
+  MoviePlayer * testMC = new MoviePlayer(mat);
+  testMC->start(0);
+
+  //Material* tmp = new Material();
+ // tmp->setDiffuse(1.0,1.0,1.0);
+  //tmp->setAmbient(1.0,1.0,1.0 );
+  //tmp->setSpecular(1.0,1.0,1.0);
+  //	tmp->setShininess(.5);tmpAMat
+  //	tmp->setTransparency(0.0);
+
+  //tmp->setDiffuseMap(mat);
+
+  tmpAMat.aviMat = testMC;
+  tmpAMat.animated = true;
+  tmpAMat.alpha = true;
   return tmpAMat;
 }
@@ -533,6 +597,6 @@
   scale*=255.0;
   sc*=scale;
-  if(sc <= 205)
-    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 50; 
+  if(sc <= 180)
+    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 75; 
   else
     ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc;
@@ -595,6 +659,6 @@
   int level = 7;
   int level1 = 8;
-  int size0 = SDL_SwapLE32(Face->size[0]);
-  int size1 = SDL_SwapLE32(Face->size[1]);
+  int size0 = (Face->size[0]);
+  int size1 = (Face->size[1]);
   // For each patch...
   for(int i = 0; i <  ( size0 - 1)    ; i+=2) {
@@ -609,24 +673,24 @@
       for(int k = 0; k < 3; k++) {
         for(int l = 0; l < 3; l++) {
-          controls[k +3*l]. position[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[0]);
-          controls[k +3*l]. position[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
-          controls[k +3*l]. position[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/
-
-          controlsTmp[2-k +6-3*l]. position[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]);
-          controlsTmp[2-k +6-3*l]. position[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
-          controlsTmp[2-k +6-3*l]. position[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/
-
-          VControls[k +3*l]. position[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]);
-          VControls[k +3*l]. position[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
-          VControls[k +3*l]. position[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]);
-
-          VControls[k +3*l]. normal[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].normal[0]);
-          VControls[k +3*l]. normal[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].normal[1]);
-          VControls[k +3*l]. normal[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].normal[2]);
-
-          VControls[k +3*l]. texcoord[0][0]=    SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[0][0]);
-          VControls[k +3*l]. texcoord[0][1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[0][1]);
-          VControls[k +3*l]. texcoord[1][0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[1][0]);
-          VControls[k +3*l]. texcoord[1][1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[1][1]);
+          controls[k +3*l]. position[0] =   (    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[0]);
+          controls[k +3*l]. position[1] =   (    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
+          controls[k +3*l]. position[2] =   (    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/
+
+          controlsTmp[2-k +6-3*l]. position[0] =   (    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]);
+          controlsTmp[2-k +6-3*l]. position[1] =   (    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
+          controlsTmp[2-k +6-3*l]. position[2] =   (    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/
+
+          VControls[k +3*l]. position[0] =   (    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]);
+          VControls[k +3*l]. position[1] =   (    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
+          VControls[k +3*l]. position[2] =   (    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]);
+
+          VControls[k +3*l]. normal[0] =   (    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].normal[0]);
+          VControls[k +3*l]. normal[1] =   (    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].normal[1]);
+          VControls[k +3*l]. normal[2] =   (    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].normal[2]);
+
+          VControls[k +3*l]. texcoord[0][0]=    (    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[0][0]);
+          VControls[k +3*l]. texcoord[0][1] =   (    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[0][1]);
+          VControls[k +3*l]. texcoord[1][0] =   (    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[1][0]);
+          VControls[k +3*l]. texcoord[1][1] =   (    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[1][1]);
 
 
@@ -911,2 +975,18 @@
   //Face->n_meshverts = sz;
 }
+
+void BspFile::swapAllBspCoordinates()
+{
+  
+}
+
+void BspFile::swapCoords((int *) array)
+{
+  
+}
+
+void BspFile::swapCoords((float *) array)
+{
+  
+}
+
Index: branches/bsp_model/src/lib/graphics/importer/bsp_file.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_file.h	(revision 7800)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_file.h	(revision 7801)
@@ -17,5 +17,7 @@
 class Vector;
 class Material;
+class MoviePlayer;
 class VertexArrayModel;
+
 
 typedef struct
@@ -118,5 +120,7 @@
 {
   Material* mat;
+  MoviePlayer* aviMat;
   bool alpha;
+  bool animated;
 }
 AMat;
@@ -148,5 +152,6 @@
   BspTreeNode* get_root();
   AMat loadMat( char* mat );
-
+  AMat loadAVI(char * mat);
+ 
 
 private:
@@ -197,6 +202,11 @@
   unsigned int whiteLightMap;
   unsigned char whiteTexture[3];
+  void swapAllBspCoordinates();
+  void swapCoords(int * array);
+  void swapCoords(float * array);
   SDL_Surface* testSurf;
 
+ 
+
 };
 
Index: branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 7800)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 7801)
@@ -30,5 +30,5 @@
 #include <vector>
 #include <deque>
-
+#include "movie_player.h"
 
 
@@ -88,14 +88,14 @@
 
   this->cam = State::getCameraTargetNode()->getAbsCoor();
-  //this->checkCollision(this->root, &this->cam);   //!< Test Collision Detection
+ // this->checkCollision(this->root, &this->cam);   //!< Test Collision Detection
   this->outputStartsOut = true;
   this->outputAllSolid = false;
   this->outputFraction = 1.0f;
   
-  //this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam);
+  this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam);
   
   if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);
 
-  if (false || viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0 )  //!< if (sizeof(Visdata) == 0)
+  if ( viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0 )  //!< if (sizeof(Visdata) == 0)
   {
    
@@ -112,6 +112,5 @@
       /** Do Frustum culling and draw 'em all **/
       bool inFrustum = true;
-      float dMins;
-      float dMaxs;
+
       Vector dir;
       dir.x = this->cam.x - State::getCameraTargetNode()->getLastAbsCoor().x;
@@ -120,10 +119,14 @@
       float dist =  dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z;
       //if(dist < 0) dist = -dist;
-      dMins = dir.x*(float)curLeaf.mins[0] +dir.y*(float)curLeaf.mins[1] +dir.z*(float)curLeaf.mins[2] ;
-      dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] ;
+      const float dMins = dir.x*(float)curLeaf.mins[0] +dir.y*(float)curLeaf.mins[1] +dir.z*(float)curLeaf.mins[2] - dist ;
+      const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ;
      
-      if(dMins < -100.0 && dMaxs < -100.0)
+      if(dMins < -30.0 && dMaxs < -30.0)
       {    
-       continue; 
+       //continue; 
+      }
+      if( (this->cam - Vector(curLeaf.mins[0],curLeaf.mins[1], curLeaf.mins[2])).len() > 3000  && (this->cam - Vector(curLeaf.maxs[0],curLeaf.maxs[1], curLeaf.maxs[2])).len() > 3000)
+      {
+        //continue; 
       }
     
@@ -176,5 +179,5 @@
         const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist;
      
-        if(dMins < -100.0 && dMaxs < -100.0)
+        if(dMins < -150.0 && dMaxs < -150.0)
         {    
         continue; 
@@ -208,5 +211,7 @@
     this->trasparent.pop_back();
   }
-
+  glActiveTextureARB(GL_TEXTURE1_ARB);
+  glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap);
+  glEnable(GL_TEXTURE_2D);
 
 }//draw
@@ -220,5 +225,5 @@
   int stride = sizeof(BspVertex);  // sizeof(Vertex)
   int offset    = curFace.vertex;
-
+  if (curFace.effect != -1) return;
   // PRINTF(0)("BSP Manager: ");
   // PRINTF(0)("BSP Manager: type: %i  \n", curFace.texture);
@@ -229,10 +234,24 @@
     return;
   }
-  if(curFace.type == 3) return;
-  //  if(this->bspFile->Materials[curFace.texture] != NULL)
+  if(curFace.type != 1) return;
+  if((char*)(this->bspFile->textures)[curFace.texture*72]== 0) return;
 
   if(this->lastTex != curFace.texture) {
+    if(this->bspFile->Materials[curFace.texture].animated)
+    {
+      glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR);
+      glEnable(GL_BLEND);
+      if(this->bspFile->Materials[curFace.texture].aviMat->getStatus() == 2) this->bspFile->Materials[curFace.texture].aviMat->start(0);
+      this->bspFile->Materials[curFace.texture].aviMat->tick(0.005);
+      int n =  this->bspFile->Materials[curFace.texture].aviMat->getTexture();
+      glActiveTextureARB(GL_TEXTURE0_ARB);
+      glBindTexture(GL_TEXTURE_2D, n );
+      glDisable(GL_BLEND);
+    }
+    else
+    {
     this->bspFile->Materials[curFace.texture].mat->select();
     this->lastTex = curFace.texture;
+    }
   }
 
@@ -247,4 +266,6 @@
   }
 
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  
  // glColor4f(3.0,3.0,3.0,1.0);
   glEnableClientState(GL_VERTEX_ARRAY );
@@ -258,5 +279,5 @@
   glClientActiveTextureARB(GL_TEXTURE0_ARB);
   glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0]));
-  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+  //glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
   glClientActiveTextureARB(GL_TEXTURE1_ARB);
@@ -273,5 +294,5 @@
   glDisableClientState(GL_TEXTURE1_ARB);
   glDisableClientState(GL_VERTEX_ARRAY );
-  //glDisableClientState(GL_TEXTURE_COORD_ARRAY );
+  glDisableClientState(GL_TEXTURE_COORD_ARRAY );
   glDisableClientState(GL_NORMAL_ARRAY );
   // glDisableClientState(GL_COLOR_ARRAY);
@@ -330,5 +351,5 @@
     this->lastTex = Face->texture;
   }
-
+  if (Face->effect != -1) return;
 
 
@@ -344,13 +365,14 @@
   //glColor4f(3.0,3.0,3.0,1.0);
 
-  //glEnable( GL_AUTO_NORMAL);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glEnable( GL_AUTO_NORMAL);
   glEnableClientState(GL_VERTEX_ARRAY );
   glEnableClientState(GL_TEXTURE_COORD_ARRAY );
-  for(int i = 0; i < Face->n_meshverts  ; i++) {
-    glFrontFace(GL_CW);
+  for(int i = Face->n_meshverts -1; i >=0   ; i--) {
+   //glFrontFace(GL_CW);
     //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]);
 
 
-    glEnableClientState(GL_NORMAL_ARRAY );
+    //glEnableClientState(GL_NORMAL_ARRAY );
 
     glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0]));
@@ -358,6 +380,7 @@
 
     glClientActiveTextureARB(GL_TEXTURE0_ARB);
+    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0]));
-    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+  
 
 
@@ -367,25 +390,23 @@
 
 
-    glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) );
-
-
-
-
-    for(int row=0; row<7; ++row) {
+  //  glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) );
+
+
+
+
+    for(int row=6; row>=0; --row) {
       glDrawElements(GL_TRIANGLE_STRIP, 2*(8), GL_UNSIGNED_INT,
                      & (     (((GLuint*)  (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8]  ))  );
     }
 
-    glFrontFace(GL_CCW);
+    //glFrontFace(GL_CCW);
   }
   glDisableClientState(GL_TEXTURE0_ARB);
   glDisableClientState(GL_TEXTURE1_ARB);
-  //glDisable(GL_AUTO_NORMAL);
+  glDisable(GL_AUTO_NORMAL);
   glDisableClientState(GL_VERTEX_ARRAY );
   glDisableClientState(GL_TEXTURE_COORD_ARRAY );
 
-  glBegin(GL_QUADS);
-
-  glEnd();
+
 }
 
