Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8030 in orxonox.OLD for branches


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

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

Location:
branches/bsp_model/src
Files:
5 edited

Legend:

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

    r7805 r8030  
    4343int BspFile::read(const char* name)
    4444{
     45  this->scale = 0.4;
    4546  int offset;
    4647  int size;
     
    598599  sc =  ((unsigned char *)(&lightMapTexture))[i];
    599600  sc *= 1/255.0;
    600   scale = 1.0;
     601  scale = 1.4;
    601602  if(sc > 1.0f && (temp = (1.0f/sc)) < scale) scale=temp;
    602603  scale*=255.0;
    603604  sc*=scale;
    604   if(sc <= 180)
     605  if(false)
    605606    ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 75;
    606607  else
     
    983984void BspFile::swapAllBspCoordinates()
    984985{
     986 
    985987  for(int i = 0; i < this->numVertex ; ++i)
    986988  {
     
    10011003  {
    10021004    float sto = this->planes[i].x;
    1003     this->planes[i].x = this->planes[i].y;
    1004     this->planes[i].y = this->planes[i].z;
     1005    this->planes[i].x =  this->planes[i].y;
     1006    this->planes[i].y =  this->planes[i].z;
    10051007    this->planes[i].z = sto;
     1008    this->planes[i].d = scale * this->planes[i].d ;
    10061009  }
    10071010
     
    10211024{
    10221025  int sto  =  array[0];
    1023   array[0] =  array[1];
    1024   array[1] =  array[2];
    1025   array[2] =  sto;
     1026  array[0] =  array[1] / (int) ( 1/ scale);
     1027  array[1] = array[2] / (int) (1/scale);
     1028  array[2] =  sto / (int) (1/scale);
    10261029 
    10271030}
     
    10301033{
    10311034  float sto  =  array[0];
    1032   array[0] =  array[1];
    1033   array[1] =  array[2];
    1034   array[2] =  sto;
    1035 }
    1036 
     1035  array[0] =  scale * array[1];
     1036  array[1] =  scale * array[2];
     1037  array[2] =  scale * sto;
     1038}
     1039
  • branches/bsp_model/src/lib/graphics/importer/bsp_file.h

    r7801 r8030  
    2121
    2222
    23 typedef struct
     23 struct plane
    2424{
    2525  float x;     //!< 1st component of the plane's normal
     
    2727  float z;     //!< 3rd component of the plane's normal
    2828  float d;     //!< distance of the plane to the origin
    29 }
    30 plane;
     29};
    3130
    3231typedef struct
     
    193192  int numBrushSides;
    194193  int numLightMaps;
    195 
    196 
     194 
     195  float  scale;
    197196
    198197  BspTreeNode* build_tree_rec( int i );
  • 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  }
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.h

    r7833 r8030  
    2525struct face;
    2626struct brush;
     27struct plane;
     28
    2729class WorldEntity;
    2830
     
    5759  Vector ship;
    5860  Vector  viewDir;
     61  plane* collPlane;
    5962  int lastTex;
    6063 
     
    6972  ::std::deque<int> opal; //!< the others here.
    7073
     74  Vector out;
     75  Vector out1;
     76  Vector out2;
    7177};
    7278
  • branches/bsp_model/src/world_entities/world_entity.cc

    r7833 r8030  
    288288{
    289289 
    290   PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() );
     290  // PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() );
     291 
    291292  Vector v = this->getAbsDirX();
    292293  v.x *= 10;
    293294  v.y *= 10;
    294295  v.z *= 10;
     296  Vector u = this->getAbsDirY();
     297 
     298  if(feet.x == (u.x+this->getAbsCoor().x) &&  feet.y == u.y +this->getAbsCoor().y && feet.z == this->getAbsCoor().z)
     299  {
     300   
    295301  this->setAbsCoor(ray_2 - v);
     302  }
     303  else
     304  {
     305    if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z)
     306    {
     307      this->setAbsCoor(feet -u ); 
     308    }
     309     
     310    this->setAbsCoor(ray_2 - v); 
     311   
     312  }
    296313}
    297314
Note: See TracChangeset for help on using the changeset viewer.