Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9003 in orxonox.OLD for trunk/src/lib/graphics/importer


Ignore:
Timestamp:
Jul 2, 2006, 1:36:13 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the single_player_map branche back
merged with command:
svn merge -r8896:HEAD https://svn.orxonox.net/orxonox/branches/single_player_map .
no conflicts

Location:
trunk/src/lib/graphics/importer
Files:
7 edited

Legend:

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

    r8894 r9003  
    4646BspFile::BspFile()
    4747{}
     48
     49BspFile::~ BspFile()
     50{
     51  delete [] nodes;
     52  delete [] leaves;
     53  delete [] planes;
     54  delete [] bspModels;
     55  delete [] leafFaces;
     56  delete [] faces;
     57  delete [] leafBrushes;
     58  delete [] brushes;
     59  delete [] brushSides;
     60  delete [] vertice;
     61  delete [] meshverts;
     62  delete [] visData;
     63  delete [] textures;
     64  delete [] patchVertice;
     65  delete [] patchIndexes;
     66 // delete [] patchTrianglesPerRow;
     67  delete [] lightMaps;
     68 
     69  for(int i = 0; i < this->numPatches; ++i) delete this->VertexArrayModels[i];
     70 // delete  [] VertexArrayModels;
     71 
     72  for(int i = 0; i < this->numTextures; ++i)
     73  {
     74    delete this->Materials[i].mat;
     75    //delete this->Materials[i].aviMat;
     76  }
     77  delete [] this->Materials;
     78  //delete [] testSurf;
     79 
     80 
     81 
     82}
    4883
    4984/**
     
    294329    this->patchVertice = new char[8*8*44*(this->numPatches+10)];
    295330    this->patchIndexes = new char[7*8*2*4*(this->numPatches+10)];
    296     this->patchRowIndexes = new int*[7*4*this->numPatches];
     331 // this->patchRowIndexes = new int*[7*4*this->numPatches]; Not needed?
    297332    this->patchTrianglesPerRow = new char[7*4*this->numPatches];
    298333    this->VertexArrayModels  = new VertexArrayModel*[this->numPatches];
     
    464499
    465500    if(File(absFileName).exists()) {
    466       PRINTF(0)("BSP FILE: gefunden . \n");
     501      PRINTF(4)("BSP FILE: gefunden . \n");
    467502      this->Materials[i] = this->loadAVI(fileName);
    468503      continue;
     
    553588    }
    554589
    555     PRINTF(0)("BSP FILE: Textur %s nicht  gefunden . \n", &this->textures[8+72*i]);
     590    PRINTF(0)("BSP FILE: Texture %s not found.",&this->textures[8+ 72*i] );
    556591    //  Default Material
    557592    this->Materials[i].mat = new Material();
     
    10121047  Face->meshvert = patchOffset -sz;  //3*(patchOffset-sz)*level1*level1;
    10131048  Face->n_meshverts = sz;
    1014   PRINTF(4)("BSP FILE: sz: %i. \n", sz);
    1015   PRINTF(4)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
     1049  PRINTF(0)("BSP FILE: sz: %i. \n", sz);
     1050  PRINTF(0)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
    10161051
    10171052  //Face->n_meshverts = sz;
  • trunk/src/lib/graphics/importer/bsp_file.h

    r8490 r9003  
    151151public:
    152152  BspFile();
     153  ~BspFile();
    153154  int read(const char* name );
    154155  void build_tree();
     
    183184
    184185  int** patchRowIndexes;
    185   VertexArrayModel** VertexArrayModels;
     186  VertexArrayModel** VertexArrayModels; 
    186187  int patchOffset;
    187188
  • trunk/src/lib/graphics/importer/bsp_manager.cc

    r8894 r9003  
    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
    1616   Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
    17  
     17
    1818   Collision detection adapted from:
    1919   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
     
    6969BspManager::BspManager(const TiXmlElement* root)
    7070{
    71  
    72  
     71
     72
    7373  if( root != NULL)
    7474    this->loadParams(root);
    75  
     75
    7676  CDEngine::getInstance()->setBSPModel(this);
    7777} */
    7878
    79 void BspManager::load(const char* fileName, float scale)
     79BspManager::~BspManager()
     80{
     81  if(this->bspFile)
     82    delete this->bspFile;
     83}
     84
     85int BspManager::load(const char* fileName, float scale)
    8086{
    8187  // open a BSP file
     88
     89
    8290  this->bspFile = new BspFile();
    8391  this->bspFile->scale =  scale;
    84   this->bspFile->read(ResourceManager::getFullName(fileName).c_str());
     92  if(this->bspFile->read(ResourceManager::getFullName(fileName).c_str()) == -1)
     93    return -1;
     94
    8595  this->bspFile->build_tree();
    8696  this->root  = this->bspFile->get_root();
     
    8898
    8999  this->outputFraction = 1.0f;
     100
     101  return 0;
    90102}
    91103/*
     
    99111  this->root  = this->bspFile->get_root();
    100112  this->alreadyVisible = new bool [this->bspFile->numFaces];
    101  
     113
    102114  CDEngine::getInstance()->setBSPModel(this);
    103115}
     
    962974  Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    963975  Vector dest1 = position + forwardDir*4.0f;
    964   Vector dest2 = position2 + forwardDir;
     976  Vector dest2 = position2 + forwardDir*4.0;
    965977  dest = position - Vector(0.0, 40.0,0.0);
    966978  Vector out = dest;
     
    974986
    975987  if( box != NULL) {
    976     position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
    977     dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
    978 
    979     position1 = worldEntity->getAbsCoor() +  box->center + box->axis[0] * box->halfLength[0] * 2.0f;
    980     dest1     = worldEntity->getAbsCoor() +  box->center - box->axis[0] * box->halfLength[0] *2.0f;
    981 
    982 
    983     position2 = worldEntity->getAbsCoor() +  box->center + box->axis[2] * box->halfLength[2] * 2.0f;
    984     dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
     988    position = worldEntity->getAbsCoor() +  box->center + Vector(0.0, 1.0, 0.0) * box->halfLength[1];
     989    dest     = worldEntity->getAbsCoor() +  box->center - Vector(0.0, 1.0, 0.0) * (box->halfLength[1] + BSP_Y_OFFSET);
     990
     991    position1 = worldEntity->getAbsCoor() +  box->center - worldEntity->getAbsDirX() * (box->halfLength[0]  + BSP_X_OFFSET);
     992    dest1     = worldEntity->getAbsCoor() +  box->center + worldEntity->getAbsDirX() * (box->halfLength[0]  + BSP_X_OFFSET);
     993
     994    position2 = worldEntity->getAbsCoor() +  box->center - worldEntity->getAbsDirZ() * (box->halfLength[2]  + BSP_Z_OFFSET);
     995    dest2     = worldEntity->getAbsCoor() +  box->center + worldEntity->getAbsDirZ() * (box->halfLength[2]  + BSP_Z_OFFSET);
    985996
    986997  } else {
     
    9891000  }
    9901001
     1002
     1003//   PRINTF(0)("x and v\n");
     1004//   worldEntity->getAbsDirX().debug();
     1005//   worldEntity->getAbsDirV().debug();
    9911006
    9921007
     
    10351050  plane* testPlane = this->collPlane;
    10361051
    1037 
    10381052  bool xCollision = false;
    10391053  bool zCollision = false;
    1040   if(!SolidFlag) {
     1054
    10411055
    10421056    // 2nd Collision Detection
     
    10481062    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
    10491063
    1050     if(!this->outputAllSolid != 1.0f) {
     1064    if(this->outputFraction < 1.0f) {
    10511065      out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction;
     1066      dest1 = position1 + (dest1 -position1) * this->outputFraction;
    10521067      xCollision = true;
    10531068      testPlane = this->collPlane;
    10541069    }
    1055     if(this->outputAllSolid) {
     1070    if(this->outputAllSolid ) {
     1071
     1072      this->collPlane = new plane;
     1073      this->collPlane->x = 0.0f;
     1074      this->collPlane->y = 0.0f;
     1075      this->collPlane->z = 0.0f;
     1076      testPlane = this->collPlane;
    10561077      SolidFlag = true;
    1057       xCollision = true; 
     1078      xCollision = true;
    10581079    }
    10591080    //out.z = this->outputFraction;
    10601081
    1061     if(!SolidFlag) {
     1082
    10621083
    10631084      // 3rd Collision Detection
     
    10671088      this->inputStart =  position2;
    10681089      this->inputEnd =   dest2;
     1090
    10691091      this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    10701092      //out.x = this->outputFraction;
    10711093
    1072       if(this->outputFraction != 1.0f ) {
     1094      if(this->outputFraction < 1.0f ) {
    10731095        out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction;
     1096        dest2 = position2 + (dest2 -position2) * this->outputFraction;
    10741097        zCollision = true;
    10751098        testPlane = this->collPlane;
    10761099
    10771100      }
    1078       if(this->outputAllSolid) {
    1079           SolidFlag = true;
    1080           zCollision = true;   
     1101      if(this->outputAllSolid ) {
     1102        this->collPlane = new plane;
     1103        this->collPlane->x = 0.0f;
     1104        this->collPlane->y = 0.0f;
     1105        this->collPlane->z = 0.0f;
     1106        testPlane = this->collPlane;
     1107
     1108        SolidFlag = true;
     1109        zCollision = true;
    10811110      }
    1082     }
    1083   }//end if
     1111
     1112  //end if
    10841113  /*
    10851114  This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
     
    10911120  // Return the normal here: Normal's stored in this->collPlane;
    10921121  if( collision) {
    1093     PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    1094     worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y || (xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0), this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
    1095   } else {
    1096     if(xCollision || zCollision) {
    1097 
    1098       worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
    1099     }
    1100 
    1101   }
     1122    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1123}
     1124  if(xCollision) {
     1125    worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag);
     1126  }
     1127  if(zCollision) {
     1128    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag);
     1129  }
     1130
     1131
    11021132  //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
    11031133
  • trunk/src/lib/graphics/importer/bsp_manager.h

    r8724 r9003  
    2828
    2929
     30#define BSP_X_OFFSET 20.0f
     31#define BSP_Y_OFFSET 40.0f
     32#define BSP_Z_OFFSET 20.0f
     33
    3034
    3135// FORWARD DECLARATIONS
     
    4145class WorldEntity;
    4246
     47
     48// Obsolete
    4349struct BspCollisionEvent
    4450{
     
    5460
    5561  BspManager(const char* fileName, float scale = 0.4f);
    56   void load(const char* fileName, float scale);
     62
     63  // Deconstructor
     64  ~BspManager();
     65
     66
    5767
    5868  // Functions
     69  int load(const char* fileName, float scale);
    5970  const void draw();
    6071  const void tick(float time);
     
    99110  Vector inputStart;
    100111  Vector inputEnd;
    101  
     112
    102113  Vector traceMins; //!< Mins of current bbox
    103114  Vector traceMaxs; //!< Maxs of current bbox
     
    112123  ::std::deque<int> opal; //!< the others here.
    113124
    114   Vector out;  //!< For debugging only
     125  Vector out;  //!< Stores collision coordinates
    115126  Vector out1; //!< For debugging only
    116127  Vector out2; //!< For debugging only
    117                        
     128
    118129  int tgl;
    119130};
  • trunk/src/lib/graphics/importer/interactive_model.h

    r8894 r9003  
    4040    virtual int getAnimation() = 0;
    4141
     42    virtual bool isAnimationFinished() { return false; }
     43
    4244    virtual void setAnimationSpeed(float speed) {}
    4345};
  • trunk/src/lib/graphics/importer/md2/md2Model.cc

    r8894 r9003  
    8585
    8686  this->scaleFactor = scale;
     87  this->animationSpeed = 1.0f;
    8788
    8889  shadeDots = MD2Model::anormsDots[0];
     
    103104  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
    104105
    105   this->animationSpeed = 1.0f;
    106106
    107107  // triangle conversion
  • trunk/src/lib/graphics/importer/md2/md2Model.h

    r8894 r9003  
    161161  inline int MD2Model::getAnimation() { return this->animationState.type; }
    162162  virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
     163  virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
    163164  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
    164165  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
Note: See TracChangeset for help on using the changeset viewer.