Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: drawing in diffrent hirarchies works now, with diffrent colors

File size: 2.6 KB
RevLine 
[4573]1/*
[4510]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:
[4511]12   main-programmer: Patrick Boenzli
[4510]13   co-programmer: ...
14*/
15
[4511]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION
[4510]17
[4511]18#include "obb_tree.h"
[4550]19#include "obb_tree_node.h"
[4531]20#include "obb.h"
[4546]21#include "debug.h"
[4550]22#include "compiler.h"
[4616]23#include "material.h"
[4510]24
25using namespace std;
26
27
28/**
29   \brief standard constructor
30*/
[4573]31OBBTree::OBBTree ()
[4510]32{
[4616]33  this->setClassID(CL_OBB_TREE, "OBBTree");
[4622]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);
[4510]44}
45
46
47/**
48   \brief standard deconstructor
49
50*/
[4573]51OBBTree::~OBBTree ()
[4510]52{
53  // delete what has to be deleted here
54}
[4528]55
56
[4551]57void OBBTree::spawnBVTree(int depth, sVec3D *verticesList, const int length)
[4531]58{
[4551]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;
[4622]66  this->rootNode->setTreeRef(this);
[4551]67  this->rootNode->spawnBVTree(depth, verticesList, length);
[4531]68}
[4528]69
70
71void OBBTree:: flushTree()
72{}
73
74
75void OBBTree::collideWith(const OBBTree &tree)
76{}
77
78
[4622]79void OBBTree::drawBV(int depth) const
[4550]80{
81  if( likely(this->rootNode != NULL))
[4581]82  {
[4622]83    this->rootNode->drawBV(depth);
84    this->rootNode->drawBVPolygon(depth);
[4581]85  }
[4550]86}
[4528]87
88
[4622]89void OBBTree::drawBVPolygon(int depth) const
[4550]90{
91  if( likely(this->rootNode != NULL))
[4622]92    this->rootNode->drawBVPolygon(depth);
[4550]93}
[4528]94
95
[4622]96void OBBTree::drawBVBlended(int depth) const
[4550]97{
98  if( likely(this->rootNode != NULL))
[4622]99    this->rootNode->drawBVBlended(depth);
[4550]100}
[4546]101
102
103void OBBTree::debug()
104{
105  PRINT(0)("\n==============================| OBBTree::debug() |===\n");
106  PRINT(0)("=  Spawning Tree: Start\n");
[4573]107
[4551]108  /* generate some test vertices */
[4612]109  int const length = 6;
[4589]110  sVec3D* vertList = new sVec3D[length];
[4612]111  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}};
[4551]112
[4589]113  for(int i = 0; i < length; ++i)
[4553]114    {
115      vertList[i][0] = data[i][0];
116      vertList[i][1] = data[i][1];
117      vertList[i][2] = data[i][2];
118    }
119
[4615]120  this->spawnBVTree(2, vertList, length);
[4551]121
[4546]122  PRINT(0)("=  Spawning Tree: Finished\n");
[4573]123  PRINT(0)("=======================================================\n");
[4546]124
125}
Note: See TracBrowser for help on using the repository browser.