Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/collision_detection/cd_engine.h @ 4921

Last change on this file since 4921 was 4919, checked in by patrick, 20 years ago

orxonox/trunk: CDEngine knows player and gets the array offsets

File size: 2.3 KB
Line 
1/*!
2    \file cd_engine.h
3  *  Definition of the collision detection engine
4
5*/
6
7#ifndef _CD_ENGINE_H
8#define _CD_ENGINE_H
9
10#include "base_object.h"
11#include "collision_defs.h"
12#include "abstract_model.h"
13
14template<class T> class tList;
15class WorldEntity;
16class OBBTree;
17class Terrain;
18class Player;
19
20
21//! featured state options, they are all additive
22typedef enum cdState
23  {
24    CD_DEBUG_DRAW_ALL = 1,
25    CD_DEBUG_DRAW_POLYGONS = 1<<1,
26    CD_DEBUG_DRAW_BLENDED = 1<<2,
27    CD_DEBUG_DRAW_HIT_BV = 1<<3,
28    CD_DEBUG_VERBOSE = 1<<4,
29
30    CD_STORE_VERTICES = 1<<5
31  };
32
33
34//! The class representing the collision detection system of orxonox
35class CDEngine : public BaseObject {
36
37 public:
38  virtual ~CDEngine();
39  /** @returns a Pointer to the only object of this Class */
40  static CDEngine* getInstance() { if (!singletonRef) singletonRef = new CDEngine(); return singletonRef; }
41  void init();
42
43  inline void setState(const int newState) { this->state = newState; }
44  inline const int getState() const { return this->state; }
45  inline void enable(const int options) { this->state |= options; }
46  inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
47
48  inline void setEntityList(tList<WorldEntity>* entityList) { this->entityList = entityList; }
49  inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
50  inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/
51
52  void drawBV(int depth, int drawMode) const;
53
54  void checkCollisions();
55
56  void debug();
57  void debugSpawnTree(int depth, sVec3D* vertices, int numVertices);
58  void debugDraw(int depth, int drawMode);
59
60 private:
61  CDEngine();
62  static CDEngine* singletonRef;
63
64  void spawnBVTree(int depth = MAX_BV_TREE_DEPTH);
65
66  void checkCollisionObjects();
67  void checkCollisionGround();
68
69
70 private:
71  int                     state;                            //!< the current state of the cd engine
72  tList<WorldEntity>*     entityList;                       //!< pointer to the world entity list
73  OBBTree*                rootTree;                         //!< for testing purposes a root tree
74
75  Terrain*                terrain;                          //!< this it a ref to the terrain, serving as a ground for all WE
76  Player*                 player;
77};
78
79#endif /* _CD_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.