Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/trunk: collision detection now displays very beatuifully

File:
1 edited

Legend:

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

    r4635 r4636  
    475475  if( drawMode & DRAW_BV_AXIS || drawMode & DRAW_ALL)
    476476  {
    477     if( drawMode & DRAW_SINGLE && depth == 0)
     477    if( !(drawMode & DRAW_SINGLE && depth != 0))
    478478    {
    479479      /* draw the obb axes */
     
    501501  if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL)
    502502  {
    503     if( drawMode & DRAW_SINGLE && depth == 0)
     503    if( !(drawMode & DRAW_SINGLE && depth != 0))
    504504    {
    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();
     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();
    570570    }
     571
    571572  }
    572573
    573574  if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL)
    574575  {
    575     if( drawMode & DRAW_SINGLE && depth == 0)
     576    if( !(drawMode & DRAW_SINGLE && depth != 0))
    576577    {
    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();
     578    /* now draw the separation plane */
     579    Vector a1 = *this->bvElement->axis[(this->longestAxisIndex + 1)%3];
     580    Vector a2 = *this->bvElement->axis[(this->longestAxisIndex + 2)%3];
     581    Vector c = *this->bvElement->center;
     582    float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3];
     583    float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3];
     584    glBegin(GL_QUADS);
     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    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);
     589    glEnd();
    589590    }
    590591  }
Note: See TracChangeset for help on using the changeset viewer.