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