Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7544 in orxonox.OLD for branches/bsp_model/src/lib


Ignore:
Timestamp:
May 5, 2006, 8:23:48 PM (19 years ago)
Author:
bottac
Message:

bsp_file looks now in the orxonox data-directory for textures.

Location:
branches/bsp_model/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/bsp_file.cc

    r7524 r7544  
    4545  int size;
    4646  struct stat results;
    47   name = "/home/stefalie/svn/orxonox/data/Kanti175.bsp";
     47  name = "/root/data/Kanti175.bsp";
    4848
    4949  if (stat( name , &results) == 0) {
     
    256256    glTexImage2D(GL_TEXTURE_2D,
    257257                 0,
    258                  GL_RGB,
     258                 GL_RGBA8,
    259259                 1,
    260260                 1,
     
    264264                 (const GLvoid *)&(this->whiteTexture));
    265265
    266     gluBuild2DMipmaps(  GL_TEXTURE_2D, GL_RGB, 1, 1,
    267                        GL_RGB, GL_FLOAT,(const GLvoid *) &(this->whiteTexture));
     266   gluBuild2DMipmaps(   GL_TEXTURE_2D, GL_RGBA8, 1, 1,
     267                      GL_RGB, GL_UNSIGNED_BYTE,(const GLvoid *) &(this->whiteTexture));
    268268   
    269269   
     
    373373void BspFile::load_textures()
    374374{
    375   char absFileName [228];
     375  ::std::string absFileName;
    376376  char fileName [228];
    377377  char ext [100];
    378378  struct stat results;
    379 
     379 
     380 
    380381  this->Materials = new AMat[this->numTextures];
    381382  for(int i = 0 ; i < this->numTextures; i++) {
    382383    PRINTF(0)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]);
    383 
     384   
     385   
     386    strcpy(fileName, &this->textures[8+ 72*i]);
     387    if(strlen(fileName) == 0)
     388    {
     389     //         Default Material
     390      this->Materials[i].mat = new Material();
     391    this->Materials[i].mat->setDiffuse(0.1,0.1,0.1);
     392    this->Materials[i].mat->setAmbient(0.1,0.1,0.1 );
     393    this->Materials[i].mat->setSpecular(0.4,0.4,0.4);
     394    //this->Materials[i]->setShininess(100.0);
     395    this->Materials[i].mat->setTransparency(1.0);
     396    this->Materials[i].mat->setDiffuseMap("pictures/ground.tga");
     397    this->Materials[i].mat->setAmbientMap("pictures/ground.tga");
     398    this->Materials[i].mat->setSpecularMap("pictures/ground.tga");
     399    this->Materials[i].alpha = false;
     400     continue;
     401    }
     402     
     403   
    384404    // Check for tga
    385405    strcpy(fileName, &this->textures[8+ 72*i]);
    386     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    387406    strcpy(ext, ".tga");
    388407    strncat (fileName, ext, strlen(fileName));
    389     strncat(absFileName,fileName,strlen(fileName));
    390     // absFileName = ResourceManager::getFullName(fileName);
    391 
    392     if(stat( absFileName , &results) == 0) {
     408
     409    absFileName = ResourceManager::getFullName(fileName);
     410
     411    if(ResourceManager::isFile(absFileName)) {
    393412      PRINTF(0)("BSP FILE: gefunden . \n");
    394413      this->Materials[i] = this->loadMat(fileName);
     
    397416    // Check for TGA
    398417    strcpy(fileName, &this->textures[8+ 72*i]);
    399     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    400418    strcpy(ext, ".TGA");
    401419    strncat (fileName, ext, strlen(fileName));
    402     strncat(absFileName,fileName,strlen(fileName));
    403     // absFileName = ResourceManager::getFullName(fileName);
    404 
    405     if(stat( absFileName , &results) == 0) {
     420    absFileName = ResourceManager::getFullName(fileName);
     421
     422    if(ResourceManager::isFile(absFileName)/*stat( absFileName.c_str() , &results) == 0*/) {
    406423      PRINTF(0)("BSP FILE: gefunden . \n");
    407424      this->Materials[i] = this->loadMat(fileName);
     
    410427    // Check for jpg
    411428    strcpy(fileName, &this->textures[8+ 72*i]);
    412     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    413429    strcpy(ext, ".jpg");
    414430    strncat (fileName, ext, strlen(fileName));
    415     strncat(absFileName,fileName,strlen(fileName));
    416     // absFileName = ResourceManager::getFullName(fileName);
    417     if(stat( absFileName , &results) == 0) {
     431    absFileName = ResourceManager::getFullName(fileName);
     432    if(ResourceManager::isFile(absFileName)) {
    418433      PRINTF(0)("BSP FILE: gefunden . \n");
    419434      this->Materials[i] =this->loadMat(fileName);
     
    424439    // Check for JPG
    425440    strcpy(fileName, &this->textures[8+ 72*i]);
    426     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    427441    strcpy(ext, ".JPG");
    428442    strncat (fileName, ext, strlen(fileName));
    429     strncat(absFileName,fileName,strlen(fileName));
    430     // absFileName = ResourceManager::getFullName(fileName);
    431     if(stat( absFileName , &results) == 0) {
     443    absFileName = ResourceManager::getFullName(fileName);
     444    if(ResourceManager::isFile(absFileName)) {
    432445      PRINTF(0)("BSP FILE: gefunden . \n");
    433446      this->Materials[i] =this->loadMat(fileName);
     
    435448    }
    436449
    437     // Check for jpeg
     450   
     451
     452    // Check for bmp
    438453    strcpy(fileName, &this->textures[8+ 72*i]);
    439     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    440     strcpy(ext, ".jpeg");
     454    strcpy(ext, ".bmp");
    441455    strncat (fileName, ext, strlen(fileName));
    442     strncat(absFileName,fileName,strlen(fileName));
    443     // absFileName = ResourceManager::getFullName(fileName);
    444     if(stat( absFileName , &results) == 0) {
     456    absFileName = ResourceManager::getFullName(fileName);
     457
     458    if(ResourceManager::isFile(absFileName)) {
    445459      PRINTF(0)("BSP FILE: gefunden . \n");
    446460      this->Materials[i] =this->loadMat(fileName);
     
    448462    }
    449463
    450 
    451     // Check for JPEG
    452     strcpy(fileName, &this->textures[8+ 72*i]);
    453     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    454     strcpy(ext, ".JPEG");
    455     strncat (fileName, ext, strlen(fileName));
    456     strncat(absFileName,fileName,strlen(fileName));
    457     // absFileName = ResourceManager::getFullName(fileName);
    458     PRINTF(0)("BSP FILE: %s . \n", absFileName);
    459     if(stat( absFileName , &results) == 0) {
    460       PRINTF(0)("BSP FILE: gefunden . \n");
    461       this->Materials[i] =this->loadMat(fileName);
    462       continue;
    463     }
    464 
    465     // Check for bmp
    466     strcpy(fileName, &this->textures[8+ 72*i]);
    467     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    468     strcpy(ext, ".bmp");
    469     strncat (fileName, ext, strlen(fileName));
    470     strncat(absFileName,fileName,strlen(fileName));
    471     // absFileName = ResourceManager::getFullName(fileName);
    472 
    473     if(stat( absFileName , &results) == 0) {
    474       PRINTF(0)("BSP FILE: gefunden . \n");
    475       this->Materials[i] =this->loadMat(fileName);
    476      
    477     }
    478 
    479464    // Check for BMP
    480465    strcpy(fileName, &this->textures[8+ 72*i]);
    481     strcpy (absFileName,"/home/stefalie/svn/orxonox/data/trunk/");
    482466    strcpy(ext, ".BMP");
    483467    strncat (fileName, ext, strlen(fileName));
    484     strncat(absFileName,fileName,strlen(fileName));
    485     // absFileName = ResourceManager::getFullName(fileName);
    486 
    487     if(false /*stat( absFileName , &results) == 0*/) {
     468    absFileName = ResourceManager::getFullName(fileName);
     469
     470    if(ResourceManager::isFile(absFileName)) {
    488471      PRINTF(0)("BSP FILE: gefunden . \n");
    489472      this->Materials[i] = this->loadMat(fileName);
    490473      continue;
    491474    }
     475   
     476   
    492477    //  Default Material
    493478    this->Materials[i].mat = new Material();
     
    501486    this->Materials[i].mat->setSpecularMap("pictures/ground.tga");
    502487    this->Materials[i].alpha = false;
     488   
    503489  }
    504490}
     
    524510
    525511  tmp->setDiffuseMap(mat);
    526   tmp->setAmbientMap(mat);
    527   tmp->setSpecularMap(mat);
    528512
    529513  tmpAMat.mat = tmp;
     
    535519{
    536520  int      errorCode = 0;           //!< the error code for the texture loading functions
    537   unsigned int   lightMap;                 //!< the OpenGL texture handle
     521  unsigned int   lightMap;          //!< the OpenGL texture handle
    538522  int      mipmapLevel = 0;         //!< the maximum mipmap level for this texture
    539523  int      mipmapWidth = 0;         //!< the width of the mipmap
     
    544528  {
    545529  sc =  ((unsigned char *)(&lightMapTexture))[i];
    546   sc *= 10.5/255.0;
     530  sc *= 1/255.0;
    547531  scale = 1.0;
    548532  if(sc > 1.0f && (temp = (1.0f/sc)) < scale) scale=temp;
    549533  scale*=255.0;
    550534  sc*=scale;
    551     ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc;
    552    
    553  
     535  if(sc <= 205)
     536    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 50;
     537  else
     538    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc;
    554539  }
    555540 
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc

    r7511 r7544  
    189189  }
    190190  if(curFace.type == 3) return;
    191   // if(this->bspFile->Materials[curFace.texture] != NULL)
    192   //if(this->lastTex != curFace.texture) {
     191//  if(this->bspFile->Materials[curFace.texture] != NULL)
     192   
     193  if(this->lastTex != curFace.texture) {
    193194    this->bspFile->Materials[curFace.texture].mat->select();
    194   //   this->lastTex = curFace.texture;
    195   //}
     195     this->lastTex = curFace.texture;
     196  }
    196197   
    197198    if(curFace.lm_index < 0)
     
    208209    }
    209210   
    210     glColor4f(3.0,3.0,3.0,0.9);
    211   glEnableClientState(GL_VERTEX_ARRAY ); 
    212   //glEnableClientState(GL_TEXTURE_COORD_ARRAY );
     211    glColor4f(3.0,3.0,3.0,1.0);
     212  glEnableClientState(GL_VERTEX_ARRAY );
     213  glEnableClientState(GL_TEXTURE_COORD_ARRAY );
    213214  glEnableClientState(GL_NORMAL_ARRAY );
    214215  //  glEnableClientState(GL_COLOR_ARRAY);
     
    223224  glClientActiveTextureARB(GL_TEXTURE1_ARB);
    224225  glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1]));
    225   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     226  //glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    226227
    227228 
     
    287288void BspManager::draw_patch(face* Face)
    288289{
    289   //if(this->lastTex != Face->texture) {
     290  if(this->lastTex != Face->texture) {
    290291    this->bspFile->Materials[Face->texture].mat->select();
    291     //this->lastTex = Face->texture;
    292   //}
     292    this->lastTex = Face->texture;
     293  }
    293294 
    294295 
     
    306307    glEnable(GL_TEXTURE_2D);
    307308}
    308     glColor4f(3.0,3.0,3.0,0.9);
     309    glColor4f(3.0,3.0,3.0,1.0);
    309310 
    310311  glEnable( GL_AUTO_NORMAL);
     
    328329    glClientActiveTextureARB(GL_TEXTURE1_ARB);
    329330    glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[1][0]));
    330     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     331    //glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    331332
    332333   
Note: See TracChangeset for help on using the changeset viewer.