Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: hash table preparation for quadtree nodes lookup

File size: 1.7 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}
53
54
55/**
56 *  standard deconstructor
57
58*/
59Quadtree::~Quadtree ()
60{
61  // delete what has to be deleted here
62  delete [] this->nodes;
63  delete this->rootNode;
64}
65
66
67/**
68 *  draws the debug quadtree boxes around the model
69 */
70void Quadtree::drawTree(int depth, int drawMode) const
71{
72  this->rootNode->drawTree(depth, drawMode);
73}
Note: See TracBrowser for help on using the repository browser.