| 1 | /* |
|---|
| 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: |
|---|
| 12 | main-programmer: Patrick Boenzli |
|---|
| 13 | co-programmer: ... |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION |
|---|
| 17 | |
|---|
| 18 | #include "obb_tree.h" |
|---|
| 19 | #include "obb_tree_node.h" |
|---|
| 20 | #include "obb.h" |
|---|
| 21 | #include "debug.h" |
|---|
| 22 | #include "compiler.h" |
|---|
| 23 | |
|---|
| 24 | using namespace std; |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | \brief standard constructor |
|---|
| 29 | */ |
|---|
| 30 | OBBTree::OBBTree () |
|---|
| 31 | { |
|---|
| 32 | this->setClassID(CL_OBB_TREE, "OBBTree"); |
|---|
| 33 | |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | /** |
|---|
| 38 | \brief standard deconstructor |
|---|
| 39 | |
|---|
| 40 | */ |
|---|
| 41 | OBBTree::~OBBTree () |
|---|
| 42 | { |
|---|
| 43 | // delete what has to be deleted here |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length) |
|---|
| 48 | { |
|---|
| 49 | if( unlikely(this->rootNode != NULL)) |
|---|
| 50 | { |
|---|
| 51 | PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n"); |
|---|
| 52 | this->flushTree(); |
|---|
| 53 | } |
|---|
| 54 | OBBTreeNode* node = new OBBTreeNode(); |
|---|
| 55 | this->rootNode = node; |
|---|
| 56 | this->rootNode->spawnBVTree(depth, verticesList, length); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | void OBBTree:: flushTree() |
|---|
| 61 | {} |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | void OBBTree::collideWith(const OBBTree &tree) |
|---|
| 65 | {} |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | void OBBTree::drawBV(int currentDepth, const int depth) const |
|---|
| 69 | { |
|---|
| 70 | if( likely(this->rootNode != NULL)) |
|---|
| 71 | { |
|---|
| 72 | this->rootNode->drawBV(currentDepth, depth); |
|---|
| 73 | this->rootNode->drawBVPolygon(currentDepth, depth); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | void OBBTree::drawBVPolygon(int currentDepth, const int depth) const |
|---|
| 79 | { |
|---|
| 80 | if( likely(this->rootNode != NULL)) |
|---|
| 81 | this->rootNode->drawBVPolygon(currentDepth, depth); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | void OBBTree::drawBVBlended(int currentDepth, const int depth) const |
|---|
| 86 | { |
|---|
| 87 | if( likely(this->rootNode != NULL)) |
|---|
| 88 | this->rootNode->drawBVBlended(currentDepth, depth); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | void OBBTree::debug() |
|---|
| 93 | { |
|---|
| 94 | PRINT(0)("\n==============================| OBBTree::debug() |===\n"); |
|---|
| 95 | PRINT(0)("= Spawning Tree: Start\n"); |
|---|
| 96 | |
|---|
| 97 | /* generate some test vertices */ |
|---|
| 98 | sVec3D* vertList = new sVec3D[3]; |
|---|
| 99 | sVec3D data[] = {{0.0, 0.0, 0.0},{10.0, -5.0, 0.0},{10.0, 5.0, 0.0}}; |
|---|
| 100 | |
|---|
| 101 | for(int i = 0; i < 3; ++i) |
|---|
| 102 | { |
|---|
| 103 | vertList[i][0] = data[i][0]; |
|---|
| 104 | vertList[i][1] = data[i][1]; |
|---|
| 105 | vertList[i][2] = data[i][2]; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | this->spawnBVTree(1, vertList, 3); |
|---|
| 109 | |
|---|
| 110 | PRINT(0)("= Spawning Tree: Finished\n"); |
|---|
| 111 | PRINT(0)("=======================================================\n"); |
|---|
| 112 | |
|---|
| 113 | } |
|---|