Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: implemented an elegant draw function to display the tree in different ways

File size: 2.4 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, int drawMode) const
80{
81  if( likely(this->rootNode != NULL))
82  {
83    this->rootNode->drawBV(depth, drawMode);
84  }
85}
86
87
88
89void OBBTree::debug()
90{
91  PRINT(0)("\n==============================| OBBTree::debug() |===\n");
92  PRINT(0)("=  Spawning Tree: Start\n");
93
94  /* generate some test vertices */
95  int const length = 6;
96  sVec3D* vertList = new sVec3D[length];
97  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}};
98
99  for(int i = 0; i < length; ++i)
100    {
101      vertList[i][0] = data[i][0];
102      vertList[i][1] = data[i][1];
103      vertList[i][2] = data[i][2];
104    }
105
106  this->spawnBVTree(2, vertList, length);
107
108  PRINT(0)("=  Spawning Tree: Finished\n");
109  PRINT(0)("=======================================================\n");
110
111}
Note: See TracBrowser for help on using the repository browser.