Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 22, 2006, 3:14:58 PM (19 years ago)
Author:
bensch
Message:

merged the bsp-model-stuff back here

File:
1 edited

Legend:

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

    r8490 r8724  
    5050BspManager::BspManager(WorldEntity* parent)
    5151{
    52  
     52
    5353  this->parent = parent;
    5454  /*// open a BSP file
     
    840840        this->checkBrushRayN(&curBrush);
    841841      if(curBrush.n_brushsides <=0) this->outputAllSolid = true;
    842     }
     842    }
     843   
    843844    return;
    844845  }
     
    907908
    908909}
     910
     911float BspManager::checkPatchAltitude(BspTreeNode* node)
     912{
     913  leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
     914  for(int i = 0; i < curLeaf.n_leaffaces ; i++)
     915  {
     916   
     917  }
     918  return 10.0f;
     919}
     920
    909921void BspManager::checkCollisionBox(void)
    910922{
     
    937949void BspManager::checkCollision(WorldEntity* worldEntity)
    938950{
    939  
     951
    940952  this->outputStartsOut = true;
    941953  this->outputAllSolid = false;
    942954  this->outputFraction = 1.0f;
    943  
    944   Vector position = worldEntity->getAbsCoor();
     955
     956
    945957
    946958
    947959  Vector forwardDir = worldEntity->getAbsDirX();
    948   forwardDir = forwardDir * 8.0f;
     960
    949961
    950962  Vector upDir = worldEntity->getAbsDirY();
     
    958970  dest.z  += forwardDir.z;
    959971  */
    960 
    961   dest = worldEntity->getAbsCoor() - upDir*40.0;
     972  Vector position = worldEntity->getAbsCoor() + upDir*10.0f ;
     973  dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    962974  Vector out = dest;
    963975
     
    966978
    967979  bool collision = false;
    968   Vector position1 = position + Vector(0.0,0.1,0.0);
    969   Vector position2 = position + Vector(0.0,0.2,0.0);
    970   Vector dest1 = position1 + forwardDir;
     980  Vector position1 = position; // + Vector(0.0,0.6,0.0);
     981  Vector position2 = position + Vector(0.0,1.0,0.0);
     982  Vector dest1 = position + forwardDir*4.0f;
    971983  Vector dest2 = position2 + forwardDir;
    972984  dest = position - Vector(0.0, 40.0,0.0);
     
    976988
    977989  float height = 40;
    978  
     990
    979991  this->inputStart =  position;
    980992  this->inputEnd =   dest;
    981993  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
    982 
    983   PRINTF(0)(" checking collision: %s, solid = %i, fraction = %f\n", worldEntity->getClassName(), this->outputAllSolid, this->outputFraction);
    984   PRINTF(0)("checking collision!! Pos.Coords: %f , %f , %f\n", position.x , position.y, position.z);
    985   PRINTF(0)("checking collision!! Dest.Coords: %f , %f , %f\n", dest.x , dest.y, dest.z); 
     994 
     995
     996
     997//   PRINTF(0)(" checking collision: %s, solid = %i, fraction = %f\n", worldEntity->getClassName(), this->outputAllSolid, this->outputFraction);
     998//   PRINTF(0)("checking collision!! Pos.Coords: %f , %f , %f\n", position.x , position.y, position.z);
     999//   PRINTF(0)("checking collision!! Dest.Coords: %f , %f , %f\n", dest.x , dest.y, dest.z);
     1000
    9861001//   position1.debug();
     1002
     1003  if(!this->outputStartsOut )
     1004  {
     1005    this->collPlane = new plane;
     1006    this->collPlane->x = 0.0f;
     1007    this->collPlane->y = 0.0f;
     1008    this->collPlane->z = 0.0f;
     1009    collision = true;
     1010  }
     1011  else
     1012  {
     1013
     1014
     1015
    9871016
    9881017  if( this->outputFraction == 1.0f)
    9891018  {
    990     if(this->outputAllSolid)
     1019    if(this->outputAllSolid )
    9911020    {
    9921021      this->collPlane = new plane;
    993       this->collPlane->x = 1.0f;
     1022      this->collPlane->x = 0.0f;
    9941023      this->collPlane->y = 0.0f;
    9951024      this->collPlane->z = 0.0f;
     
    10131042  }
    10141043
     1044
     1045  }
     1046 
     1047  plane* testPlane = this->collPlane;
     1048 
     1049  this->outputStartsOut = true;
     1050  this->outputAllSolid = false;
     1051  this->outputFraction = 1.0f;
     1052  this->inputStart =  position;
     1053  this->inputEnd =   dest1;
     1054  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest1 );
     1055  out.x = this->outputFraction;
     1056  out.z = this->outputFraction;
     1057 
     1058  /*
     1059  out.x = position1.x + (dest.x -position1.x) * this->outputFraction;
     1060 
     1061  out.z = position1.z + (dest.z -position1.z) * this->outputFraction;
     1062  */
     1063 
     1064 
    10151065  // Return the normal here: Normal's stored in this->collPlane;
    10161066  if( collision) {
    1017     PRINTF(0)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    1018     worldEntity->registerCollision(this->parent, worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out);
    1019   }
     1067    PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
     1068    worldEntity->registerCollision(this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);
     1069  }
     1070  else  worldEntity->registerCollision(this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);
    10201071
    10211072}
Note: See TracChangeset for help on using the changeset viewer.