Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2006, 11:44:50 PM (18 years ago)
Author:
patrick
Message:

bsp: collision detection doesn't work at all

File:
1 edited

Legend:

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

    r8219 r8220  
    8383  this->root  = this->bspFile->get_root();
    8484  this->alreadyVisible = new bool [this->bspFile->numFaces];
     85
     86  this->outputFraction = 1.0f;
    8587}
    8688/*
     
    853855
    854856  Vector position = worldEntity->getAbsCoor();
    855 
    856 
    857   Vector forwardDir = worldEntity->getAbsDirX();
    858   forwardDir.x =8.0*forwardDir.x;
    859   forwardDir.y =8.0*forwardDir.y;
    860   forwardDir.z =8.0*forwardDir.z;
    861 
    862   Vector upDir = worldEntity->getAbsDirY();
    863   Vector dest = position;
    864   dest.x  += forwardDir.x;
    865   dest.y  += forwardDir.y;
    866   dest.z  += forwardDir.z;
    867   Vector out = dest;
     857  Vector downDir = worldEntity->getAbsDirY();
     858  Vector dest = position + downDir * -80.0f;
     859
     860//   Vector forwardDir = worldEntity->getAbsDirX();
     861//   forwardDir.x =8.0*forwardDir.x;
     862//   forwardDir.y =8.0*forwardDir.y;
     863//   forwardDir.z =8.0*forwardDir.z;
     864//
     865//   Vector upDir = worldEntity->getAbsDirY();
     866//   Vector dest = position;
     867//   dest.x  += forwardDir.x;
     868//   dest.y  += forwardDir.y;
     869//   dest.z  += forwardDir.z;
     870//   Vector out = dest;
    868871
    869872   bool collision = false;
    870873
    871    Vector position1 = position + Vector(0.0,0.1,0.0);
    872    Vector position2 = position + Vector(0.0,0.2,0.0);
    873    Vector dest1 = position1 + forwardDir;
    874    Vector dest2 = position2 + forwardDir;
    875    dest = position - Vector(0.0, 20.0,0.0);
    876    Vector out1;
    877    Vector out2;
    878 
    879    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
    880    if(this->outputFraction == 1.0f)  out1 = dest;
     874
     875//    Vector position1 = position + Vector(0.0,0.1,0.0);
     876//    Vector position2 = position + Vector(0.0,0.2,0.0);
     877//    Vector dest1 = position1 + forwardDir;
     878//    Vector dest2 = position2 + forwardDir;
     879//    dest = position - Vector(0.0, 20.0,0.0);
     880//    Vector out1;
     881//    Vector out2;
     882
     883//    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
     884//    if(this->outputFraction == 1.0f)  out1 = dest;
     885//    else {
     886//      collision = true;
     887//      out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction;
     888//      out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction;
     889//      out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction;
     890//
     891//    }
     892//    this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
     893//    if(this->outputFraction == 1.0f) out2= dest;
     894//    else {
     895//      collision = true;
     896//      out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction;
     897//      out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction;
     898//      out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction;
     899//
     900//    }
     901
     902   this->checkCollisionRayN(this->root,0.0f, 1.0f, &position, &dest );
     903
     904   if( this->outputFraction == 1.0f)
     905     out = dest;
    881906   else {
     907     PRINTF(0)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    882908     collision = true;
    883      out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction;
    884      out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction;
    885      out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction;
    886 
    887    }
    888 
    889    this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    890    if(this->outputFraction == 1.0f) out2= dest;
    891    else {
    892      collision = true;
    893      out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction;
    894      out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction;
    895      out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction;
    896 
    897    }
    898 
    899    this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
    900    if(this->outputFraction == 1.0f) out = dest;
    901    else {
    902      collision = true;
    903      out.x = position.x + (dest.x -position.x) * this->outputFraction;
    904      out.y = position.y + (dest.y -position.y) * this->outputFraction;
    905      out.z = position.z + (dest.z -position.z) * this->outputFraction;
     909//      out.x = position.x + (dest.x -position.x) * this->outputFraction;
     910//      out.y = position.y + (dest.y -position.y) * this->outputFraction;
     911//      out.z = position.z + (dest.z -position.z) * this->outputFraction;
     912
     913     out = position + (dest - position) * this->outputFraction;
    906914
    907915     Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z);
    908      this->out = out;
    909      this->out1 = out1;
    910      this->out2 = out2;
     916
     917
    911918      //this->drawDebugCube(&out1);
    912919      //this->drawDebugCube(&out2);
     
    917924
    918925    // Return the normal here: Normal's stored in this->collPlane;
    919    if(collision)
     926   if( collision) {
    920927     worldEntity->registerCollision(worldEntity, this->parent, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out);
     928   }
    921929}
    922930
Note: See TracChangeset for help on using the changeset viewer.