Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8220 in orxonox.OLD for branches/bsp_model


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

bsp: collision detection doesn't work at all

Location:
branches/bsp_model/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/collision_detection/cd_engine.cc

    r8218 r8220  
    109109  for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++) {
    110110      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
     111      {
     112//         PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassName());
    111113        (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator);
     114      }
    112115  }
    113116}
  • branches/bsp_model/src/lib/collision_reaction/collision_handle.cc

    r8213 r8220  
    173173
    174174 c->registerCollisionEvent(collisionEvent);
     175 PRINTF(0)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassName(), collisionEvent->getEntityB()->getClassName());
    175176}
    176177
  • branches/bsp_model/src/lib/event/event_handler.cc

    r8148 r8220  
    353353  else
    354354  {
    355 //    SDL_WM_GrabInput(SDL_GRAB_ON);
     355    SDL_WM_GrabInput(SDL_GRAB_ON);
    356356    SDL_ShowCursor(SDL_DISABLE);
    357357  }
  • 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
  • branches/bsp_model/src/story_entities/game_world.cc

    r8215 r8220  
    428428  // ground collision detection: BSP Model
    429429  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_00));
     430  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_01));
    430431}
    431432
  • branches/bsp_model/src/world_entities/bsp_entity.cc

    r8219 r8220  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Claudio Botta
    1313   co-programmer: ...
    1414*/
     
    2727{
    2828  this->init();
     29
    2930  if (root != NULL)
    3031    this->loadParams(root);
     
    3738BspEntity::~BspEntity ()
    3839{
    39 
     40  if( this->bspManager)
     41    delete this->bspManager;
    4042}
    41 
    42 void BspEntity::setName(const std::string& name)
    43 {
    44   PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
    45 
    46   this->bspManager->load(name.c_str(), 0.1f);
    47 }
    48 
    4943
    5044
     
    5549void BspEntity::init()
    5650{
    57   this->bspManager = new BspManager(this);
    5851  this->setClassID(CL_BSP_ENTITY, "BspEntity");
    5952
     53  this->bspManager = new BspManager(this);
    6054  this->toList(OM_ENVIRON);
    6155
     
    6357   * @todo: Write CL_BSP_ENTITY INTO THE src/defs/class_id.h (your own definition)
    6458   */
     59}
    6560
     61
     62void BspEntity::setName(const std::string& name)
     63{
     64  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
     65
     66  this->bspManager->load(name.c_str(), 0.1f);
    6667}
    6768
Note: See TracChangeset for help on using the changeset viewer.