Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2006, 2:37:13 PM (19 years ago)
Author:
bensch
Message:

orxonox/bsp_model: Material should support multiple Textures now

File:
1 edited

Legend:

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

    r7465 r7510  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44   Copyright (C) 2006 orx
    5  
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10  
     10
    1111   ### File Specific:
    1212   main-programmer: bottac@ee.ethz.ch
     
    5151  // Draw Debug Terrain
    5252  /*
    53   this->bspFile->Materials[0]->select(); 
     53  this->bspFile->Materials[0]->select();
    5454  for(int i = 0; i <  this->bspFile->numPatches ; i++)
    55         {
    56                 this->bspFile->VertexArrayModels[i]->draw();
    57    
    58         }
     55        {
     56                this->bspFile->VertexArrayModels[i]->draw();
     57
     58        }
    5959  */
    6060
     
    103103        if (f >=0 && !this->isAlreadyVisible(f)) {
    104104          this->alreadyVisible[f] = true;
    105           /*    if(ActLeaf->leafIndex == i)public final double readLEDouble()
    106                 {
    107                         this->alreadyVisible[i] = false;
    108                         this->draw_debug_face(f);
    109                         this->alreadyVisible[i] = true;
    110                 } 
     105          /*    if(ActLeaf->leafIndex == i)public final double readLEDouble()
     106                {
     107                        this->alreadyVisible[i] = false;
     108                        this->draw_debug_face(f);
     109                        this->alreadyVisible[i] = true;
     110                }
    111111                else */
    112112          addFace(f); // "visibleFaces.append(f)"
     
    131131      leaf& curLeaf =  (this->bspFile->leaves)[i] ;
    132132      cluster =  curLeaf.cluster;
    133      
     133
    134134      if(cluster <0) continue;
    135135      v = ((viscluster *  ( ((int *)this->bspFile->visData)[1]) ) + (cluster / 8));
    136136      visSet =((unsigned char*) (this->bspFile->visData))[v+8];
    137    
    138      
     137
     138
    139139      if( ((visSet) & ((unsigned char)1 <<(unsigned char) (cluster &  7))) == 0 )
    140140      {
     
    191191  // if(this->bspFile->Materials[curFace.texture] != NULL)
    192192  //if(this->lastTex != curFace.texture) {
    193     this->bspFile->Materials[curFace.texture].mat->select0();
     193    this->bspFile->Materials[curFace.texture].mat->select();
    194194  //   this->lastTex = curFace.texture;
    195195  //}
    196    
    197     if(curFace.lm_index < 0) 
     196
     197    if(curFace.lm_index < 0)
    198198    {
    199199      glActiveTextureARB(GL_TEXTURE1_ARB);
     
    207207    glEnable(GL_TEXTURE_2D);
    208208    }
    209    
     209
    210210    glColor4f(3.0,3.0,3.0,0.9);
    211211  glEnableClientState(GL_VERTEX_ARRAY );
     
    213213  glEnableClientState(GL_NORMAL_ARRAY );
    214214  //  glEnableClientState(GL_COLOR_ARRAY);
    215  
     215
    216216
    217217  glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0]));
    218  
     218
    219219  glClientActiveTextureARB(GL_TEXTURE0_ARB);
    220220  glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0]));
    221221  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    222  
     222
    223223  glClientActiveTextureARB(GL_TEXTURE1_ARB);
    224224  glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1]));
    225225  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    226226
    227  
     227
    228228  glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0]));
    229229  // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0]));
     
    288288{
    289289  if(this->lastTex != Face->texture) {
    290     this->bspFile->Materials[Face->texture].mat->select0();
     290    this->bspFile->Materials[Face->texture].mat->select();
    291291    this->lastTex = Face->texture;
    292292  }
    293  
    294  
    295  
    296   if(Face->lm_index < 0) 
     293
     294
     295
     296  if(Face->lm_index < 0)
    297297  {
    298298    glActiveTextureARB(GL_TEXTURE1_ARB);
     
    307307}
    308308    glColor4f(3.0,3.0,3.0,0.9);
    309  
     309
    310310  glEnable( GL_AUTO_NORMAL);
    311311  glEnableClientState(GL_VERTEX_ARRAY );
     
    314314    glFrontFace(GL_CW);
    315315    //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]);
    316  
    317  
     316
     317
    318318    glEnableClientState(GL_NORMAL_ARRAY );
    319319
    320320    glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0]));
    321    
    322    
     321
     322
    323323    glClientActiveTextureARB(GL_TEXTURE0_ARB);
    324324    glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0]));
    325325    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    326326
    327    
     327
    328328    glClientActiveTextureARB(GL_TEXTURE1_ARB);
    329329    glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[1][0]));
    330330    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    331331
    332    
     332
    333333    glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) );
    334334
     
    344344                     & (     (((GLuint*)  (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8]  ))  );
    345345    }
    346    
     346
    347347    glFrontFace(GL_CCW);
    348348  }
     
    352352  glDisableClientState(GL_VERTEX_ARRAY );
    353353  glDisableClientState(GL_TEXTURE_COORD_ARRAY );
    354  
     354
    355355  glBegin(GL_QUADS);
    356  
     356
    357357  glEnd();
    358358}
     
    406406
    407407    /*
    408         for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ )
    409         {
    410                 brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes];
    411                 if(curBrush.n_brushsides < 0) return;
    412                 for(int j = 0; j < curBrush.n_brushsides; j++)
    413                 {
    414                 float dist = -0.1;
    415                 brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides];
    416                 plane&      testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes];
    417                 dist = testPlane.x * this->cam.x +  testPlane.y * this->cam.y  +  testPlane.z * this->cam.z   -testPlane.d ;
    418                
    419                 if(dist < -0.01f) dist = -1.0f *dist;
    420                 if(dist < 1.0f){
    421                                 this->drawDebugCube(&this->cam);
    422                                 return;
    423                               }
    424                 }
    425                        
    426         } */
     408        for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ )
     409        {
     410                brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes];
     411                if(curBrush.n_brushsides < 0) return;
     412                for(int j = 0; j < curBrush.n_brushsides; j++)
     413                {
     414                float dist = -0.1;
     415                brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides];
     416                plane&      testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes];
     417                dist = testPlane.x * this->cam.x +  testPlane.y * this->cam.y  +  testPlane.z * this->cam.z   -testPlane.d ;
     418
     419                if(dist < -0.01f) dist = -1.0f *dist;
     420                if(dist < 1.0f){
     421                                this->drawDebugCube(&this->cam);
     422                                return;
     423                              }
     424                }
     425
     426        } */
    427427
    428428  }
Note: See TracChangeset for help on using the changeset viewer.