Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/collision_detection/obb_tree.cc @ 4630

Last change on this file since 4630 was 4626, checked in by patrick, 19 years ago

orxonox/trunk: fight for a working lin alg jacobi decomposition algorithm.

File size: 2.6 KB
Line 
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
25using namespace std;
26
27
28/**
29   \brief standard constructor
30*/
31OBBTree::OBBTree ()
32{
33  this->setClassID(CL_OBB_TREE, "OBBTree");
34
35  material = new Material*[3];
36  for(int i = 0; i < 3; ++i)
37  {
38    material[i] = new Material();
39    material[i]->setIllum(0);
40  }
41  material[0]->setAmbient(0.0, 0.3, 0.0);
42  material[1]->setAmbient(0.0, 0.0, 0.2);
43  material[2]->setAmbient(1.0, 0.0, 0.0);
44}
45
46
47/**
48   \brief standard deconstructor
49
50*/
51OBBTree::~OBBTree ()
52{
53  // delete what has to be deleted here
54}
55
56
57void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length)
58{
59  if( unlikely(this->rootNode != NULL))
60    {
61      PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n");
62      this->flushTree();
63    }
64  OBBTreeNode* node = new OBBTreeNode();
65  this->rootNode = node;
66  this->rootNode->setTreeRef(this);
67  this->rootNode->spawnBVTree(--depth, verticesList, length);
68}
69
70
71void OBBTree:: flushTree()
72{}
73
74
75void OBBTree::collideWith(const OBBTree &tree)
76{}
77
78
79void OBBTree::drawBV(int depth) const
80{
81  if( likely(this->rootNode != NULL))
82  {
83    this->rootNode->drawBV(depth);
84    this->rootNode->drawBVPolygon(depth);
85  }
86}
87
88
89void OBBTree::drawBVPolygon(int depth) const
90{
91  if( likely(this->rootNode != NULL))
92    this->rootNode->drawBVPolygon(depth);
93}
94
95
96void OBBTree::drawBVBlended(int depth) const
97{
98  if( likely(this->rootNode != NULL))
99    this->rootNode->drawBVBlended(depth);
100}
101
102
103void OBBTree::debug()
104{
105  PRINT(0)("\n==============================| OBBTree::debug() |===\n");
106  PRINT(0)("=  Spawning Tree: Start\n");
107
108  /* generate some test vertices */
109  int const length = 6;
110  sVec3D* vertList = new sVec3D[length];
111  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}};
112
113  for(int i = 0; i < length; ++i)
114    {
115      vertList[i][0] = data[i][0];
116      vertList[i][1] = data[i][1];
117      vertList[i][2] = data[i][2];
118    }
119
120  this->spawnBVTree(2, vertList, length);
121
122  PRINT(0)("=  Spawning Tree: Finished\n");
123  PRINT(0)("=======================================================\n");
124
125}
Note: See TracBrowser for help on using the repository browser.