Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc @ 4913

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

orxonox/trunk: working on the hash table alg

File size: 1.9 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_SPATIAL_SEPARATION
17
18#include "quadtree.h"
19#include "quadtree_node.h"
20#include "material.h"
21
22using namespace std;
23
24
25/**
26 *  standard constructor
27   @todo this constructor is not jet implemented - do it
28*/
29Quadtree::Quadtree (modelInfo* pModelInfo, const int treeDepth)
30{
31   this->setClassID(CL_QUADTREE, "Quadtree");
32   this->pModelInfo = pModelInfo;
33   this->treeDepth = treeDepth;
34
35   /* initialize the materials for debug draw */
36   this->materials = new Material*[4];
37   for(int i = 0; i < 4; ++i)
38   {
39     materials[i] = new Material();
40     materials[i]->setIllum(3);
41   }
42   materials[0]->setAmbient(0.0, 0.3, 0.0);
43   materials[1]->setAmbient(0.4, 0.0, 0.2);
44   materials[2]->setAmbient(1.0, 0.0, 0.0);
45   materials[3]->setAmbient(5.0, 3.0, 1.0);
46
47   /* build the tree */
48   this->rootNode = new QuadtreeNode(this->pModelInfo, this, this->treeDepth);
49
50   /* make an array with access to the leafs of the Quad-Tree */
51   this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)];
52   int* index = new int; *index = 0;
53   for(int i = 0; i < (int)pow(2, treeDepth); ++i)
54     this->rootNode->buildHashTable(this->nodes, index);
55}
56
57
58/**
59 *  standard deconstructor
60
61*/
62Quadtree::~Quadtree ()
63{
64  // delete what has to be deleted here
65  delete [] this->nodes;
66  delete this->rootNode;
67}
68
69
70/**
71 *  draws the debug quadtree boxes around the model
72 */
73void Quadtree::drawTree(int depth, int drawMode) const
74{
75  //this->rootNode->drawTree(depth, drawMode);
76  for(int i = 0; i < 4; ++i)
77  {
78    this->nodes[i]->drawTree(0, 0);
79  }
80}
Note: See TracBrowser for help on using the repository browser.