Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4635 in orxonox.OLD for orxonox/trunk/src/lib/collision_detection


Ignore:
Timestamp:
Jun 15, 2005, 7:05:39 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: implemented an elegant draw function to display the tree in different ways

Location:
orxonox/trunk/src/lib/collision_detection
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/bounding_volume.h

    r4616 r4635  
    2727    virtual void mergeWith(const BoundingVolume &bv) = NULL;
    2828
    29     virtual void drawBV(int currentDepth, const int depth) const = NULL;
    30     virtual void drawBVPolygon(int currentDepth, const int depth) const = NULL;
    31     virtual void drawBVBlended(int currentDepth, const int depth) const = NULL;
     29    virtual void drawBV(int currentDepth, int drawMode) const = NULL;
     30
    3231
    3332
  • orxonox/trunk/src/lib/collision_detection/bv_tree.h

    r4622 r4635  
    1515class BoundingVolume;
    1616
     17typedef enum DrawMode
     18{
     19  DRAW_ALL               = 1<<0,
     20  DRAW_SINGLE            = 1<<1,
     21
     22  DRAW_SEPARATING_PLANE  = 1<<2,
     23  DRAW_BV_AXIS           = 1<<3,
     24  DRAW_BV_BLENDED        = 1<<4,
     25  DRAW_BV_POLYGON        = 1<<5,
     26  DRAW_MODEL             = 1<<6
     27};
     28
    1729
    1830//! A class that represents a bounding volume tree
     
    2638  virtual void flushTree() = NULL;
    2739
    28 
    29   virtual void drawBV(int depth) const = NULL;
    30   virtual void drawBVPolygon(int depth) const = NULL;
    31   virtual void drawBVBlended(int depth) const = NULL;
     40  virtual void drawBV(int depth, int drawMode) const = NULL;
    3241
    3342 protected:
  • orxonox/trunk/src/lib/collision_detection/bv_tree_node.h

    r4618 r4635  
    3131  virtual void collideWith(const BVTree &tree) = NULL;
    3232
    33   virtual void drawBV(int depth) const = NULL;
    34   virtual void drawBVPolygon(int depth) const = NULL;
    35   virtual void drawBVBlended(int depth) const = NULL;
     33  virtual void drawBV(int depth, int drawMode) const = NULL;
    3634
    3735
  • orxonox/trunk/src/lib/collision_detection/cd_engine.cc

    r4622 r4635  
    5353
    5454
    55 void CDEngine::drawBV(int depth) const
     55void CDEngine::drawBV(int depth, int drawMode) const
    5656{
    5757  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
    58   this->rootTree->drawBV(depth);
     58  this->rootTree->drawBV(depth, drawMode);
    5959}
    6060
    6161
    62 void CDEngine::drawBVPolygon(int depth) const
    63 {}
    64 
    65 
    66 void CDEngine::drawBVBlended(int depth) const
    67 {}
    6862
    6963
  • orxonox/trunk/src/lib/collision_detection/cd_engine.h

    r4622 r4635  
    4444  void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
    4545
    46   void drawBV(int depth) const;
    47   void drawBVPolygon(int depth) const;
    48   void drawBVBlended(int depth) const;
     46  void drawBV(int depth, int drawMode) const;
    4947
    5048  void checkCollisions();
  • orxonox/trunk/src/lib/collision_detection/obb.cc

    r4576 r4635  
    5151
    5252
    53 void OBB::drawBV(int currentDepth, const int depth) const
     53void OBB::drawBV(int currentDepth, int drawMode) const
    5454{}
    5555
    5656
    57 void OBB::drawBVPolygon(int currentDepth, const int depth) const
    58 {}
    59 
    60 
    61 void OBB::drawBVBlended(int currentDepth, const int depth) const
    62 {}
  • orxonox/trunk/src/lib/collision_detection/obb.h

    r4588 r4635  
    2626  virtual void mergeWith(const BoundingVolume &bv);
    2727
    28   virtual void drawBV(int currentDepth, const int depth) const;
    29   virtual void drawBVPolygon(int currentDepth, const int depth) const;
    30   virtual void drawBVBlended(int currentDepth, const int depth) const;
     28  virtual void drawBV(int currentDepth, int drawMode) const;
    3129
    3230
  • orxonox/trunk/src/lib/collision_detection/obb_tree.cc

    r4626 r4635  
    7777
    7878
    79 void OBBTree::drawBV(int depth) const
     79void OBBTree::drawBV(int depth, int drawMode) const
    8080{
    8181  if( likely(this->rootNode != NULL))
    8282  {
    83     this->rootNode->drawBV(depth);
    84     this->rootNode->drawBVPolygon(depth);
     83    this->rootNode->drawBV(depth, drawMode);
    8584  }
    8685}
    8786
    88 
    89 void OBBTree::drawBVPolygon(int depth) const
    90 {
    91   if( likely(this->rootNode != NULL))
    92     this->rootNode->drawBVPolygon(depth);
    93 }
    94 
    95 
    96 void OBBTree::drawBVBlended(int depth) const
    97 {
    98   if( likely(this->rootNode != NULL))
    99     this->rootNode->drawBVBlended(depth);
    100 }
    10187
    10288
  • orxonox/trunk/src/lib/collision_detection/obb_tree.h

    r4622 r4635  
    2727    void collideWith(const OBBTree &tree);
    2828
    29     virtual void drawBV(int depth) const;
    30     virtual void drawBVPolygon(int depth) const;
    31     virtual void drawBVBlended(int depth) const;
     29    virtual void drawBV(int depth, int drawMode) const;
    3230
    3331    Material* getMaterial(unsigned int depth) { return material[depth%3]; }
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4633 r4635  
    439439
    440440
    441 void OBBTreeNode::drawBV(int depth) const
    442 {
    443   glBegin(GL_TRIANGLES);
    444   glColor3f(1.0, 1.0, 1.0);
    445   for(int i = 0; i < this->bvElement->numOfVertices; ++i)
     441void OBBTreeNode::drawBV(int depth, int drawMode) const
     442{
     443  //OBBTree::material->select();
     444
     445  this->obbTree->getMaterial(depth)->select();
     446
     447  /* draw the model itself, there is some problem concerning this: the vertices are drawn multiple times */
     448  if( drawMode & DRAW_MODEL || drawMode & DRAW_ALL)
     449  {
     450    glBegin(GL_TRIANGLES);
     451    glColor3f(1.0, 1.0, 1.0);
     452    for(int i = 0; i < this->bvElement->numOfVertices; ++i)
    446453    {
    447454      glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
    448455      //printf("v(%f, %f, %f)\n", this->vertices[i][0], this->vertices[i][1], this->vertices[i][2]);
    449456    }
    450   glEnd();
    451   //this->drawBVPolygon(depth);
    452 }
    453 
    454 
    455 void OBBTreeNode::drawBVPolygon(int depth) const
    456 {
    457   //OBBTree::material->select();
    458 
    459   this->obbTree->getMaterial(depth)->select();
     457    glEnd();
     458  }
     459
    460460
    461461  /* draw world axes */
     
    473473
    474474
    475 
    476   /* draw the obb axes */
    477 //   glBegin(GL_LINES);
    478 //   glColor3f(0.0, 0.4, 0.3);
    479 //   glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
    480 //   glVertex3f(this->bvElement->center->x + this->bvElement->axis[0]->x * this->bvElement->halfLength[0],
    481 //              this->bvElement->center->y + this->bvElement->axis[0]->y * this->bvElement->halfLength[0],
    482 //              this->bvElement->center->z + this->bvElement->axis[0]->z * this->bvElement->halfLength[0]);
    483 //
    484 //   glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
    485 //   glVertex3f(this->bvElement->center->x + this->bvElement->axis[1]->x * this->bvElement->halfLength[1],
    486 //              this->bvElement->center->y + this->bvElement->axis[1]->y * this->bvElement->halfLength[1],
    487 //              this->bvElement->center->z + this->bvElement->axis[1]->z * this->bvElement->halfLength[1]);
    488 //
    489 //   glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
    490 //   glVertex3f(this->bvElement->center->x + this->bvElement->axis[2]->x * this->bvElement->halfLength[2],
    491 //              this->bvElement->center->y + this->bvElement->axis[2]->y * this->bvElement->halfLength[2],
    492 //              this->bvElement->center->z + this->bvElement->axis[2]->z * this->bvElement->halfLength[2]);
    493 //   glEnd();
    494 
    495 
    496   Vector cen = *this->bvElement->center;
    497   Vector** axis = this->bvElement->axis;
    498   float* len = this->bvElement->halfLength;
    499 
    500   /* draw bounding box */
    501   glBegin(GL_LINE_LOOP);
    502   glColor3f(0.3, 0.4, 0.7);
    503   glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
    504              cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
    505              cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
    506   glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
    507              cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
    508              cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
    509   glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
    510              cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
    511              cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
    512   glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
    513              cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
    514              cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
    515   glEnd();
    516 
    517   glBegin(GL_LINE_LOOP);
    518   glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
    519              cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
    520              cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
    521   glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
    522              cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
    523              cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
    524   glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
    525              cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
    526              cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
    527   glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
    528              cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
    529              cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
    530   glEnd();
    531 
    532   glBegin(GL_LINE_LOOP);
    533   glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
    534              cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
    535              cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
    536   glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
    537              cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
    538              cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
    539   glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
    540              cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
    541              cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
    542   glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
    543              cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
    544              cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
    545   glEnd();
    546 
    547   glBegin(GL_LINE_LOOP);
    548   glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
    549              cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
    550              cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
    551   glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
    552              cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
    553              cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
    554   glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
    555              cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
    556              cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
    557   glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
    558              cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
    559              cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
    560   glEnd();
    561 
    562 
    563   if( true)//depth != 0)
    564   {
    565     /* now draw the separation plane */
    566     Vector a1 = *this->bvElement->axis[(this->longestAxisIndex + 1)%3];
    567     Vector a2 = *this->bvElement->axis[(this->longestAxisIndex + 2)%3];
    568     Vector c = *this->bvElement->center;
    569     float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3];
    570     float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3];
    571     glBegin(GL_QUADS);
    572     glVertex3f(c.x + a1.x * l1 + a2.x * l2, c.y + a1.y * l1+ a2.y * l2, c.z + a1.z * l1 + a2.z * l2);
    573     glVertex3f(c.x - a1.x * l1 + a2.x * l2, c.y - a1.y * l1+ a2.y * l2, c.z - a1.z * l1 + a2.z * l2);
    574     glVertex3f(c.x - a1.x * l1 - a2.x * l2, c.y - a1.y * l1- a2.y * l2, c.z - a1.z * l1 - a2.z * l2);
    575     glVertex3f(c.x + a1.x * l1 - a2.x * l2, c.y + a1.y * l1- a2.y * l2, c.z + a1.z * l1 - a2.z * l2);
    576     glEnd();
     475  if( drawMode & DRAW_BV_AXIS || drawMode & DRAW_ALL)
     476  {
     477    if( drawMode & DRAW_SINGLE && depth == 0)
     478    {
     479      /* draw the obb axes */
     480      glBegin(GL_LINES);
     481      glColor3f(0.0, 0.4, 0.3);
     482      glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
     483      glVertex3f(this->bvElement->center->x + this->bvElement->axis[0]->x * this->bvElement->halfLength[0],
     484                 this->bvElement->center->y + this->bvElement->axis[0]->y * this->bvElement->halfLength[0],
     485                 this->bvElement->center->z + this->bvElement->axis[0]->z * this->bvElement->halfLength[0]);
     486
     487      glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
     488      glVertex3f(this->bvElement->center->x + this->bvElement->axis[1]->x * this->bvElement->halfLength[1],
     489                 this->bvElement->center->y + this->bvElement->axis[1]->y * this->bvElement->halfLength[1],
     490                 this->bvElement->center->z + this->bvElement->axis[1]->z * this->bvElement->halfLength[1]);
     491
     492      glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
     493      glVertex3f(this->bvElement->center->x + this->bvElement->axis[2]->x * this->bvElement->halfLength[2],
     494                 this->bvElement->center->y + this->bvElement->axis[2]->y * this->bvElement->halfLength[2],
     495                 this->bvElement->center->z + this->bvElement->axis[2]->z * this->bvElement->halfLength[2]);
     496      glEnd();
     497    }
     498  }
     499
     500
     501  if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL)
     502  {
     503    if( drawMode & DRAW_SINGLE && depth == 0)
     504    {
     505      Vector cen = *this->bvElement->center;
     506      Vector** axis = this->bvElement->axis;
     507      float* len = this->bvElement->halfLength;
     508
     509      /* draw bounding box */
     510      glBegin(GL_LINE_LOOP);
     511      glColor3f(0.3, 0.4, 0.7);
     512      glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
     513                 cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
     514                 cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
     515      glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
     516                 cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
     517                 cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
     518      glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
     519                 cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
     520                 cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
     521      glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
     522                 cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
     523                 cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
     524      glEnd();
     525
     526      glBegin(GL_LINE_LOOP);
     527      glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
     528                 cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
     529                 cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
     530      glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
     531                 cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
     532                 cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
     533      glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
     534                 cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
     535                 cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
     536      glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
     537                 cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
     538                 cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
     539      glEnd();
     540
     541      glBegin(GL_LINE_LOOP);
     542      glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
     543                 cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
     544                 cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
     545      glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
     546                 cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
     547                 cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
     548      glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
     549                 cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
     550                 cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
     551      glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
     552                 cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
     553                 cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
     554      glEnd();
     555
     556      glBegin(GL_LINE_LOOP);
     557      glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
     558                 cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
     559                 cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
     560      glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
     561                 cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
     562                 cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
     563      glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
     564                 cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
     565                 cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
     566      glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
     567                 cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
     568                 cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
     569      glEnd();
     570    }
     571  }
     572
     573  if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL)
     574  {
     575    if( drawMode & DRAW_SINGLE && depth == 0)
     576    {
     577      /* now draw the separation plane */
     578      Vector a1 = *this->bvElement->axis[(this->longestAxisIndex + 1)%3];
     579      Vector a2 = *this->bvElement->axis[(this->longestAxisIndex + 2)%3];
     580      Vector c = *this->bvElement->center;
     581      float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3];
     582      float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3];
     583      glBegin(GL_QUADS);
     584      glVertex3f(c.x + a1.x * l1 + a2.x * l2, c.y + a1.y * l1+ a2.y * l2, c.z + a1.z * l1 + a2.z * l2);
     585      glVertex3f(c.x - a1.x * l1 + a2.x * l2, c.y - a1.y * l1+ a2.y * l2, c.z - a1.z * l1 + a2.z * l2);
     586      glVertex3f(c.x - a1.x * l1 - a2.x * l2, c.y - a1.y * l1- a2.y * l2, c.z - a1.z * l1 - a2.z * l2);
     587      glVertex3f(c.x + a1.x * l1 - a2.x * l2, c.y + a1.y * l1- a2.y * l2, c.z + a1.z * l1 - a2.z * l2);
     588      glEnd();
     589    }
    577590  }
    578591
    579592  if( this->nodeLeft != NULL && depth != 0 )
    580     this->nodeLeft->drawBVPolygon(depth - 1);
     593    this->nodeLeft->drawBV(depth - 1, drawMode);
    581594  if( this->nodeRight != NULL && depth != 0)
    582     this->nodeRight->drawBVPolygon(depth - 1);
    583 
    584 }
    585 
    586 
    587 void OBBTreeNode::drawBVBlended(int depth) const
    588 {}
     595    this->nodeRight->drawBV(depth - 1, drawMode);
     596
     597}
     598
    589599
    590600
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.h

    r4632 r4635  
    3535    virtual void collideWith(const BVTree &tree);
    3636
    37     virtual void drawBV(int depth) const;
    38     virtual void drawBVPolygon(int depth) const;
    39     virtual void drawBVBlended(int depth) const;
     37    virtual void drawBV(int depth, int drawMode) const;
    4038
    4139    void debug();
Note: See TracChangeset for help on using the changeset viewer.