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 | #include "material.h" |
---|
24 | |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | |
---|
28 | Material* OBBTree::material = NULL; |
---|
29 | |
---|
30 | /** |
---|
31 | \brief standard constructor |
---|
32 | */ |
---|
33 | OBBTree::OBBTree () |
---|
34 | { |
---|
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); |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | /** |
---|
43 | \brief standard deconstructor |
---|
44 | |
---|
45 | */ |
---|
46 | OBBTree::~OBBTree () |
---|
47 | { |
---|
48 | // delete what has to be deleted here |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length) |
---|
53 | { |
---|
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); |
---|
62 | } |
---|
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 |
---|
74 | { |
---|
75 | if( likely(this->rootNode != NULL)) |
---|
76 | { |
---|
77 | this->rootNode->drawBV(currentDepth, depth); |
---|
78 | this->rootNode->drawBVPolygon(currentDepth, depth); |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | void OBBTree::drawBVPolygon(int currentDepth, const int depth) const |
---|
84 | { |
---|
85 | if( likely(this->rootNode != NULL)) |
---|
86 | this->rootNode->drawBVPolygon(currentDepth, depth); |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | void OBBTree::drawBVBlended(int currentDepth, const int depth) const |
---|
91 | { |
---|
92 | if( likely(this->rootNode != NULL)) |
---|
93 | this->rootNode->drawBVBlended(currentDepth, depth); |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | void OBBTree::debug() |
---|
98 | { |
---|
99 | PRINT(0)("\n==============================| OBBTree::debug() |===\n"); |
---|
100 | PRINT(0)("= Spawning Tree: Start\n"); |
---|
101 | |
---|
102 | /* generate some test vertices */ |
---|
103 | int const length = 6; |
---|
104 | sVec3D* vertList = new sVec3D[length]; |
---|
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}}; |
---|
106 | |
---|
107 | for(int i = 0; i < length; ++i) |
---|
108 | { |
---|
109 | vertList[i][0] = data[i][0]; |
---|
110 | vertList[i][1] = data[i][1]; |
---|
111 | vertList[i][2] = data[i][2]; |
---|
112 | } |
---|
113 | |
---|
114 | this->spawnBVTree(2, vertList, length); |
---|
115 | |
---|
116 | PRINT(0)("= Spawning Tree: Finished\n"); |
---|
117 | PRINT(0)("=======================================================\n"); |
---|
118 | |
---|
119 | } |
---|