Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4636 in orxonox.OLD for orxonox/trunk


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

orxonox/trunk: collision detection now displays very beatuifully

Location:
orxonox/trunk/src
Files:
3 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  }
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4635 r4636  
    2727#include "md2Model.h"
    2828
     29
     30
     31
    2932MD2Model* model;
     33int drawMode;
     34int depth;
    3035
    3136void Framework::moduleInit(int argc, char** argv)
     
    4853//   }
    4954
    50   CDEngine::getInstance()->debugSpawnTree(3, model->data->pVertices, model->data->numVertices);
     55  CDEngine::getInstance()->debugSpawnTree(7, model->data->pVertices, model->data->numVertices);
    5156
    5257
     
    5661  lightMan->addLight();
    5762  lightMan->setPosition(10, 20, 100);
     63
     64  drawMode = DRAW_MODEL;
     65  depth = 2;
     66
     67  printf("\n\n===========================");
     68  printf("Collision Detection Modler:\n");
     69  printf("Key Bindings:\n");
     70  printf(" -| Displaying Polygons\t\t p\n");
     71  printf(" -| Displaying Separation Plane\t s\n");
     72  printf("\n");
     73  printf(" -| Tree Depth 1\t\t 1\n");
     74  printf(" -| Tree Depth 2\t\t 2\n");
     75  printf(" -| Tree Depth 3\t\t 3\n");
     76  printf(" -| Tree Depth 4\t\t 4\n");
     77  printf(" -| Tree Depth 5\t\t 5\n");
     78  printf("===========================\n\n");
    5879}
    5980
     
    6687      switch (event->key.keysym.sym)
    6788      {
    68         case SDLK_i:
     89        case SDLK_a:
     90          drawMode |= DRAW_ALL;
    6991          break;
    7092        case SDLK_1:
    71           printf("alsjdf;lajsfd;lajsdf\n");
    72           break;
     93        {
     94          printf("Setting tree depth = 1\n");
     95          depth = 1;
     96          int temp = drawMode & DRAW_ALL;
     97          drawMode ^= temp;
     98          drawMode |= DRAW_SINGLE;
     99          break;
     100        }
     101        case SDLK_2:
     102        {
     103          printf("Setting tree depth = 2\n");
     104          depth = 2;
     105          int temp = drawMode & DRAW_ALL;
     106          drawMode ^= temp;
     107          drawMode |= DRAW_SINGLE;
     108          break;
     109        }
     110        case SDLK_3:
     111        {
     112          printf("Setting tree depth = 3\n");
     113          depth = 3;
     114          int temp = drawMode & DRAW_ALL;
     115          drawMode ^= temp;
     116          drawMode |= DRAW_SINGLE;
     117          break;
     118        }
     119        case SDLK_4:
     120        {
     121          printf("Setting tree depth = 4\n");
     122          depth = 4;
     123          int temp = drawMode & DRAW_ALL;
     124          drawMode ^= temp;
     125          drawMode |= DRAW_SINGLE;
     126          break;
     127        }
     128        case SDLK_5:
     129        {
     130          printf("Setting tree depth = 5\n");
     131          depth = 5;
     132          int temp = drawMode & DRAW_ALL;
     133          drawMode ^= temp;
     134          drawMode |= DRAW_SINGLE;
     135          break;
     136        }
     137        case SDLK_6:
     138        {
     139          printf("Setting tree depth = 6\n");
     140          depth = 6;
     141          int temp = drawMode & DRAW_ALL;
     142          drawMode ^= temp;
     143          drawMode |= DRAW_SINGLE;
     144          break;
     145        }
     146        case SDLK_s:
     147          if(drawMode & DRAW_SEPARATING_PLANE)
     148          {
     149            int temp = drawMode & DRAW_SEPARATING_PLANE;
     150            drawMode ^= temp;
     151            printf("Removing Separation Plane\n");
     152          }
     153          else
     154          {
     155            drawMode |= DRAW_SEPARATING_PLANE;
     156            printf("Drawing Separation Plane\n");
     157          }
     158
     159          break;
     160        case SDLK_p:
     161          if(drawMode & DRAW_BV_POLYGON)
     162          {
     163            int temp = drawMode & DRAW_BV_POLYGON;
     164            drawMode ^= temp;
     165            printf("Removing OBB Polygons\n");
     166          }
     167          else
     168          {
     169            drawMode |= DRAW_BV_POLYGON;
     170            printf("Drawing OBB Polygons\n");
     171          }
     172          break;
     173
    73174      }
    74175  }
     
    83184void Framework::moduleDraw() const
    84185{
    85   CDEngine::getInstance()->drawBV(2, DRAW_MODEL);
     186  CDEngine::getInstance()->drawBV(depth, drawMode);
    86187
    87188  LightManager::getInstance()->draw();
  • orxonox/trunk/src/subprojects/framework.cc

    r4554 r4636  
    171171#endif
    172172            break;
    173           case SDLK_a:
     173          case SDLK_t:
    174174            camera->setRelCoor(camera->getRelCoor() + (camera->getTarget()->getAbsCoor() - camera->getAbsCoor())*.1);
    175175            break;
     
    184184            this->printHelp();
    185185            break;
    186           case SDLK_2:
     186          case SDLK_l:
    187187            for (int i = 0; i < 3; i++)
    188188              {
Note: See TracChangeset for help on using the changeset viewer.