Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8889 in orxonox.OLD for branches/single_player_map/src


Ignore:
Timestamp:
Jun 28, 2006, 9:51:05 PM (18 years ago)
Author:
bottac
Message:

Done?

File:
1 edited

Legend:

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

    r8888 r8889  
    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} */
     
    9999  this->root  = this->bspFile->get_root();
    100100  this->alreadyVisible = new bool [this->bspFile->numFaces];
    101 
     101 
    102102  CDEngine::getInstance()->setBSPModel(this);
    103103}
     
    912912{
    913913  leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
    914   for(int i = 0; i < curLeaf.n_leaffaces ; i++) {
    915   }
     914  for(int i = 0; i < curLeaf.n_leaffaces ; i++) {}
    916915  return 10.0f;
    917916}
    918917
    919918void BspManager::checkCollisionBox(void)
    920 {
    921 }
     919{}
    922920;
    923921
     
    968966  Vector out = dest;
    969967
    970  
     968
    971969  bool SolidFlag = false;
    972970  bool collision = false;
     
    984982
    985983
    986   if( box != NULL)
    987   {
     984  if( box != NULL) {
    988985    position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
    989986    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
     
    996993    dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
    997994
    998   }
    999   else
    1000   {
     995  } else {
    1001996    // Init positions and destinations to anything useful!
    1002997
     
    10321027
    10331028
    1034         out = dest;
     1029      out = dest;
    10351030
    10361031    } else {
     
    10491044  plane* testPlane = this->collPlane;
    10501045
    1051  
     1046
    10521047  bool xCollision = false;
    10531048  bool zCollision = false;
    1054   if(!SolidFlag)
    1055   {
    1056 
    1057   // 2nd Collision Detection
    1058   this->outputStartsOut = true;
    1059   this->outputAllSolid = false;
    1060   this->outputFraction = 1.0f;
    1061   this->inputStart =  position1;
    1062   this->inputEnd =   dest1;
    1063   this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
    1064   out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction;
    1065   xCollision = true;
    1066   //out.z = this->outputFraction;
    1067 
    1068   if(!SolidFlag)
    1069   {
    1070 
    1071     // 3rd Collision Detection
    1072   this->outputStartsOut = true;
    1073   this->outputAllSolid = false;
    1074   this->outputFraction = 1.0f;
    1075   this->inputStart =  position2;
    1076   this->inputEnd =   dest2;
    1077   this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    1078   //out.x = this->outputFraction;
    1079   out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction;
    1080   if(this->outputFraction != 1.0 )
    1081     zCollision = true;
    1082   }
    1083   }
     1049  if(!SolidFlag) {
     1050
     1051    // 2nd Collision Detection
     1052    this->outputStartsOut = true;
     1053    this->outputAllSolid = false;
     1054    this->outputFraction = 1.0f;
     1055    this->inputStart =  position1;
     1056    this->inputEnd =   dest1;
     1057    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
     1058
     1059    if(!this->outputAllSolid != 1.0f) {
     1060      out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction;
     1061      xCollision = true;
     1062    }
     1063    if(this->outputAllSolid) {
     1064      SolidFlag = true;
     1065      xCollision = true;   
     1066    }
     1067    //out.z = this->outputFraction;
     1068
     1069    if(!SolidFlag) {
     1070
     1071      // 3rd Collision Detection
     1072      this->outputStartsOut = true;
     1073      this->outputAllSolid = false;
     1074      this->outputFraction = 1.0f;
     1075      this->inputStart =  position2;
     1076      this->inputEnd =   dest2;
     1077      this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
     1078      //out.x = this->outputFraction;
     1079
     1080      if(this->outputFraction != 1.0f ) {
     1081        out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction;
     1082        zCollision = true;
     1083      }
     1084      if(this->outputAllSolid) {
     1085          SolidFlag = true;
     1086          zCollision = true;   
     1087      }
     1088    }
     1089  }//end if
    10841090  /*
    10851091  This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
     
    10901096
    10911097  // Return the normal here: Normal's stored in this->collPlane;
    1092   if( collision)
    1093   {
     1098  if( collision) {
    10941099    PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    10951100    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);
    1096   }
    1097   else
    1098   {
    1099     if(xCollision || yCollision)
    1100     {
    1101      
    1102       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, false);
    1103     }
    1104    
     1101  } else {
     1102    if(xCollision || zCollision) {
     1103
     1104      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);
     1105    }
     1106
    11051107  }
    11061108  //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
Note: See TracChangeset for help on using the changeset viewer.