Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8922 in orxonox.OLD


Ignore:
Timestamp:
Jun 29, 2006, 9:48:25 PM (18 years ago)
Author:
patrick
Message:

the ground walking algorithm is almost working again

Location:
branches/single_player_map/src/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r8915 r8922  
    6363  // normal.normalize();
    6464
    65   // put it back
    66     // PRINTF(0)("putting it back to lastPos: \n");
    67      //this->lastPositions[0].debug();
    68     //  PRINTF(0)("current pos:\n");
    69      collision->getEntityB()->getAbsCoor().debug();
    70      
    71    
    7265
    7366  float height;
     
    8073    return;
    8174  }
    82  
    83  
     75
     76
    8477  // collision position maths
    8578  Vector collPos =  collision->getEntityB()->getAbsCoor()  + box->center - ce->getCollisionPosition();
     
    9184  //PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    9285  // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    93   // 
     86  //
    9487
    9588  switch( ce->getType())
    9689  {
    97    
     90
    9891    case COLLISION_TYPE_AXIS_X:
    99      // PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    100      // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    101      // PRINTF(0)("COLLISION_TYPE_AXIS_X \n");
    102       break;
    103    case COLLISION_TYPE_AXIS_Y:
     92
     93      break;
     94
     95    case COLLISION_TYPE_AXIS_Y:
    10496
    10597      height = collPos.y - box->halfLength[1];
    106      // PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    107      //  PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    108      //  PRINTF(0)("COLLISION_TYPE_AXIS_Y \n");
    109 //       // object is beneath the plane (ground)
    110 //       if( height <= 0.0f )
    111 //       {
    112 //         entity->shiftCoor(Vector(0, -height, 0));
    113 //       }
    114 //       // object is already in the wall
    115 //       else if( ce->isInWall())
    116 //       {
    117 //         entity->setAbsCoor(entity->getLastAbsCoor());
    118 //       }
    119 //       break;
    120      break;
    121 
    122    
     98
     99      PRINTF(0)("height: %f\n", height);
     100      PRINTF(0)("in wall %i\n", ce->isInWall());
     101
     102      // object is beneath the plane (ground)
     103      if( height <= 0.0f )
     104      {
     105        entity->shiftCoor(Vector(0, -height, 0));
     106      }
     107      // object is already in the wall
     108      else if( ce->isInWall())
     109      {
     110        entity->setAbsCoor(entity->getLastAbsCoor());
     111      }
     112      break;
     113      break;
     114
     115
    123116    case COLLISION_TYPE_AXIS_Z:
    124     //  PRINTF(0)("height: %f          , model height: %f\n", height, box->halfLength[1]);
    125     //  PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z);
    126     //  PRINTF(0)("COLLISION_TYPE_AXIS_Z \n");
    127      break;
    128 
    129     }
     117
     118      break;
     119
     120  }
    130121
    131122
     
    143134
    144135
    145   if( box != NULL) {
    146 
    147 
    148     if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
     136  if( box != NULL)
     137  {
     138
     139
     140    if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
     141    {
    149142      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    150143      return;
    151144    }
    152     if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
     145    if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f)
     146    {
    153147      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    154148      return;
    155149    }
    156150
    157     if(ce->getGroundNormal().len() <= 0.1f) {
     151    if(ce->getGroundNormal().len() <= 0.1f)
     152    {
    158153      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
    159154      return;
     
    161156
    162157
    163     if(ce->getGroundNormal().len() >= 1.4f) {
     158    if(ce->getGroundNormal().len() >= 1.4f)
     159    {
    164160      downspeed++;
    165161      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
     
    181177
    182178    }
    183     else {
     179    else
     180    {
    184181      if(height.y <  box->halfLength[1] + 0.0f   /* && height.y  >  - 55.0f*/) // below ground
    185182      {
     
    212209void CRPhysicsGroundWalk::update(WorldEntity* owner)
    213210{
    214 
    215211}
    216212
  • branches/single_player_map/src/lib/graphics/importer/bsp_manager.cc

    r8912 r8922  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44   Copyright (C) 2006 orx
    5  
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10  
     10
    1111   ### File Specific:
    1212   main-programmer: bottac@ee.ethz.ch
    13  
     13
    1414   Inspired by:
    1515   Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
    1616   Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
    17  
     17
    1818   Collision detection adapted from:
    1919   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
     
    6969BspManager::BspManager(const TiXmlElement* root)
    7070{
    71  
    72  
     71
     72
    7373  if( root != NULL)
    7474    this->loadParams(root);
    75  
     75
    7676  CDEngine::getInstance()->setBSPModel(this);
    7777} */
     
    111111  this->root  = this->bspFile->get_root();
    112112  this->alreadyVisible = new bool [this->bspFile->numFaces];
    113  
     113
    114114  CDEngine::getInstance()->setBSPModel(this);
    115115}
     
    986986
    987987  if( box != NULL) {
    988     position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
     988    position = worldEntity->getAbsCoor() +  box->center + box->axis[1] * box->halfLength[1];
    989989    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
    990990
     
    998998  } else {
    999999    // Init positions and destinations to anything useful!
    1000    
     1000
    10011001  }
    10021002
     
    10491049  bool xCollision = false;
    10501050  bool zCollision = false;
    1051  
     1051
    10521052
    10531053    // 2nd Collision Detection
     
    10701070    //out.z = this->outputFraction;
    10711071
    1072    
     1072
    10731073
    10741074      // 3rd Collision Detection
     
    10781078      this->inputStart =  position2;
    10791079      this->inputEnd =   dest2;
    1080      
     1080
    10811081      this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    10821082      //out.x = this->outputFraction;
     
    10921092        zCollision = true;
    10931093      }
    1094    
     1094
    10951095  //end if
    10961096  /*
     
    11021102
    11031103  // Return the normal here: Normal's stored in this->collPlane;
    1104 /*  if( collision) {
    1105     PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
     1104  if( collision) {
    11061105    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
    1107 } */
     1106}
    11081107  if(xCollision) {
    11091108    worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
Note: See TracChangeset for help on using the changeset viewer.