Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4694 was 4682, checked in by patrick, 19 years ago

orxonox/trunk: now there is a possibility to render the bvtree through the world entities, the bvtree is a member of the worldentity

File size: 3.5 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->init();
34}
35
36OBBTree::OBBTree(int depth, sVec3D *verticesList, const int length)
37{
38  this->init();
39  this->spawnBVTree(depth, verticesList, length);
40}
41
42
43
44void OBBTree::init()
45{
46  this->setClassID(CL_OBB_TREE, "OBBTree");
47
48  material = new Material*[5];
49  for(int i = 0; i < 5; ++i)
50  {
51    material[i] = new Material();
52    material[i]->setIllum(3);
53  }
54  material[0]->setAmbient(0.0, 0.3, 0.0);
55  material[1]->setAmbient(0.4, 0.0, 0.2);
56  material[2]->setAmbient(1.0, 0.0, 0.0);
57  material[3]->setAmbient(5.0, 3.0, 1.0);
58  material[4]->setAmbient(1.0, 0.0, 7.0);
59
60
61  transparentMaterial = new Material*[5];
62  for(int i = 0; i < 5; ++i)
63  {
64    transparentMaterial[i] = new Material();
65    transparentMaterial[i]->setIllum(3);
66    transparentMaterial[i]->setTransparency(0.2);
67  }
68  transparentMaterial[0]->setAmbient(0.0, 0.3, 0.0);
69  transparentMaterial[1]->setAmbient(0.4, 0.0, 0.2);
70  transparentMaterial[2]->setAmbient(1.0, 0.0, 0.0);
71  transparentMaterial[3]->setAmbient(5.0, 3.0, 1.0);
72  transparentMaterial[4]->setAmbient(1.0, 0.0, 7.0);
73
74  this->id = 0;
75}
76
77/**
78   \brief standard deconstructor
79
80*/
81OBBTree::~OBBTree ()
82{
83  // delete what has to be deleted here
84}
85
86
87void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length)
88{
89  if( unlikely(this->rootNode != NULL))
90    {
91      PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n");
92      this->flushTree();
93    }
94  OBBTreeNode* node = new OBBTreeNode();
95  this->rootNode = node;
96  this->rootNode->setTreeRef(this);
97  this->rootNode->spawnBVTree(--depth, verticesList, length);
98}
99
100
101void OBBTree:: flushTree()
102{}
103
104
105void OBBTree::collideWith(const OBBTree &tree)
106{}
107
108
109void OBBTree::drawBV(int depth, int drawMode) const
110{
111  if( likely(this->rootNode != NULL))
112  {
113    this->rootNode->drawBV(depth, drawMode);
114  }
115}
116
117
118
119void OBBTree::debug()
120{
121  PRINT(0)("\n==============================| OBBTree::debug() |===\n");
122  PRINT(0)("=  Spawning Tree: Start\n");
123
124  /* generate some test vertices */
125  int const length = 9;
126  sVec3D* vertList = new sVec3D[length];
127//   sVec3D data[length]  = {{0.0, 0.0, 0.0},{1.0, 2.0, 5.0},{0.0, 6.0, 9.0},
128//                           {1.0, 4.0, 12.0}, {1.0, 2.0, 16.0}, {0.0, 0.0, 19.0},
129//                           {0.0, 3.0, 23.0}, {1.0, 5.0, 30.0}, {0.0, 10.0, 35.0}};
130
131  sVec3D data[length]  = {{0.0, 0.0, 0.0},{1.0, 2.0, 5.0},{1.0, 5.0, 30.0},
132                          {0.0, 3.0, 23.0}, {0.0, 6.0, 9.0}, {0.0, 10.0, 35.0},
133                          {1.0, 4.0, 12.0}, {1.0, 2.0, 16.0}, {0.0, 0.0, 19.0}};
134
135  for(int i = 0; i < length; ++i)
136    {
137      vertList[i][0] = data[i][0];
138      vertList[i][1] = data[i][1];
139      vertList[i][2] = data[i][2];
140    }
141
142  this->spawnBVTree(3, vertList, length);
143
144  PRINT(0)("=  Spawning Tree: Finished\n");
145  PRINT(0)("=======================================================\n");
146
147}
Note: See TracBrowser for help on using the repository browser.