Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4710 in orxonox.OLD


Ignore:
Timestamp:
Jun 26, 2005, 10:10:48 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: weeped out some very serious bugs, now the tree separation werks flawless, hf

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/cd_engine.cc

    r4704 r4710  
    130130  this->rootTree->spawnBVTree(depth, vertices, numVertices);
    131131}
     132
     133void CDEngine::debugDraw(int depth, int drawMode)
     134{
     135  if(this-> rootTree != NULL)
     136    this->rootTree->drawBV(depth, drawMode);
     137}
  • orxonox/trunk/src/lib/collision_detection/cd_engine.h

    r4688 r4710  
    5252  void debug();
    5353  void debugSpawnTree(int depth, sVec3D* vertices, int numVertices);
     54  void debugDraw(int depth, int drawMode);
    5455
    5556 private:
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4708 r4710  
    114114
    115115
    116     if(this->tmpLen1 > 0)
     116    if(this->tmpLen1 > 2)
    117117    {
    118118      OBBTreeNode* node1 = new OBBTreeNode();
     
    125125    }
    126126
    127     if( this->tmpLen2 > 0)
     127    if( this->tmpLen2 > 2)
    128128    {
    129129      OBBTreeNode* node2 = new OBBTreeNode();
     
    133133    else
    134134    {
    135       PRINTF(0)("Aboarding tree walk: less than 3 vertices left\n");
     135      PRINTF(0)("Abording tree walk: less than 3 vertices left\n");
    136136    }
    137137
     
    420420
    421421  /* get the maximal dimensions of the body in all directions */
    422    maxLength[0] = 0.0f;
    423    minLength[0] = 0.0f;
     422    maxLength[0] = p0.distancePoint(vertices[0]);
     423    minLength[0] = p0.distancePoint(vertices[0]);
    424424   for(int j = 0; j < length; ++j)
    425425   {
     
    431431   }
    432432
    433    maxLength[1] = 0.0f;
    434    minLength[1] = 0.0f;
     433   maxLength[1] = p1.distancePoint(vertices[0]);
     434   minLength[1] = p1.distancePoint(vertices[0]);
    435435   for(int j = 0; j < length; ++j)
    436436   {
     
    442442   }
    443443
    444    maxLength[2] = 0.0f;
    445    minLength[2] = 0.0f;
     444   maxLength[2] = p2.distancePoint(vertices[0]);
     445   minLength[2] = p2.distancePoint(vertices[0]);
    446446   for(int j = 0; j < length; ++j)
    447447   {
     
    460460     {
    461461       PRINTF(3)("max: %f, min: %f \n", maxLength[i], minLength[i]);
    462        centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f; // min length is negatie
    463        newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f; // min length is negative
     462       centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f;       // min length is negatie
     463       newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;      // min length is negative
    464464       *box->center +=  (box->axis[i] * centerOffset[i]);            // update the new center vector
    465465       halfLength[i] = newHalfLength[i];
     
    478478  {
    479479    //if( box->halfLength[i] == 0.0)
    480     PRINTF(3)("length[%i] = %f\n", i, box->halfLength[i]);
     480    if(fabs(box->halfLength[i]) > 5.0f)
     481    {
     482      PRINTF(0)("length[%i] = %f\n", i, box->halfLength[i]);
     483      PRINTF(0)("MaxLength = %f, MinLength = %f\n", maxLength[i], minLength[i]);
     484      PRINTF(0)("\nVertex Data:\n");
     485      for(int i = 0; i < length; i++)
     486      {
     487        PRINTF(0)("vertex %i: %f, %f, %f\n", i, box->vertices[i][0], box->vertices[i][1], box->vertices[i][2]);
     488      }
     489    }
    481490  }
    482491}
     
    525534  }
    526535
    527 //   PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
     536  PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
    528537
    529538
     
    534543  tList<sVec3D>      partition2;                           //!< the vertex partition 2
    535544
     545
    536546  PRINTF(3)("vertex index: %i, of %i\n", vertexIndex, box->numOfVertices);
    537547  this->separationPlane = new Plane(box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
     
    541551  for(int i = 0; i < box->numOfVertices; ++i)
    542552  {
    543     if( this->separationPlane->distancePoint(box->vertices[i]) > 0.0f)
    544       partition1.add(&box->vertices[i]);
     553    if( i == vertexIndex) continue;
     554    tmpDist = this->separationPlane->distancePoint(box->vertices[i]);
     555    if( tmpDist > 0.0)
     556      partition1.add(&box->vertices[i]); /* positive numbers plus zero */
    545557    else
    546       partition2.add(&box->vertices[i]);
     558      partition2.add(&box->vertices[i]); /* negatice numbers */
    547559  }
    548560  partition1.add(&box->vertices[vertexIndex]);
    549 
    550 //   PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
     561  partition2.add(&box->vertices[vertexIndex]);
     562
     563  PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
    551564
    552565
     
    827840  if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL || drawMode & DRAW_BV_BLENDED)
    828841  {
     842    if(this->nodeLeft == NULL && this->nodeRight == NULL)
     843      depth = 0;
    829844    if( !(drawMode & DRAW_SINGLE && depth != 0))
    830845    {
  • orxonox/trunk/src/subprojects/collision_detection/Makefile.am

    r4679 r4710  
    4141                   $(MAINSRCDIR)/world_entities/world_entity.cc
    4242
     43#$(MAINSRCDIR)/util/loading/load_param.cc
    4344
    4445
  • orxonox/trunk/src/subprojects/collision_detection/Makefile.in

    r4679 r4710  
    878878include $(MAINSRCDIR)/defs/include_paths.am
    879879
     880#$(MAINSRCDIR)/util/loading/load_param.cc
     881
    880882#                   $(MAINSRCDIR)/util/loading/game_loader.cc \
    881883#                   $(MAINSRCDIR)/util/track/track_manager.cc \
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4708 r4710  
    2929#include "test_entity.h"
    3030#include "environment.h"
     31
    3132
    3233#include "graphics_engine.h"
     
    4445bool drawModel;
    4546
    46 Environment* a;
    47 Environment* b;
     47WorldEntity* a;
     48WorldEntity* b;
     49//Terrain* c;
    4850
    4951void Framework::moduleInit(int argc, char** argv)
     
    5355  CDEngine::getInstance();
    5456
    55   /* Simple Test */
    56   //CDEngine::getInstance()->debug();
     57  /* Primitive Data Test */
     58//   sVec3D* data = new sVec3D[6];
     59//   float tmp[6][3] = {{0.0, 4.2, 2.4}, {3.0, 3.0, 2.0}, {5.0, 1.0, 6.0}, {6.5, 1.0, 3.0}, {7.0, 3.0, 5.0}, {8.0, 6.0, 6.0}};
     60//   for(int i = 0; i < 6; ++i)
     61//   {
     62//     data[i][0] = tmp[i][0];
     63//     data[i][1] = tmp[i][1];
     64//     data[i][2] = tmp[i][2];
     65//   }
     66//   CDEngine::getInstance()->debugSpawnTree(5, data, 6);
    5767
    5868  /* MD2 Model Test */
     
    6979  entityList = new tList<WorldEntity>();
    7080
    71   //a = new TestEntity(); a->setName("Clown1");
    72   a = new Environment(); a->setName("Clown");
    73   b = new Environment(); b->setName("Jaeger");
     81  a = new TestEntity(); a->setName("Clown1");
     82  b = new Environment(); a->setName("Clown");
     83  //b = new Environment(); b->setName("Jaeger");
     84  //c = new Terrain();
    7485
    7586  b->setRelCoor(0.0, 0.0, -10.0);
    76   b->setRelDir(Quaternion(-M_PI/2.0f, Vector(0.0, 1.0, 0.0)));
    77 
    78 //   TestEntity* c = new TestEntity(); c->setName("Colwn2");
    79 //   c->setRelCoor(0.0, 0.0, -20.0);
     87  //b->setRelDir(Quaternion(-M_PI/2.0f, Vector(0.0, 1.0, 0.0)));
    8088
    8189  entityList->add(a);
     
    8593
    8694  LightManager* lightMan = LightManager::getInstance();
    87   lightMan->setAmbientColor(.1,.1,.1);
     95    lightMan->setAmbientColor(.1,.1,.1);
    8896  lightMan->addLight();
    89   lightMan->setPosition(30, 30, 30);
     97  lightMan->setPosition(-5.0, 50.0, -40.0);
    9098  lightMan->addLight();
    91   lightMan->setPosition(-30, -30, -30);
     99  lightMan->setPosition(100, 80, 60);
     100
    92101
    93102  /* properties */
     
    223232
    224233
    225   b->shiftCoor(Vector(0.0, 0.0, iterata));
     234  //b->shiftCoor(Vector(0.0, 0.0, iterata));
    226235
    227236
     
    239248void Framework::moduleDraw() const
    240249{
     250  //CDEngine::getInstance()->debugDraw(depth, drawMode);
     251
    241252  tIterator<WorldEntity>* iterator = entityList->getIterator();
    242253  WorldEntity* entity = iterator->nextElement();
     
    371382
    372383
    373       Slider* TreeDepth = new Slider("TreeDepth", 0, 5);
     384      Slider* TreeDepth = new Slider("TreeDepth", 0, 10);
    374385      TreeDepth->connectSignal("value_changed", (void*)TreeDepth, treeDepth);
    375386      windowBox->fill(TreeDepth);
  • orxonox/trunk/src/world_entities/environment.cc

    r4682 r4710  
    3333{
    3434  this->setClassID(CL_ENVIRONMENT, "Environment");
    35   this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
     35  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj"/*"worlds/vulcania.obj"*/, OBJ, RP_CAMPAIGN);
    3636
    37   this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     37  this->obbTree = new OBBTree(10, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
    3838}
    3939
Note: See TracChangeset for help on using the changeset viewer.