[4615] | 1 | /* |
---|
[4510] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
[4511] | 12 | main-programmer: Patrick Boenzli |
---|
[4510] | 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[4511] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION |
---|
[4510] | 17 | |
---|
[4511] | 18 | #include "cd_engine.h" |
---|
[4546] | 19 | #include "obb_tree.h" |
---|
| 20 | #include "debug.h" |
---|
[4615] | 21 | #include "abstract_model.h" |
---|
[4689] | 22 | #include "world_entity.h" |
---|
| 23 | #include "list.h" |
---|
[4510] | 24 | |
---|
| 25 | using namespace std; |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | \brief standard constructor |
---|
| 30 | */ |
---|
[4615] | 31 | CDEngine::CDEngine () |
---|
[4510] | 32 | { |
---|
[4511] | 33 | this->setClassName("CDEngine"); |
---|
[4615] | 34 | this->setClassID(CL_CD_ENGINE, "CDEngine"); |
---|
[4551] | 35 | |
---|
| 36 | /* testing purposes only: */ |
---|
[4689] | 37 | //this->rootTree = new OBBTree(); |
---|
[4510] | 38 | } |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | \brief the singleton reference to this class |
---|
| 42 | */ |
---|
[4511] | 43 | CDEngine* CDEngine::singletonRef = NULL; |
---|
[4510] | 44 | |
---|
| 45 | /** |
---|
| 46 | \brief standard deconstructor |
---|
| 47 | |
---|
| 48 | */ |
---|
[4615] | 49 | CDEngine::~CDEngine () |
---|
[4510] | 50 | { |
---|
[4511] | 51 | CDEngine::singletonRef = NULL; |
---|
[4510] | 52 | |
---|
| 53 | } |
---|
[4546] | 54 | |
---|
| 55 | |
---|
[4675] | 56 | void CDEngine::checkCollisions() |
---|
| 57 | { |
---|
[4689] | 58 | tIterator<WorldEntity>* iterator1 = entityList->getIterator(); |
---|
| 59 | tIterator<WorldEntity>* iterator2 = entityList->getIterator(); |
---|
| 60 | WorldEntity* entity1 = iterator1->nextElement(); |
---|
[4694] | 61 | WorldEntity* entity2 = iterator2->seekElement(entity1); |
---|
| 62 | printf("checking for collisions\n"); |
---|
[4689] | 63 | while( entity1 != NULL) |
---|
| 64 | { |
---|
[4694] | 65 | printf("entering l1\n"); |
---|
| 66 | while( entity2 != NULL) |
---|
[4689] | 67 | { |
---|
[4694] | 68 | printf("entering l2 - checking object %s against %s\n", entity1->getName(), entity2->getName()); |
---|
[4689] | 69 | entity1->collideWith(entity2); |
---|
| 70 | entity2 = iterator2->nextElement(); |
---|
[4694] | 71 | |
---|
[4689] | 72 | } |
---|
| 73 | entity1 = iterator1->nextElement(); |
---|
[4694] | 74 | entity2 = iterator2->seekElement(entity1); |
---|
| 75 | |
---|
[4689] | 76 | } |
---|
| 77 | delete iterator1; |
---|
| 78 | delete iterator2; |
---|
[4675] | 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
[4688] | 83 | void CDEngine::checkCollisionObjects() |
---|
| 84 | {} |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | void CDEngine::checkCollisionGround() |
---|
| 88 | {} |
---|
| 89 | |
---|
| 90 | |
---|
[4635] | 91 | void CDEngine::drawBV(int depth, int drawMode) const |
---|
[4551] | 92 | { |
---|
| 93 | /* this would operate on worldList bases, for testing purposes, we only use one OBBTree */ |
---|
[4689] | 94 | //this->rootTree->drawBV(depth, drawMode); |
---|
| 95 | |
---|
| 96 | tIterator<WorldEntity>* iterator = entityList->getIterator(); |
---|
| 97 | WorldEntity* entity = iterator->nextElement(); |
---|
| 98 | while( entity != NULL) |
---|
| 99 | { |
---|
| 100 | entity->drawBVTree(depth, drawMode); |
---|
| 101 | entity = iterator->nextElement(); |
---|
| 102 | } |
---|
| 103 | delete iterator; |
---|
| 104 | //model->draw(); |
---|
[4551] | 105 | } |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | |
---|
[4546] | 111 | void CDEngine::debug() |
---|
| 112 | { |
---|
| 113 | PRINT(0)("\n=============================| CDEngine::debug() |===\n"); |
---|
| 114 | PRINT(0)("= CDEngine: Spawning Tree Start\n"); |
---|
[4689] | 115 | //this->rootTree->debug(); |
---|
[4546] | 116 | PRINT(0)("= CDEngine: Spawning Tree: Finished\n"); |
---|
[4615] | 117 | PRINT(0)("=======================================================\n"); |
---|
[4546] | 118 | |
---|
| 119 | } |
---|
[4615] | 120 | |
---|
| 121 | void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices) |
---|
| 122 | { |
---|
[4689] | 123 | if ( this->rootTree == NULL) |
---|
| 124 | this->rootTree = new OBBTree(); |
---|
[4615] | 125 | this->rootTree->spawnBVTree(depth, vertices, numVertices); |
---|
| 126 | } |
---|