Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9088 in orxonox.OLD for branches/presentation/src/lib/graphics


Ignore:
Timestamp:
Jul 4, 2006, 2:17:07 AM (18 years ago)
Author:
patrick
Message:

cr x axis checked in both direcitons

File:
1 edited

Legend:

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

    r9086 r9088  
    11461146
    11471147
    1148 /*  Vector forwardDir = Vector(0.0,0.0,1.0);
    1149   Vector upDir = Vector(0.0,1.0,0.0);*/
    1150   Vector position = entity->getAbsCoor();
    1151 
    1152   bool SolidFlag = false;
    1153 
    1154   plane* testPlane = NULL;
    1155 
    1156   bool xCollisionRight = false;
    1157   bool xCollisionLeft = false;
    1158 
    1159 
    1160   Vector            left;                       //!< left collision ray
    1161   Vector            right;                      //!< right collision ray
     1148  plane*            testPlane          = NULL;  //!< the collision test plane
     1149
     1150  Vector            forward;                    //!< left collision ray
     1151  Vector            backward;                   //!< right collision ray
    11621152  Vector            collPos;                    //!< the collision position
    11631153
    1164 
    1165 
    1166 
    1167   Vector dirX =  entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     1154  bool              xCollisionForward  = false; //!< flag true if right collision
     1155  bool              xCollisionBackward = false; //!< flag true if left collision
     1156  bool              SolidFlag          = false; //!< flag set true if solid
     1157
     1158  Vector            position;                   //!< current position of the entity
     1159  Vector            dirX;                       //!< direction x
     1160
     1161  position = entity->getAbsCoor();
     1162  dirX =  entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
    11681163
    11691164  // calculate the rays
    11701165  if( box != NULL)
    11711166  {
    1172     left  = entity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
    1173     right = entity->getAbsCoor() -  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     1167    forward  = entity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     1168    backward = entity->getAbsCoor() -  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
    11741169  }
    11751170  else
    11761171  {
    1177     left  = position + dirX * 4.0f;
    1178     right = position + Vector(0.0, 1.0, 0.0) + dirX * 4.0;
    1179   }
    1180 
    1181 
    1182   /*   X Ray Left  */
     1172    forward  = position + dirX * 4.0f;
     1173    backward = position + Vector(0.0, 1.0, 0.0) + dirX * 4.0;
     1174  }
     1175
     1176
     1177  /*   X Ray forward  */
    11831178  // init some member variables before collision check
    11841179  this->outputStartsOut = true;
     
    11861181  this->outputFraction = 1.0f;
    11871182  this->inputStart =  position;
    1188   this->inputEnd =   right;
    1189   this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &right );
     1183  this->inputEnd =   forward;
     1184  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &forward );
    11901185
    11911186  // collision occured
    11921187  if( this->outputFraction < 1.0f)
    11931188  {
    1194     collPos = position + (right - position) * this->outputFraction;
    1195     xCollisionRight = true;
     1189    collPos = position + (forward - position) * this->outputFraction;
     1190    xCollisionForward = true;
    11961191    testPlane = this->collPlane;
    11971192  }
     
    12041199    testPlane = this->collPlane;
    12051200    SolidFlag = true;
    1206     xCollisionRight = true;
     1201    xCollisionForward = true;
    12071202  }
    12081203
    12091204  // collision registration
    1210   if( xCollisionRight) {
     1205  if( xCollisionForward) {
    12111206    entity->registerCollision(COLLISION_TYPE_AXIS_X ,
     1207                              this->parent, entity,
     1208                              Vector(testPlane->x, testPlane->y, testPlane->z),
     1209                              collPos,
     1210                              SolidFlag);
     1211  }
     1212
     1213
     1214
     1215  /*   X Ray backward  */
     1216  // init some member variables before collision check
     1217  this->outputStartsOut = true;
     1218  this->outputAllSolid = false;
     1219  this->outputFraction = 1.0f;
     1220  this->inputStart =  position;
     1221  this->inputEnd =   backward;
     1222  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &backward );
     1223
     1224  // collision occured
     1225  if( this->outputFraction < 1.0f)
     1226  {
     1227    collPos = position + (backward - position) * this->outputFraction;
     1228    xCollisionBackward = true;
     1229    testPlane = this->collPlane;
     1230  }
     1231  if(this->outputAllSolid )
     1232  {
     1233    this->collPlane = new plane;
     1234    this->collPlane->x = 0.0f;
     1235    this->collPlane->y = 0.0f;
     1236    this->collPlane->z = 0.0f;
     1237    testPlane = this->collPlane;
     1238    SolidFlag = true;
     1239    xCollisionBackward = true;
     1240  }
     1241
     1242  // collision registration
     1243  if( xCollisionBackward) {
     1244    entity->registerCollision(COLLISION_TYPE_AXIS_X_NEG ,
    12121245                              this->parent, entity,
    12131246                              Vector(testPlane->x, testPlane->y, testPlane->z),
Note: See TracChangeset for help on using the changeset viewer.