Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4656 was 4638, checked in by patrick, 19 years ago

orxonox/trunk: changed the way the data is displayed, now supports colors and stuff. noticed some data drawing problems. the tree separation seems so work perfectly but the graphical data representation is buggy

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