Changeset 4636 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 15, 2005, 10:38:15 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
r4635 r4636 475 475 if( drawMode & DRAW_BV_AXIS || drawMode & DRAW_ALL) 476 476 { 477 if( drawMode & DRAW_SINGLE && depth == 0)477 if( !(drawMode & DRAW_SINGLE && depth != 0)) 478 478 { 479 479 /* draw the obb axes */ … … 501 501 if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL) 502 502 { 503 if( drawMode & DRAW_SINGLE && depth == 0)503 if( !(drawMode & DRAW_SINGLE && depth != 0)) 504 504 { 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 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 570 } 571 571 572 } 572 573 573 574 if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL) 574 575 { 575 if( drawMode & DRAW_SINGLE && depth == 0)576 if( !(drawMode & DRAW_SINGLE && depth != 0)) 576 577 { 577 578 579 580 581 582 583 584 585 586 587 588 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(); 589 590 } 590 591 } -
orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc
r4635 r4636 27 27 #include "md2Model.h" 28 28 29 30 31 29 32 MD2Model* model; 33 int drawMode; 34 int depth; 30 35 31 36 void Framework::moduleInit(int argc, char** argv) … … 48 53 // } 49 54 50 CDEngine::getInstance()->debugSpawnTree( 3, model->data->pVertices, model->data->numVertices);55 CDEngine::getInstance()->debugSpawnTree(7, model->data->pVertices, model->data->numVertices); 51 56 52 57 … … 56 61 lightMan->addLight(); 57 62 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"); 58 79 } 59 80 … … 66 87 switch (event->key.keysym.sym) 67 88 { 68 case SDLK_i: 89 case SDLK_a: 90 drawMode |= DRAW_ALL; 69 91 break; 70 92 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 73 174 } 74 175 } … … 83 184 void Framework::moduleDraw() const 84 185 { 85 CDEngine::getInstance()->drawBV( 2, DRAW_MODEL);186 CDEngine::getInstance()->drawBV(depth, drawMode); 86 187 87 188 LightManager::getInstance()->draw(); -
orxonox/trunk/src/subprojects/framework.cc
r4554 r4636 171 171 #endif 172 172 break; 173 case SDLK_ a:173 case SDLK_t: 174 174 camera->setRelCoor(camera->getRelCoor() + (camera->getTarget()->getAbsCoor() - camera->getAbsCoor())*.1); 175 175 break; … … 184 184 this->printHelp(); 185 185 break; 186 case SDLK_ 2:186 case SDLK_l: 187 187 for (int i = 0; i < 3; i++) 188 188 {
Note: See TracChangeset
for help on using the changeset viewer.