Changeset 4708 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jun 26, 2005, 6:51:31 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
r4705 r4708 643 643 { 644 644 /* first check all axis */ 645 Vector t = nodeA->getAbsCoor() + *boxA->center - ( nodeB->getAbsCoor() + *boxB->center);645 Vector t; 646 646 float rA = 0.0f; 647 647 float rB = 0.0f; 648 648 Vector l; 649 Vector rotAxisA[3]; 650 Vector rotAxisB[3]; 651 652 rotAxisA[0] = nodeA->getAbsDir().apply(boxA->axis[0]); 653 rotAxisA[1] = nodeA->getAbsDir().apply(boxA->axis[1]); 654 rotAxisA[2] = nodeA->getAbsDir().apply(boxA->axis[2]); 655 656 rotAxisB[0] = nodeB->getAbsDir().apply(boxB->axis[0]); 657 rotAxisB[1] = nodeB->getAbsDir().apply(boxB->axis[1]); 658 rotAxisB[2] = nodeB->getAbsDir().apply(boxB->axis[2]); 659 660 t = nodeA->getAbsCoor() + nodeA->getAbsDir().apply(*boxA->center) - ( nodeB->getAbsCoor() + nodeB->getAbsDir().apply(*boxB->center)); 661 662 // printf("\n"); 663 // printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[0].x, boxA->axis[0].y, boxA->axis[0].z, rotAxisA[0].x, rotAxisA[0].y, rotAxisA[0].z); 664 // printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[1].x, boxA->axis[1].y, boxA->axis[1].z, rotAxisA[1].x, rotAxisA[1].y, rotAxisA[1].z); 665 // printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[2].x, boxA->axis[2].y, boxA->axis[2].z, rotAxisA[2].x, rotAxisA[2].y, rotAxisA[2].z); 666 // 667 // printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[0].x, boxB->axis[0].y, boxB->axis[0].z, rotAxisB[0].x, rotAxisB[0].y, rotAxisB[0].z); 668 // printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[1].x, boxB->axis[1].y, boxB->axis[1].z, rotAxisB[1].x, rotAxisB[1].y, rotAxisB[1].z); 669 // printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[2].x, boxB->axis[2].y, boxB->axis[2].z, rotAxisB[2].x, rotAxisB[2].y, rotAxisB[2].z); 670 649 671 650 672 /* All 3 axis of the object A */ … … 653 675 rA = 0.0f; 654 676 rB = 0.0f; 655 l = boxA->axis[j];656 657 rA += fabs(boxA->halfLength[0] * boxA->axis[0].dot(l));658 rA += fabs(boxA->halfLength[1] * boxA->axis[1].dot(l));659 rA += fabs(boxA->halfLength[2] * boxA->axis[2].dot(l));660 661 rB += fabs(boxB->halfLength[0] * boxB->axis[0].dot(l));662 rB += fabs(boxB->halfLength[1] * boxB->axis[1].dot(l));663 rB += fabs(boxB->halfLength[2] * boxB->axis[2].dot(l));677 l = rotAxisA[j]; 678 679 rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l)); 680 rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l)); 681 rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l)); 682 683 rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l)); 684 rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l)); 685 rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l)); 664 686 665 687 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); … … 677 699 rA = 0.0f; 678 700 rB = 0.0f; 679 l = boxB->axis[j];680 681 rA += fabs(boxA->halfLength[0] * boxA->axis[0].dot(l));682 rA += fabs(boxA->halfLength[1] * boxA->axis[1].dot(l));683 rA += fabs(boxA->halfLength[2] * boxA->axis[2].dot(l));684 685 rB += fabs(boxB->halfLength[0] * boxB->axis[0].dot(l));686 rB += fabs(boxB->halfLength[1] * boxB->axis[1].dot(l));687 rB += fabs(boxB->halfLength[2] * boxB->axis[2].dot(l));701 l = rotAxisB[j]; 702 703 rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l)); 704 rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l)); 705 rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l)); 706 707 rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l)); 708 rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l)); 709 rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l)); 688 710 689 711 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); … … 705 727 rA = 0.0f; 706 728 rB = 0.0f; 707 l = boxA->axis[j].cross(boxB->axis[k]);708 709 rA += fabs(boxA->halfLength[0] * boxA->axis[0].dot(l));710 rA += fabs(boxA->halfLength[1] * boxA->axis[1].dot(l));711 rA += fabs(boxA->halfLength[2] * boxA->axis[2].dot(l));712 713 rB += fabs(boxB->halfLength[0] * boxB->axis[0].dot(l));714 rB += fabs(boxB->halfLength[1] * boxB->axis[1].dot(l));715 rB += fabs(boxB->halfLength[2] * boxB->axis[2].dot(l));729 l = rotAxisA[j].cross(rotAxisB[k]); 730 731 rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l)); 732 rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l)); 733 rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l)); 734 735 rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l)); 736 rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l)); 737 rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l)); 716 738 717 739 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); … … 731 753 return true; 732 754 } 755 756 733 757 734 758 -
orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc
r4707 r4708 44 44 bool drawModel; 45 45 46 TestEntity* a;46 Environment* a; 47 47 Environment* b; 48 48 … … 69 69 entityList = new tList<WorldEntity>(); 70 70 71 a = new TestEntity(); a->setName("Clown1");72 //a = new Environment(); a->setName("Clown");71 //a = new TestEntity(); a->setName("Clown1"); 72 a = new Environment(); a->setName("Clown"); 73 73 b = new Environment(); b->setName("Jaeger"); 74 74 75 b->setRelCoor(0.0, 0.0, -10.0); 76 b->setRelDir(Quaternion(-M_PI/2.0f, Vector(0.0, 1.0, 0.0))); 75 77 76 78 // TestEntity* c = new TestEntity(); c->setName("Colwn2"); … … 79 81 entityList->add(a); 80 82 entityList->add(b); 81 // entityList->add(c);82 83 83 84 CDEngine::getInstance()->setEntityList(entityList); … … 225 226 226 227 227 tIterator<WorldEntity>* iterator = entityList->getIterator(); /* get the iterator - JAVA style */228 WorldEntity* entity = iterator->nextElement(); /* this returns the FIRST element */229 while( entity != NULL) /* nextElement() will return NULL at the end */228 tIterator<WorldEntity>* iterator = entityList->getIterator(); 229 WorldEntity* entity = iterator->nextElement(); 230 while( entity != NULL) 230 231 { 231 232 entity->tick(dt); 232 entity = iterator->nextElement(); /* give back the next element or NULL if last */233 entity = iterator->nextElement(); 233 234 } 234 235 delete iterator; … … 238 239 void Framework::moduleDraw() const 239 240 { 240 //CDEngine::getInstance()->drawBV(depth, drawMode); 241 242 tIterator<WorldEntity>* iterator = entityList->getIterator(); /* get the iterator - JAVA style */ 243 WorldEntity* entity = iterator->nextElement(); /* this returns the FIRST element */ 244 while( entity != NULL) /* nextElement() will return NULL at the end */ 241 tIterator<WorldEntity>* iterator = entityList->getIterator(); 242 WorldEntity* entity = iterator->nextElement(); 243 while( entity != NULL) 245 244 { 246 245 if( likely(drawModel)) 247 246 entity->draw(); 248 247 entity->drawBVTree(depth, drawMode); 249 entity = iterator->nextElement(); /* give back the next element or NULL if last */248 entity = iterator->nextElement(); 250 249 } 251 250 delete iterator;
Note: See TracChangeset
for help on using the changeset viewer.