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 | this->rootNode->drawBV(currentDepth, depth); |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | void OBBTree::drawBVPolygon(int currentDepth, const int depth) const |
---|
76 | { |
---|
77 | if( likely(this->rootNode != NULL)) |
---|
78 | this->rootNode->drawBVPolygon(currentDepth, depth); |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | void OBBTree::drawBVBlended(int currentDepth, const int depth) const |
---|
83 | { |
---|
84 | if( likely(this->rootNode != NULL)) |
---|
85 | this->rootNode->drawBVBlended(currentDepth, depth); |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | void OBBTree::debug() |
---|
90 | { |
---|
91 | PRINT(0)("\n==============================| OBBTree::debug() |===\n"); |
---|
92 | PRINT(0)("= Spawning Tree: Start\n"); |
---|
93 | |
---|
94 | /* generate some test vertices */ |
---|
95 | sVec3D* vertList = new sVec3D[3]; |
---|
96 | sVec3D data[] = {{0.0, 0.0, 0.0},{5.0, 0.0, 10.0},{-5.0, 0.0, 10.0}}; |
---|
97 | |
---|
98 | for(int i = 0; i < 3; ++i) |
---|
99 | { |
---|
100 | vertList[i][0] = data[i][0]; |
---|
101 | vertList[i][1] = data[i][1]; |
---|
102 | vertList[i][2] = data[i][2]; |
---|
103 | } |
---|
104 | |
---|
105 | this->spawnBVTree(1, vertList, 3); |
---|
106 | |
---|
107 | PRINT(0)("= Spawning Tree: Finished\n"); |
---|
108 | PRINT(0)("=======================================================\n"); |
---|
109 | |
---|
110 | } |
---|