Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8088 in orxonox.OLD for branches/bsp_model/src


Ignore:
Timestamp:
Jun 1, 2006, 5:19:14 PM (19 years ago)
Author:
bensch
Message:

merge complete

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

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/Makefile.am

    r8087 r8088  
    1919                           \
    2020                           bsp_manager.cc \
    21                            bsp_file.cc
     21                           bsp_file.cc \
     22                           bsp_tree_node.cc \
     23                           bsp_tree_leaf.cc
    2224
    2325
     
    4547                \
    4648                bsp_manager.h \
    47                 bsp_file.h
     49                bsp_file.h \
     50                bsp_tree_node.h \
     51                bsp_tree_leaf.h
  • branches/bsp_model/src/lib/graphics/importer/bsp_file.cc

    r8087 r8088  
    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
    13    
     13
    1414   Inspired by:
    1515   Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
     
    1818*/
    1919
     20
    2021#include "bsp_file.h"
    2122#include "bsp_tree_node.h"
    2223#include <fstream>
     24#include "file.h"
    2325#include <sys/stat.h>
    2426#include <string.h>
     
    233235      PRINTF(4)("BSP FILE: Texture 0: %s. \n", &this->textures[8+ 72*i]);
    234236    this->load_textures();
    235    
     237
    236238    // Load the lightMaps
    237239    this->glLightMapTextures = new GLuint[this->numLightMaps];
    238240    for(int i = 0; i < this->numLightMaps; i++)
    239241      this->glLightMapTextures[i] = this->loadLightMapToGL(this->lightMaps[i]);
    240    
     242
    241243    //Create white texture for if no lightmap specified
    242244    glGenTextures(1, &this->whiteLightMap);
    243245    glBindTexture(GL_TEXTURE_2D, this->whiteLightMap);
    244         //Create texture
     246        //Create texture
    245247    this->whiteTexture[0]=255;
    246248    this->whiteTexture[1]=255;
    247249    this->whiteTexture[2]=255;
    248    
     250
    249251    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    250252    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
     
    255257
    256258
    257  
     259
    258260    /* control the mipmap levels */
    259261    glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_MIN_LOD, 5);
     
    271273                 (const GLvoid *)&(this->whiteTexture));
    272274
    273    gluBuild2DMipmaps(   GL_TEXTURE_2D, GL_RGBA8, 1, 1,
     275   gluBuild2DMipmaps(   GL_TEXTURE_2D, GL_RGBA8, 1, 1,
    274276                      GL_RGB, GL_UNSIGNED_BYTE,(const GLvoid *) &(this->whiteTexture));
    275    
    276    
     277
     278
    277279
    278280    // Get the number of patches
     
    294296
    295297    PRINTF(0)("BSP FILE:NumberOfPatches: %i . \n", numPatches);
    296    
     298
    297299    this->swapAllBspCoordinates();
    298    
     300
    299301    // Do tesselation for all Faces of type 2
    300302    for( int i = 0; i < this->numFaces; i++) {
     
    310312    return -1;
    311313  }
    312  
    313  
     314
     315
    314316
    315317}
     
    343345  float z1 =(((plane *) this->planes) [planeIndex]).z;
    344346  thisNode->leafIndex = 0;
    345   thisNode->d          = (((plane *) this->planes) [planeIndex]).d;
     347  thisNode->d          = (((plane *) this->planes) [planeIndex]).d;
    346348
    347349  thisNode->plane = Vector(x1,y1,z1);
     
    389391  char ext [100];
    390392  struct stat results;
    391  
    392  
     393
     394
    393395  this->Materials = new AMat[this->numTextures];
    394396  for(int i = 0 ; i < this->numTextures; i++) {
    395397    PRINTF(0)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]);
    396    
    397    
     398
     399
    398400    strcpy(fileName, &this->textures[8+ 72*i]);
    399401    if(strlen(fileName) == 0)
    400402    {
    401      //         Default Material
     403     //         Default Material
    402404      this->Materials[i].mat = new Material();
    403405    this->Materials[i].mat->setDiffuse(0.1,0.1,1.0);
     
    412414    this->Materials[i].animated = false;
    413415     continue;
    414     } 
    415    
     416    }
     417
    416418      // Check for mov
    417419    strcpy(fileName, &this->textures[8+ 72*i]);
     
    421423    absFileName = ResourceManager::getFullName(fileName);
    422424
    423     if(ResourceManager::isFile(absFileName)) {
     425    if(File(absFileName).exists()) {
    424426      PRINTF(0)("BSP FILE: gefunden . \n");
    425427      this->Materials[i] = this->loadAVI(fileName);
    426428      continue;
    427429    }
    428      
     430
    429431    // Check for avi
    430432    strcpy(fileName, &this->textures[8+ 72*i]);
     
    434436    absFileName = ResourceManager::getFullName(fileName);
    435437
    436     if(ResourceManager::isFile(absFileName)) {
     438    if(File(absFileName).exists()) {
    437439      PRINTF(0)("BSP FILE: gefunden . \n");
    438440      this->Materials[i] = this->loadAVI(fileName);
    439441      continue;
    440442    }
    441    
     443
    442444       // Check for mpg
    443445    strcpy(fileName, &this->textures[8+ 72*i]);
     
    447449    absFileName = ResourceManager::getFullName(fileName);
    448450
    449     if(ResourceManager::isFile(absFileName)) {
     451    if(File(absFileName).exists()) {
    450452      PRINTF(0)("BSP FILE: gefunden . \n");
    451453      this->Materials[i] = this->loadAVI(fileName);
    452454      continue;
    453455    }
    454    
     456
    455457    // Check for tga
    456458    strcpy(fileName, &this->textures[8+ 72*i]);
     
    460462    absFileName = ResourceManager::getFullName(fileName);
    461463
    462     if(ResourceManager::isFile(absFileName)) {
     464    if(File(absFileName).exists()) {
    463465      PRINTF(0)("BSP FILE: gefunden . \n");
    464466      this->Materials[i] = this->loadMat(fileName);
     
    471473    absFileName = ResourceManager::getFullName(fileName);
    472474
    473     if(ResourceManager::isFile(absFileName)/*stat( absFileName.c_str() , &results) == 0*/) {
     475    if(File(absFileName).exists()/*stat( absFileName.c_str() , &results) == 0*/) {
    474476      PRINTF(0)("BSP FILE: gefunden . \n");
    475477      this->Materials[i] = this->loadMat(fileName);
     
    481483    strncat (fileName, ext, strlen(fileName));
    482484    absFileName = ResourceManager::getFullName(fileName);
    483     if(ResourceManager::isFile(absFileName)) {
     485    if(File(absFileName).exists()) {
    484486      PRINTF(0)("BSP FILE: gefunden . \n");
    485487      this->Materials[i] =this->loadMat(fileName);
     
    493495    strncat (fileName, ext, strlen(fileName));
    494496    absFileName = ResourceManager::getFullName(fileName);
    495     if(ResourceManager::isFile(absFileName)) {
     497    if(File(absFileName).exists()) {
    496498      PRINTF(0)("BSP FILE: gefunden . \n");
    497499      this->Materials[i] =this->loadMat(fileName);
     
    499501    }
    500502
    501    
     503
    502504
    503505    // Check for bmp
     
    507509    absFileName = ResourceManager::getFullName(fileName);
    508510
    509     if(ResourceManager::isFile(absFileName)) {
     511    if(File(absFileName).exists()) {
    510512      PRINTF(0)("BSP FILE: gefunden . \n");
    511513      this->Materials[i] =this->loadMat(fileName);
     
    519521    absFileName = ResourceManager::getFullName(fileName);
    520522
    521     if(ResourceManager::isFile(absFileName)) {
     523    if(File(absFileName).exists()) {
    522524      PRINTF(0)("BSP FILE: gefunden . \n");
    523525      this->Materials[i] = this->loadMat(fileName);
    524526      continue;
    525527    }
    526    
    527    
    528     //  Default Material
     528
     529
     530    //  Default Material
    529531    this->Materials[i].mat = new Material();
    530532    this->Materials[i].mat->setDiffuse(0.1,0.1,0.1);
     
    538540    this->Materials[i].alpha = true;
    539541    this->Materials[i].animated = false;
    540    
     542
    541543  }
    542544}
     
    551553  if(this->testSurf != NULL) {
    552554    if(this->testSurf->format->Amask != 0 ) tmpAMat.alpha = true;
    553     else                                       tmpAMat.alpha = false;
     555    else                                       tmpAMat.alpha = false;
    554556  } else   tmpAMat.alpha = false;
    555557
     
    558560   tmp->setAmbient(1.0,1.0,1.0 );
    559561  tmp->setSpecular(1.0,1.0,1.0);
    560   //    tmp->setShininess(.5);
    561   //    tmp->setTransparency(0.0);
     562  //    tmp->setShininess(.5);
     563  //    tmp->setTransparency(0.0);
    562564
    563565  tmp->setDiffuseMap(mat);
     
    580582  //tmp->setAmbient(1.0,1.0,1.0 );
    581583  //tmp->setSpecular(1.0,1.0,1.0);
    582   //    tmp->setShininess(.5);tmpAMat
    583   //    tmp->setTransparency(0.0);
     584  //    tmp->setShininess(.5);tmpAMat
     585  //    tmp->setTransparency(0.0);
    584586
    585587  //tmp->setDiffuseMap(mat);
     
    608610  sc*=scale;
    609611  if(false)
    610     ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 75; 
     612    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 75;
    611613  else
    612614    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc ;
    613615  }
    614  
     616
    615617  glGenTextures(1, &lightMap);
    616618  glBindTexture(GL_TEXTURE_2D,  lightMap);
     
    638640                   (const GLvoid *)&lightMapTexture);
    639641
    640    
     642
    641643   // build the MipMaps automaticaly
    642644   errorCode = gluBuild2DMipmaps(GL_TEXTURE_2D,
     
    648650                                 (const GLvoid *)&lightMapTexture
    649651                                );
    650    
     652
    651653
    652654
     
    658660/**
    659661 * Generates a vertex-array, a indice-array and a texture-coordinates-array for iface.
    660  * @param iface integer index of face 
     662 * @param iface integer index of face
    661663 * @todo cleanup this function, let the user choose the level of tesselation
    662664 */
    663  
    664  
     665
     666
    665667void BspFile::tesselate(int iface)
    666668{
     
    791793
    792794
    793           //Vertice[u*(tesselation+1)+v]=       temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px);
     795          //Vertice[u*(tesselation+1)+v]=       temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px);
    794796          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);
    795797          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);
     
    826828      // Debug Model
    827829      //***********************************************************************************************************************
    828      
     830
    829831      this->VertexArrayModels[this->patchOffset] = new VertexArrayModel();
    830832      VertexArrayModel*  tmp = this->VertexArrayModels[this->patchOffset];
     
    989991void BspFile::swapAllBspCoordinates()
    990992{
    991  
     993
    992994  for(int i = 0; i < this->numVertex ; ++i)
    993995  {
     
    995997    this->swapCoords(&((BspVertex *)this->vertice)[i].normal[0]);
    996998
    997    
     999
    9981000  }
    999  
     1001
    10001002  for(int i = 0; i < this->numLeafs ; ++i)
    10011003  {
    10021004    this->swapCoords(this->leaves[i].mins);
    10031005    this->swapCoords(this->leaves[i].maxs);
    1004  
     1006
    10051007  }
    1006  
     1008
    10071009  for(int i = 0; i < this->numPlanes; ++i)
    10081010  {
     
    10141016  }
    10151017
    1016    
     1018
    10171019  for(int i = 0; i < this->numFaces; ++i)
    10181020  {
    10191021    this->swapCoords(this->faces[i].normal);
    10201022  }
    1021  
     1023
    10221024}
    10231025
     
    10361038    array[0] =  scale * array[1] ;
    10371039    array[1] =  scale * array[2];
    1038     array[2] =  scale * sto ; 
     1040    array[2] =  scale * sto ;
    10391041  }
    1040  
     1042
    10411043}
    10421044
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc

    r8087 r8088  
    901901
    902902    // Return the normal here: Normal's stored in this->collPlane;
    903     if(collision) worldEntity->collidesWithGround(out,out1,out2);
     903//    if(collision) worldEntity->collidesWithGround(out,out1,out2);
    904904
    905905  }
Note: See TracChangeset for help on using the changeset viewer.