Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/collision_detection/cd_engine.cc @ 4694

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

orxonox/trunk: now ready to implement the collision detection algorithm

File size: 2.8 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 "cd_engine.h"
19#include "obb_tree.h"
20#include "debug.h"
21#include "abstract_model.h"
22#include "world_entity.h"
23#include "list.h"
24
25using namespace std;
26
27
28/**
29   \brief standard constructor
30*/
31CDEngine::CDEngine ()
32{
33   this->setClassName("CDEngine");
34   this->setClassID(CL_CD_ENGINE, "CDEngine");
35
36   /* testing purposes only: */
37   //this->rootTree = new OBBTree();
38}
39
40/**
41   \brief the singleton reference to this class
42*/
43CDEngine* CDEngine::singletonRef = NULL;
44
45/**
46   \brief standard deconstructor
47
48*/
49CDEngine::~CDEngine ()
50{
51  CDEngine::singletonRef = NULL;
52
53}
54
55
56void CDEngine::checkCollisions()
57{
58  tIterator<WorldEntity>* iterator1 = entityList->getIterator();
59  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
60  WorldEntity* entity1 = iterator1->nextElement();
61  WorldEntity* entity2 = iterator2->seekElement(entity1);
62  printf("checking for collisions\n");
63  while( entity1 != NULL)
64  {
65    printf("entering l1\n");
66    while( entity2 != NULL)
67    {
68      printf("entering l2 - checking object %s against %s\n", entity1->getName(), entity2->getName());
69      entity1->collideWith(entity2);
70      entity2 = iterator2->nextElement();
71
72    }
73    entity1 = iterator1->nextElement();
74    entity2 = iterator2->seekElement(entity1);
75
76  }
77  delete iterator1;
78  delete iterator2;
79}
80
81
82
83void CDEngine::checkCollisionObjects()
84{}
85
86
87void CDEngine::checkCollisionGround()
88{}
89
90
91void CDEngine::drawBV(int depth, int drawMode) const
92{
93  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
94  //this->rootTree->drawBV(depth, drawMode);
95
96  tIterator<WorldEntity>* iterator = entityList->getIterator();
97  WorldEntity* entity = iterator->nextElement();
98  while( entity != NULL)
99  {
100    entity->drawBVTree(depth, drawMode);
101    entity = iterator->nextElement();
102  }
103  delete iterator;
104  //model->draw();
105}
106
107
108
109
110
111void CDEngine::debug()
112{
113  PRINT(0)("\n=============================| CDEngine::debug() |===\n");
114  PRINT(0)("=  CDEngine: Spawning Tree Start\n");
115  //this->rootTree->debug();
116  PRINT(0)("=  CDEngine: Spawning Tree: Finished\n");
117  PRINT(0)("=======================================================\n");
118
119}
120
121void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices)
122{
123  if ( this->rootTree == NULL)
124    this->rootTree = new OBBTree();
125  this->rootTree->spawnBVTree(depth, vertices, numVertices);
126}
Note: See TracBrowser for help on using the repository browser.