Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2006, 3:22:23 PM (18 years ago)
Author:
bottac
Message:

bsp_manager now knows the normals of the planes into which an obj collided.

File:
1 edited

Legend:

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

    r7833 r8030  
    5252
    5353
    54 
    55 
    56 
     54  this->drawDebugCube(&this->out);
     55  this->out1 = this->out;
     56  this->out2 = this->out;
     57  if(this->collPlane != NULL)
     58  {
     59  this->out1.x += this->collPlane->x*5.0;
     60  this->out1.y += this->collPlane->y*5.0;
     61  this->out1.z += this->collPlane->z*5.0;
     62 
     63  this->out2.x += this->collPlane->x*10.0;
     64  this->out2.y += this->collPlane->y*10.0;
     65  this->out2.z += this->collPlane->z*10.0;
     66  }
     67  this->drawDebugCube(&this->out1);
     68  this->drawDebugCube(&this->out2);
     69 
    5770  // Draw Debug Terrain
    5871  /*
     
    98111  this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam);
    99112
    100   if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);
     113  //if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);
    101114
    102115  if ( viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0 )  //!< if (sizeof(Visdata) == 0)
     
    117130
    118131      Vector dir;
    119       dir.x = State::getCameraNode()->getAbsDirZ().x;
    120       dir.y =  State::getCameraNode()->getAbsDirZ().y;
    121       dir.z =  State::getCameraNode()->getAbsDirZ().z;
     132      dir.x = State::getCameraNode()->getAbsDirX().x;
     133      dir.y =  State::getCameraNode()->getAbsDirX().y;
     134      dir.z =  State::getCameraNode()->getAbsDirX().z;
    122135      float dist =  dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z;
    123136      //if(dist < 0) dist = -dist;
     
    125138      const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ;
    126139
    127       if(dMins < -1.0 && dMaxs < -1.0) {
    128         //continue;
     140      if(dMins < -150.0 && dMaxs < -150.0) {
     141        continue;
    129142      }
    130143      if( (this->cam - Vector(curLeaf.mins[0],curLeaf.mins[1], curLeaf.mins[2])).len() > 3000  && (this->cam - Vector(curLeaf.maxs[0],curLeaf.maxs[1], curLeaf.maxs[2])).len() > 3000) {
    131         //continue;
     144        continue;
    132145      }
    133146
     
    179192        const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist;
    180193
    181         if(dMins < -30.0 && dMaxs < -30.0) {
     194        if(dMins < -100.0 && dMaxs < -  100.0) {
    182195          continue;
    183196        }
     
    466479      if (fraction > startFraction)
    467480        startFraction = fraction;
     481      // store plane
     482      this->collPlane = &curPlane;
     483     
    468484    } else {   // line is leaving the brush
    469485      float fraction = (startDistance + EPSILON) / (startDistance - endDistance);  // *
    470486      if (fraction < endFraction)
    471487        endFraction = fraction;
     488      // store plane
     489      this->collPlane = & curPlane;
     490     
    472491    }
    473492
     
    484503      if (startFraction < 0)
    485504        startFraction = 0;
    486       this->outputFraction = startFraction;
     505      this->outputFraction = startFraction; 
    487506    }
    488507  }
     
    587606void BspManager::checkCollision(WorldEntity* worldEntity)
    588607{
    589 
     608 // return;
     609 
    590610  Vector position = worldEntity->getAbsCoor();
    591611
    592612
    593613  Vector forwardDir = worldEntity->getAbsDirX();
    594   forwardDir.x =10*forwardDir.x;
    595   forwardDir.y =10*forwardDir.y;
    596   forwardDir.z =10*forwardDir.z;
     614  forwardDir.x =2.0*forwardDir.x;
     615  forwardDir.y =2.0*forwardDir.y;
     616  forwardDir.z =2.0*forwardDir.z;
    597617 
    598618  Vector upDir = worldEntity->getAbsDirY();
     
    643663    out.y = position.y + (dest.y -position.y) * this->outputFraction;
    644664    out.z = position.z + (dest.z -position.z) * this->outputFraction;
     665   
     666    Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z);
     667    this->out = out;
     668    this->out1 = out1;
     669    this->out2 = out2;
     670    //this->drawDebugCube(&out1);
     671    //this->drawDebugCube(&out2);
     672   
     673    //this->drawDebugCube(&out3);
    645674 
    646675    }
    647676   
    648     if(collision) worldEntity->collidesWithGround(out,out1,out2);
     677   // if(collision) worldEntity->collidesWithGround(out,out1,out2);
    649678 
    650679  }
Note: See TracChangeset for help on using the changeset viewer.