Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 26, 2006, 4:37:58 PM (18 years ago)
Author:
bottac
Message:

Minor improvements (transparancy). Code formatting revised.

File:
1 edited

Legend:

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

    r7353 r7385  
    1717#include "bsp_file.h"
    1818#include "bsp_manager.h"
    19 #include "bsp_tree_node.h"
     19#include "bsp_tree_leaf.h"
    2020#include "p_node.h"
    2121#include "state.h"
     
    2323#include "material.h"
    2424#include "camera.h"
    25 
    2625#include "vertex_array_model.h"
    2726
    28 
    29 
    30 
     27// STL Containers
     28#include <vector>
     29#include <deque>
    3130
    3231
     
    3736        // open a BSP file
    3837        this->bspFile = new BspFile();
    39         this->bspFile->read("Kanti175.bsp");
     38        this->bspFile->read("/root/data/Kanti175.bsp");
    4039        this->bspFile->build_tree();
    4140        this->root  = this->bspFile->get_root();
     
    6463   // erase alreadyVisible
    6564   for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false;
    66  float tmp = 0;
     65        float tmp = 0;
     66   this->opal.clear();
     67   this->trasparent.clear();   
    6768  // Find all visible faces...
    6869
     
    110111                                        this->alreadyVisible[i] = true;
    111112                                }
    112                                 else */draw_face(f); // "visibleFaces.append(f)"
     113                                else */addFace(f); // "visibleFaces.append(f)"
    113114                        }
    114115                }
     
    150151                        if (!this->isAlreadyVisible(f) && f>=0)
    151152                        {
    152                                         this->draw_face(f);
     153                                        this->addFace(f);
    153154                                        this->alreadyVisible[f] = true;
    154155                        }
     
    161162
    162163    }//else
     164
     165while(!this->opal.empty())
     166{
     167 this->draw_face(this->opal.front());
     168  this->opal.pop_front();
     169}
     170while(!this->trasparent.empty())
     171{
     172 this->draw_face(this->trasparent.back());
     173 this->trasparent.pop_back();
     174}
    163175
    164176
     
    190202        if(this->lastTex != curFace.texture)
    191203        {
    192         this->bspFile->Materials[curFace.texture]->select();
     204        this->bspFile->Materials[curFace.texture].mat->select();
    193205        this->lastTex = curFace.texture;
    194206        }
     
    239251   // if(this->bspFile->Materials[curFace.texture] != NULL)     
    240252
    241         this->bspFile->Materials[2]->select();
     253        this->bspFile->Materials[2].mat->select();
    242254        this->lastTex = 2;
    243255
     
    266278                if(this->lastTex != Face->texture)
    267279                {
    268                 this->bspFile->Materials[Face->texture]->select();
     280                this->bspFile->Materials[Face->texture].mat->select();
    269281                this->lastTex = Face->texture;
    270282                }
     
    331343        {
    332344                dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d;
    333                 if(dist > 1.0f)
     345                if(dist > 4.0f)
    334346                {
    335347                 checkCollision(node->left,cam);
    336348                 return;
    337349                }
    338                 if(dist < -1.0f)
     350                if(dist < -4.0f)
    339351                {
    340352                 checkCollision(node->right,cam);
    341353                 return;
    342354                }
    343                 if(dist<=1.0f && dist >= -1.0f)
     355                if(dist<=4.0f && dist >= -4.0f)
    344356                        {
    345357                        checkCollision(node->left,cam);
     
    357369
    358370       
    359 
     371/*
    360372        for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ )
    361373        {
     
    376388                }
    377389                       
    378         }
     390        } */
    379391       
    380392        }
     
    454466   glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f);
    455467
    456 
    457 
    458                 glEnd();
    459 }
     468        glEnd();
     469}
     470
     471void BspManager::addFace(int f)
     472{
     473 face& curFace =  ((face *)(this->bspFile->faces))[f];
     474 if(this->bspFile->Materials[curFace.texture].alpha) this->trasparent.push_back(f);
     475 else this->opal.push_back(f);
     476}
Note: See TracChangeset for help on using the changeset viewer.