Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/bsp_manager.h @ 8547

Last change on this file since 8547 was 8490, checked in by patrick, 18 years ago

merged the bsp branche back to trunk

File size: 3.6 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2006 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: bottac@ee.ethz.ch
13
14   Inspired by:
15   Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
16   Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
17
18   Collision detection adapted from:
19   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
20*/
21
22#ifndef _BSP_MANAGER_H
23#define _BSP_MANAGER_H
24
25
26#include <vector>
27#include <deque>
28
29
30
31// FORWARD DECLARATIONS
32class  BspFile;
33class BspTreeLeaf;
34class BspTreeNode;
35class Vector;
36class set;
37struct face;
38struct brush;
39struct plane;
40
41class WorldEntity;
42
43struct BspCollisionEvent
44{
45  Vector normal; //!< normal Vector, length 1
46  Vector place;  //!< Absoloute coordinates of collision
47};
48
49class BspManager
50{
51public:
52  // Constructors
53  BspManager(WorldEntity* parent);
54
55  BspManager(const char* fileName, float scale = 0.4f);
56  void load(const char* fileName, float scale);
57
58  // Functions
59  const void draw();
60  const void tick(float time);
61  void draw_debug_face(int Face);
62  void draw_face(int Face);
63  void draw_patch(face* Face);
64
65
66  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity.
67                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
68
69private:
70  // Functions
71  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
72  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
73  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
74  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
75  void TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
76  void  checkCollisionBox(void);
77  void  checkBrushRay(brush* curBrush);
78  void  checkBrushRayN(brush* curBrush);
79  void   checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
80
81  void drawDebugCube(Vector* cam);
82  bool isAlreadyVisible(int Face);
83  void addFace(int Face);
84
85  // Data
86  BspFile*  bspFile;
87  BspTreeNode* root;
88  Vector cam;
89  Vector ship;
90  Vector  viewDir;
91  plane* collPlane;
92  int lastTex;
93
94  //obsolete: global variables for collision detection
95  bool  outputStartsOut;
96  bool  outputAllSolid;
97  float outputFraction;
98  Vector inputStart;
99  Vector inputEnd;
100 
101  Vector traceMins; //!< Mins of current bbox
102  Vector traceMaxs; //!< Maxs of current bbox
103  Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box.
104                            For example, if traceMins was (-100,-3,-15) and traceMaxs was (55,22,7), traceExtents */
105
106  WorldEntity* parent;          //!< the parent entity of the bspManager: interface to this
107
108  bool * alreadyVisible;
109  // Deques to store the visible faces
110  ::std::deque<int> trasparent; //!< the ones with transparancy go here
111  ::std::deque<int> opal; //!< the others here.
112
113  Vector out;  //!< For debugging only
114  Vector out1; //!< For debugging only
115  Vector out2; //!< For debugging only
116                       
117  int tgl;
118};
119
120#endif /* _BSP_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.